dockview-core 1.17.2 → 2.1.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 (132) hide show
  1. package/dist/cjs/api/component.api.d.ts +3 -3
  2. package/dist/cjs/api/dockviewGroupPanelApi.d.ts +10 -8
  3. package/dist/cjs/api/dockviewGroupPanelApi.js +1 -0
  4. package/dist/cjs/api/dockviewPanelApi.d.ts +6 -14
  5. package/dist/cjs/api/dockviewPanelApi.js +5 -3
  6. package/dist/cjs/dnd/abstractDragHandler.js +1 -1
  7. package/dist/cjs/dnd/dnd.d.ts +2 -2
  8. package/dist/cjs/dnd/droptarget.js +4 -4
  9. package/dist/cjs/dockview/components/panel/content.d.ts +2 -2
  10. package/dist/cjs/dockview/components/panel/content.js +3 -1
  11. package/dist/cjs/dockview/components/tab/defaultTab.d.ts +3 -3
  12. package/dist/cjs/dockview/components/tab/tab.js +4 -4
  13. package/dist/cjs/dockview/components/titlebar/tabsContainer.js +5 -9
  14. package/dist/cjs/dockview/components/titlebar/voidContainer.js +1 -2
  15. package/dist/cjs/dockview/components/watermark/watermark.d.ts +1 -4
  16. package/dist/cjs/dockview/components/watermark/watermark.js +2 -34
  17. package/dist/cjs/dockview/dockviewComponent.d.ts +33 -16
  18. package/dist/cjs/dockview/dockviewComponent.js +103 -38
  19. package/dist/cjs/dockview/dockviewGroupPanel.js +16 -12
  20. package/dist/cjs/dockview/dockviewGroupPanelModel.d.ts +4 -3
  21. package/dist/cjs/dockview/dockviewGroupPanelModel.js +10 -10
  22. package/dist/cjs/dockview/dockviewPanel.d.ts +4 -4
  23. package/dist/cjs/dockview/dockviewPanelModel.d.ts +1 -1
  24. package/dist/cjs/dockview/options.d.ts +12 -0
  25. package/dist/cjs/dockview/options.js +1 -0
  26. package/dist/cjs/dom.d.ts +11 -1
  27. package/dist/cjs/dom.js +19 -1
  28. package/dist/cjs/gridview/baseComponentGridview.d.ts +8 -3
  29. package/dist/cjs/gridview/baseComponentGridview.js +8 -8
  30. package/dist/cjs/gridview/basePanelView.d.ts +1 -1
  31. package/dist/cjs/gridview/branchNode.d.ts +1 -1
  32. package/dist/cjs/gridview/branchNode.js +1 -1
  33. package/dist/cjs/gridview/gridview.d.ts +9 -1
  34. package/dist/cjs/gridview/gridview.js +51 -7
  35. package/dist/cjs/gridview/gridviewPanel.d.ts +4 -0
  36. package/dist/cjs/gridview/gridviewPanel.js +60 -32
  37. package/dist/cjs/gridview/leafNode.d.ts +1 -1
  38. package/dist/cjs/index.d.ts +8 -9
  39. package/dist/cjs/index.js +14 -7
  40. package/dist/cjs/overlay/overlay.d.ts +6 -3
  41. package/dist/cjs/overlay/overlay.js +15 -0
  42. package/dist/cjs/paneview/defaultPaneviewHeader.d.ts +1 -1
  43. package/dist/cjs/paneview/defaultPaneviewHeader.js +5 -3
  44. package/dist/cjs/paneview/paneview.d.ts +3 -3
  45. package/dist/cjs/paneview/paneview.js +3 -3
  46. package/dist/cjs/paneview/paneviewComponent.d.ts +2 -2
  47. package/dist/cjs/paneview/paneviewPanel.d.ts +2 -2
  48. package/dist/cjs/paneview/paneviewPanel.js +3 -3
  49. package/dist/cjs/popoutWindow.js +23 -16
  50. package/dist/cjs/splitview/splitview.d.ts +6 -6
  51. package/dist/cjs/splitview/splitview.js +18 -17
  52. package/dist/cjs/splitview/splitviewComponent.d.ts +2 -2
  53. package/dist/cjs/splitview/viewItem.d.ts +1 -1
  54. package/dist/cjs/svg.js +1 -1
  55. package/dist/dockview-core.amd.js +346 -210
  56. package/dist/dockview-core.amd.js.map +1 -1
  57. package/dist/dockview-core.amd.min.js +2 -2
  58. package/dist/dockview-core.amd.min.js.map +1 -1
  59. package/dist/dockview-core.amd.min.noStyle.js +2 -2
  60. package/dist/dockview-core.amd.min.noStyle.js.map +1 -1
  61. package/dist/dockview-core.amd.noStyle.js +345 -209
  62. package/dist/dockview-core.amd.noStyle.js.map +1 -1
  63. package/dist/dockview-core.cjs.js +346 -210
  64. package/dist/dockview-core.cjs.js.map +1 -1
  65. package/dist/dockview-core.esm.js +347 -209
  66. package/dist/dockview-core.esm.js.map +1 -1
  67. package/dist/dockview-core.esm.min.js +2 -2
  68. package/dist/dockview-core.esm.min.js.map +1 -1
  69. package/dist/dockview-core.js +346 -210
  70. package/dist/dockview-core.js.map +1 -1
  71. package/dist/dockview-core.min.js +2 -2
  72. package/dist/dockview-core.min.js.map +1 -1
  73. package/dist/dockview-core.min.noStyle.js +2 -2
  74. package/dist/dockview-core.min.noStyle.js.map +1 -1
  75. package/dist/dockview-core.noStyle.js +345 -209
  76. package/dist/dockview-core.noStyle.js.map +1 -1
  77. package/dist/esm/api/component.api.d.ts +3 -3
  78. package/dist/esm/api/dockviewGroupPanelApi.d.ts +10 -8
  79. package/dist/esm/api/dockviewGroupPanelApi.js +1 -0
  80. package/dist/esm/api/dockviewPanelApi.d.ts +6 -14
  81. package/dist/esm/api/dockviewPanelApi.js +5 -3
  82. package/dist/esm/dnd/abstractDragHandler.js +1 -1
  83. package/dist/esm/dnd/dnd.d.ts +2 -2
  84. package/dist/esm/dnd/droptarget.js +4 -4
  85. package/dist/esm/dockview/components/panel/content.d.ts +2 -2
  86. package/dist/esm/dockview/components/panel/content.js +4 -2
  87. package/dist/esm/dockview/components/tab/defaultTab.d.ts +3 -3
  88. package/dist/esm/dockview/components/tab/tab.js +4 -4
  89. package/dist/esm/dockview/components/titlebar/tabsContainer.js +5 -9
  90. package/dist/esm/dockview/components/titlebar/voidContainer.js +1 -2
  91. package/dist/esm/dockview/components/watermark/watermark.d.ts +1 -4
  92. package/dist/esm/dockview/components/watermark/watermark.js +2 -34
  93. package/dist/esm/dockview/dockviewComponent.d.ts +33 -16
  94. package/dist/esm/dockview/dockviewComponent.js +102 -37
  95. package/dist/esm/dockview/dockviewGroupPanel.js +16 -12
  96. package/dist/esm/dockview/dockviewGroupPanelModel.d.ts +4 -3
  97. package/dist/esm/dockview/dockviewGroupPanelModel.js +10 -10
  98. package/dist/esm/dockview/dockviewPanel.d.ts +4 -4
  99. package/dist/esm/dockview/dockviewPanelModel.d.ts +1 -1
  100. package/dist/esm/dockview/options.d.ts +12 -0
  101. package/dist/esm/dockview/options.js +1 -0
  102. package/dist/esm/dom.d.ts +11 -1
  103. package/dist/esm/dom.js +14 -0
  104. package/dist/esm/gridview/baseComponentGridview.d.ts +8 -3
  105. package/dist/esm/gridview/baseComponentGridview.js +8 -4
  106. package/dist/esm/gridview/basePanelView.d.ts +1 -1
  107. package/dist/esm/gridview/branchNode.d.ts +1 -1
  108. package/dist/esm/gridview/branchNode.js +1 -1
  109. package/dist/esm/gridview/gridview.d.ts +9 -1
  110. package/dist/esm/gridview/gridview.js +51 -7
  111. package/dist/esm/gridview/gridviewPanel.d.ts +4 -0
  112. package/dist/esm/gridview/gridviewPanel.js +40 -12
  113. package/dist/esm/gridview/leafNode.d.ts +1 -1
  114. package/dist/esm/index.d.ts +8 -9
  115. package/dist/esm/index.js +5 -6
  116. package/dist/esm/overlay/overlay.d.ts +6 -3
  117. package/dist/esm/overlay/overlay.js +11 -0
  118. package/dist/esm/paneview/defaultPaneviewHeader.d.ts +1 -1
  119. package/dist/esm/paneview/defaultPaneviewHeader.js +5 -3
  120. package/dist/esm/paneview/paneview.d.ts +3 -3
  121. package/dist/esm/paneview/paneview.js +3 -3
  122. package/dist/esm/paneview/paneviewComponent.d.ts +2 -2
  123. package/dist/esm/paneview/paneviewPanel.d.ts +2 -2
  124. package/dist/esm/paneview/paneviewPanel.js +3 -3
  125. package/dist/esm/popoutWindow.js +24 -17
  126. package/dist/esm/splitview/splitview.d.ts +6 -6
  127. package/dist/esm/splitview/splitview.js +18 -17
  128. package/dist/esm/splitview/splitviewComponent.d.ts +2 -2
  129. package/dist/esm/splitview/viewItem.d.ts +1 -1
  130. package/dist/esm/svg.js +1 -1
  131. package/dist/styles/dockview.css +111 -151
  132. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * dockview-core
3
- * @version 1.17.2
3
+ * @version 2.1.0
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -328,31 +328,6 @@
328
328
  }
329
329
  }
330
330
 
331
- function createComponent(id, componentName, components = {}, frameworkComponents = {}, createFrameworkComponent, fallback) {
332
- const Component = typeof componentName === 'string'
333
- ? components[componentName]
334
- : undefined;
335
- const FrameworkComponent = typeof componentName === 'string'
336
- ? frameworkComponents[componentName]
337
- : undefined;
338
- if (Component && FrameworkComponent) {
339
- throw new Error(`Cannot create '${id}'. component '${componentName}' registered as both a component and frameworkComponent`);
340
- }
341
- if (FrameworkComponent) {
342
- if (!createFrameworkComponent) {
343
- throw new Error(`Cannot create '${id}' for framework component '${componentName}'. you must register a frameworkPanelWrapper to use framework components`);
344
- }
345
- return createFrameworkComponent.createComponent(id, componentName, FrameworkComponent);
346
- }
347
- if (!Component) {
348
- if (fallback) {
349
- return fallback();
350
- }
351
- throw new Error(`Cannot create '${id}', no component '${componentName}' provided`);
352
- }
353
- return new Component(id, componentName);
354
- }
355
-
356
331
  function watchElementResize(element, cb) {
357
332
  const observer = new ResizeObserver((entires) => {
358
333
  /**
@@ -821,10 +796,10 @@
821
796
  const tmp = this.size;
822
797
  this.size = this.orthogonalSize;
823
798
  this.orthogonalSize = tmp;
824
- removeClasses(this.element, 'horizontal', 'vertical');
799
+ removeClasses(this.element, 'dv-horizontal', 'dv-vertical');
825
800
  this.element.classList.add(this.orientation == exports.Orientation.HORIZONTAL
826
- ? 'horizontal'
827
- : 'vertical');
801
+ ? 'dv-horizontal'
802
+ : 'dv-vertical');
828
803
  }
829
804
  get minimumSize() {
830
805
  return this.viewItems.reduce((r, item) => r + item.minimumSize, 0);
@@ -1002,11 +977,11 @@
1002
977
  }
1003
978
  style(styles) {
1004
979
  if ((styles === null || styles === void 0 ? void 0 : styles.separatorBorder) === 'transparent') {
1005
- removeClasses(this.element, 'separator-border');
980
+ removeClasses(this.element, 'dv-separator-border');
1006
981
  this.element.style.removeProperty('--dv-separator-border');
1007
982
  }
1008
983
  else {
1009
- addClasses(this.element, 'separator-border');
984
+ addClasses(this.element, 'dv-separator-border');
1010
985
  if (styles === null || styles === void 0 ? void 0 : styles.separatorBorder) {
1011
986
  this.element.style.setProperty('--dv-separator-border', styles.separatorBorder);
1012
987
  }
@@ -1076,7 +1051,7 @@
1076
1051
  }
1077
1052
  addView(view, size = { type: 'distribute' }, index = this.viewItems.length, skipLayout) {
1078
1053
  const container = document.createElement('div');
1079
- container.className = 'view';
1054
+ container.className = 'dv-view';
1080
1055
  container.appendChild(view.element);
1081
1056
  let viewSize;
1082
1057
  if (typeof size === 'number') {
@@ -1108,7 +1083,7 @@
1108
1083
  if (this.viewItems.length > 1) {
1109
1084
  //add sash
1110
1085
  const sash = document.createElement('div');
1111
- sash.className = 'sash';
1086
+ sash.className = 'dv-sash';
1112
1087
  const onPointerStart = (event) => {
1113
1088
  for (const item of this.viewItems) {
1114
1089
  item.enabled = false;
@@ -1367,7 +1342,8 @@
1367
1342
  const offset = i === 0 || visiblePanelsBeforeThisView === 0
1368
1343
  ? 0
1369
1344
  : viewLeftOffsets[i - 1] +
1370
- (visiblePanelsBeforeThisView / sashCount) * marginReducedSize;
1345
+ (visiblePanelsBeforeThisView / sashCount) *
1346
+ marginReducedSize;
1371
1347
  if (i < this.viewItems.length - 1) {
1372
1348
  // calculate sash position
1373
1349
  const newSize = view.visible
@@ -1478,27 +1454,27 @@
1478
1454
  }
1479
1455
  }
1480
1456
  updateSash(sash, state) {
1481
- toggleClass(sash.container, 'disabled', state === exports.SashState.DISABLED);
1482
- toggleClass(sash.container, 'enabled', state === exports.SashState.ENABLED);
1483
- toggleClass(sash.container, 'maximum', state === exports.SashState.MAXIMUM);
1484
- toggleClass(sash.container, 'minimum', state === exports.SashState.MINIMUM);
1457
+ toggleClass(sash.container, 'dv-disabled', state === exports.SashState.DISABLED);
1458
+ toggleClass(sash.container, 'dv-enabled', state === exports.SashState.ENABLED);
1459
+ toggleClass(sash.container, 'dv-maximum', state === exports.SashState.MAXIMUM);
1460
+ toggleClass(sash.container, 'dv-minimum', state === exports.SashState.MINIMUM);
1485
1461
  }
1486
1462
  createViewContainer() {
1487
1463
  const element = document.createElement('div');
1488
- element.className = 'view-container';
1464
+ element.className = 'dv-view-container';
1489
1465
  return element;
1490
1466
  }
1491
1467
  createSashContainer() {
1492
1468
  const element = document.createElement('div');
1493
- element.className = 'sash-container';
1469
+ element.className = 'dv-sash-container';
1494
1470
  return element;
1495
1471
  }
1496
1472
  createContainer() {
1497
1473
  const element = document.createElement('div');
1498
1474
  const orientationClassname = this._orientation === exports.Orientation.HORIZONTAL
1499
- ? 'horizontal'
1500
- : 'vertical';
1501
- element.className = `split-view-container ${orientationClassname}`;
1475
+ ? 'dv-horizontal'
1476
+ : 'dv-vertical';
1477
+ element.className = `dv-split-view-container ${orientationClassname}`;
1502
1478
  return element;
1503
1479
  }
1504
1480
  dispose() {
@@ -1549,7 +1525,7 @@
1549
1525
  this.onDidChange = this._onDidChange.event;
1550
1526
  this._orientation = (_a = options.orientation) !== null && _a !== void 0 ? _a : exports.Orientation.VERTICAL;
1551
1527
  this.element = document.createElement('div');
1552
- this.element.className = 'pane-container';
1528
+ this.element.className = 'dv-pane-container';
1553
1529
  container.appendChild(this.element);
1554
1530
  this.splitview = new Splitview(this.element, {
1555
1531
  orientation: this._orientation,
@@ -1641,10 +1617,10 @@
1641
1617
  clearTimeout(this.animationTimer);
1642
1618
  this.animationTimer = undefined;
1643
1619
  }
1644
- addClasses(this.element, 'animated');
1620
+ addClasses(this.element, 'dv-animated');
1645
1621
  this.animationTimer = setTimeout(() => {
1646
1622
  this.animationTimer = undefined;
1647
- removeClasses(this.element, 'animated');
1623
+ removeClasses(this.element, 'dv-animated');
1648
1624
  }, 200);
1649
1625
  }
1650
1626
  dispose() {
@@ -1869,7 +1845,7 @@
1869
1845
  this._orthogonalSize = orthogonalSize;
1870
1846
  this._size = size;
1871
1847
  this.element = document.createElement('div');
1872
- this.element.className = 'branch-node';
1848
+ this.element.className = 'dv-branch-node';
1873
1849
  if (!childDescriptors) {
1874
1850
  this.splitview = new Splitview(this.element, {
1875
1851
  orientation: this.orientation,
@@ -2080,7 +2056,7 @@
2080
2056
  if (!parentElement) {
2081
2057
  throw new Error('Invalid grid element');
2082
2058
  }
2083
- if (/\bgrid-view\b/.test(parentElement.className)) {
2059
+ if (/\bdv-grid-view\b/.test(parentElement.className)) {
2084
2060
  return [];
2085
2061
  }
2086
2062
  const index = indexInParent(parentElement);
@@ -2217,6 +2193,7 @@
2217
2193
  if (this.hasMaximizedView()) {
2218
2194
  this.exitMaximizedView();
2219
2195
  }
2196
+ serializeBranchNode(this.getView(), this.orientation);
2220
2197
  const hiddenOnMaximize = [];
2221
2198
  function hideAllViewsBut(parent, exclude) {
2222
2199
  for (let i = 0; i < parent.children.length; i++) {
@@ -2238,7 +2215,10 @@
2238
2215
  }
2239
2216
  hideAllViewsBut(this.root, node);
2240
2217
  this._maximizedNode = { leaf: node, hiddenOnMaximize };
2241
- this._onDidMaximizedNodeChange.fire();
2218
+ this._onDidMaximizedNodeChange.fire({
2219
+ view: node.view,
2220
+ isMaximized: true,
2221
+ });
2242
2222
  }
2243
2223
  exitMaximizedView() {
2244
2224
  if (!this._maximizedNode) {
@@ -2259,24 +2239,51 @@
2259
2239
  }
2260
2240
  }
2261
2241
  showViewsInReverseOrder(this.root);
2242
+ const tmp = this._maximizedNode.leaf;
2262
2243
  this._maximizedNode = undefined;
2263
- this._onDidMaximizedNodeChange.fire();
2244
+ this._onDidMaximizedNodeChange.fire({
2245
+ view: tmp.view,
2246
+ isMaximized: false,
2247
+ });
2264
2248
  }
2265
2249
  serialize() {
2250
+ const maximizedView = this.maximizedView();
2251
+ let maxmizedViewLocation;
2252
+ if (maximizedView) {
2253
+ /**
2254
+ * The minimum information we can get away with in order to serialize a maxmized view is it's location within the grid
2255
+ * which is represented as a branch of indices
2256
+ */
2257
+ maxmizedViewLocation = getGridLocation(maximizedView.element);
2258
+ }
2266
2259
  if (this.hasMaximizedView()) {
2267
2260
  /**
2268
- * do not persist maximized view state
2269
- * firstly exit any maximized views to ensure the correct dimensions are persisted
2261
+ * the saved layout cannot be in its maxmized state otherwise all of the underlying
2262
+ * view dimensions will be wrong
2263
+ *
2264
+ * To counteract this we temporaily remove the maximized view to compute the serialized output
2265
+ * of the grid before adding back the maxmized view as to not alter the layout from the users
2266
+ * perspective when `.toJSON()` is called
2270
2267
  */
2271
2268
  this.exitMaximizedView();
2272
2269
  }
2273
2270
  const root = serializeBranchNode(this.getView(), this.orientation);
2274
- return {
2271
+ const resullt = {
2275
2272
  root,
2276
2273
  width: this.width,
2277
2274
  height: this.height,
2278
2275
  orientation: this.orientation,
2279
2276
  };
2277
+ if (maxmizedViewLocation) {
2278
+ resullt.maximizedNode = {
2279
+ location: maxmizedViewLocation,
2280
+ };
2281
+ }
2282
+ if (maximizedView) {
2283
+ // replace any maximzied view that was removed for serialization purposes
2284
+ this.maximizeView(maximizedView);
2285
+ }
2286
+ return resullt;
2280
2287
  }
2281
2288
  dispose() {
2282
2289
  this.disposable.dispose();
@@ -2295,6 +2302,19 @@
2295
2302
  const orientation = json.orientation;
2296
2303
  const height = orientation === exports.Orientation.VERTICAL ? json.height : json.width;
2297
2304
  this._deserialize(json.root, orientation, deserializer, height);
2305
+ /**
2306
+ * The deserialied layout must be positioned through this.layout(...)
2307
+ * before any maximizedNode can be positioned
2308
+ */
2309
+ this.layout(json.width, json.height);
2310
+ if (json.maximizedNode) {
2311
+ const location = json.maximizedNode.location;
2312
+ const [_, node] = this.getNode(location);
2313
+ if (!(node instanceof LeafNode)) {
2314
+ return;
2315
+ }
2316
+ this.maximizeView(node.view);
2317
+ }
2298
2318
  }
2299
2319
  _deserialize(root, orientation, deserializer, orthogonalSize) {
2300
2320
  this.root = this._deserializeNode(root, orientation, deserializer, orthogonalSize);
@@ -2428,7 +2448,7 @@
2428
2448
  this._onDidMaximizedNodeChange = new Emitter();
2429
2449
  this.onDidMaximizedNodeChange = this._onDidMaximizedNodeChange.event;
2430
2450
  this.element = document.createElement('div');
2431
- this.element.className = 'grid-view';
2451
+ this.element.className = 'dv-grid-view';
2432
2452
  this._locked = locked !== null && locked !== void 0 ? locked : false;
2433
2453
  this._margin = margin !== null && margin !== void 0 ? margin : 0;
2434
2454
  this.root = new BranchNode(orientation, proportionalLayout, styles, 0, 0, this.locked, this.margin);
@@ -2719,6 +2739,8 @@
2719
2739
  this.onDidRemove = this._onDidRemove.event;
2720
2740
  this._onDidAdd = new Emitter();
2721
2741
  this.onDidAdd = this._onDidAdd.event;
2742
+ this._onDidMaximizedChange = new Emitter();
2743
+ this.onDidMaximizedChange = this._onDidMaximizedChange.event;
2722
2744
  this._onDidActiveChange = new Emitter();
2723
2745
  this.onDidActiveChange = this._onDidActiveChange.event;
2724
2746
  this._bufferOnDidLayoutChange = new AsapEvent();
@@ -2734,7 +2756,12 @@
2734
2756
  this.gridview.locked = !!options.locked;
2735
2757
  this.element.appendChild(this.gridview.element);
2736
2758
  this.layout(0, 0, true); // set some elements height/widths
2737
- this.addDisposables(this.gridview.onDidViewVisibilityChange(() => this._onDidViewVisibilityChangeMicroTaskQueue.fire()), this.onDidViewVisibilityChangeMicroTaskQueue(() => {
2759
+ this.addDisposables(this.gridview.onDidMaximizedNodeChange((event) => {
2760
+ this._onDidMaximizedChange.fire({
2761
+ panel: event.view,
2762
+ isMaximized: event.isMaximized,
2763
+ });
2764
+ }), this.gridview.onDidViewVisibilityChange(() => this._onDidViewVisibilityChangeMicroTaskQueue.fire()), this.onDidViewVisibilityChangeMicroTaskQueue(() => {
2738
2765
  this.layout(this.width, this.height, true);
2739
2766
  }), exports.DockviewDisposable.from(() => {
2740
2767
  var _a;
@@ -2784,9 +2811,6 @@
2784
2811
  hasMaximizedGroup() {
2785
2812
  return this.gridview.hasMaximizedView();
2786
2813
  }
2787
- get onDidMaximizedGroupChange() {
2788
- return this.gridview.onDidMaximizedNodeChange;
2789
- }
2790
2814
  doAddGroup(group, location = [0], size) {
2791
2815
  this.gridview.addView(group, size !== null && size !== void 0 ? size : exports.Sizing.Distribute, location);
2792
2816
  this._onDidAdd.fire(group);
@@ -3650,7 +3674,7 @@
3650
3674
  * dnd logic. You can see the code at
3651
3675
  * https://github.com/react-dnd/react-dnd/blob/main/packages/backend-html5/src/HTML5BackendImpl.ts#L542
3652
3676
  */
3653
- event.dataTransfer.setData('text/plain', '__dockview_internal_drag_event__');
3677
+ event.dataTransfer.setData('text/plain', '');
3654
3678
  }
3655
3679
  }
3656
3680
  }), addDisposableListener(this.el, 'dragend', () => {
@@ -3824,12 +3848,12 @@
3824
3848
  this.markAsUsed(e);
3825
3849
  if (!this.targetElement) {
3826
3850
  this.targetElement = document.createElement('div');
3827
- this.targetElement.className = 'drop-target-dropzone';
3851
+ this.targetElement.className = 'dv-drop-target-dropzone';
3828
3852
  this.overlayElement = document.createElement('div');
3829
- this.overlayElement.className = 'drop-target-selection';
3853
+ this.overlayElement.className = 'dv-drop-target-selection';
3830
3854
  this._state = 'center';
3831
3855
  this.targetElement.appendChild(this.overlayElement);
3832
- this.element.classList.add('drop-target');
3856
+ this.element.classList.add('dv-drop-target');
3833
3857
  this.element.append(this.targetElement);
3834
3858
  }
3835
3859
  this.toggleClasses(quadrant, width, height);
@@ -3967,7 +3991,7 @@
3967
3991
  this.element.removeChild(this.targetElement);
3968
3992
  this.targetElement = undefined;
3969
3993
  this.overlayElement = undefined;
3970
- this.element.classList.remove('drop-target');
3994
+ this.element.classList.remove('dv-drop-target');
3971
3995
  }
3972
3996
  }
3973
3997
  }
@@ -4304,7 +4328,7 @@
4304
4328
  this._headerVisible = isHeaderVisible;
4305
4329
  this._onDidChangeExpansionState.fire(this.isExpanded()); // initialize value
4306
4330
  this._orientation = orientation;
4307
- this.element.classList.add('pane');
4331
+ this.element.classList.add('dv-pane');
4308
4332
  this.addDisposables(this.api.onWillVisibilityChange((event) => {
4309
4333
  const { isVisible } = event;
4310
4334
  const { accessor } = this._params;
@@ -4401,14 +4425,14 @@
4401
4425
  renderOnce() {
4402
4426
  this.header = document.createElement('div');
4403
4427
  this.header.tabIndex = 0;
4404
- this.header.className = 'pane-header';
4428
+ this.header.className = 'dv-pane-header';
4405
4429
  this.header.style.height = `${this.headerSize}px`;
4406
4430
  this.header.style.lineHeight = `${this.headerSize}px`;
4407
4431
  this.header.style.minHeight = `${this.headerSize}px`;
4408
4432
  this.header.style.maxHeight = `${this.headerSize}px`;
4409
4433
  this.element.appendChild(this.header);
4410
4434
  this.body = document.createElement('div');
4411
- this.body.className = 'pane-body';
4435
+ this.body.className = 'dv-pane-body';
4412
4436
  this.element.appendChild(this.body);
4413
4437
  }
4414
4438
  // TODO slightly hacky by-pass of the component to create a body and header component
@@ -4529,7 +4553,7 @@
4529
4553
  this._onDidBlur = new Emitter();
4530
4554
  this.onDidBlur = this._onDidBlur.event;
4531
4555
  this._element = document.createElement('div');
4532
- this._element.className = 'content-container';
4556
+ this._element.className = 'dv-content-container';
4533
4557
  this._element.tabIndex = -1;
4534
4558
  this.addDisposables(this._onDidFocus, this._onDidBlur);
4535
4559
  this.dropTarget = new Droptarget(this.element, {
@@ -4602,6 +4626,8 @@
4602
4626
  referenceContainer: this,
4603
4627
  });
4604
4628
  break;
4629
+ default:
4630
+ throw new Error(`dockview: invalid renderer type '${panel.api.renderer}'`);
4605
4631
  }
4606
4632
  if (doRender) {
4607
4633
  const focusTracker = trackFocus(container);
@@ -4668,10 +4694,10 @@
4668
4694
  this._onDragStart = new Emitter();
4669
4695
  this.onDragStart = this._onDragStart.event;
4670
4696
  this._element = document.createElement('div');
4671
- this._element.className = 'tab';
4697
+ this._element.className = 'dv-tab';
4672
4698
  this._element.tabIndex = 0;
4673
4699
  this._element.draggable = true;
4674
- toggleClass(this.element, 'inactive-tab', true);
4700
+ toggleClass(this.element, 'dv-inactive-tab', true);
4675
4701
  const dragHandler = new TabDragHandler(this._element, this.accessor, this.group, this.panel);
4676
4702
  this.dropTarget = new Droptarget(this._element, {
4677
4703
  acceptedTargetZones: ['center'],
@@ -4704,8 +4730,8 @@
4704
4730
  }), this.dropTarget);
4705
4731
  }
4706
4732
  setActive(isActive) {
4707
- toggleClass(this.element, 'active-tab', isActive);
4708
- toggleClass(this.element, 'inactive-tab', !isActive);
4733
+ toggleClass(this.element, 'dv-active-tab', isActive);
4734
+ toggleClass(this.element, 'dv-inactive-tab', !isActive);
4709
4735
  }
4710
4736
  setContent(part) {
4711
4737
  if (this.content) {
@@ -4793,8 +4819,7 @@
4793
4819
  this._onDragStart = new Emitter();
4794
4820
  this.onDragStart = this._onDragStart.event;
4795
4821
  this._element = document.createElement('div');
4796
- this._element.className = 'void-container';
4797
- this._element.tabIndex = 0;
4822
+ this._element.className = 'dv-void-container';
4798
4823
  this._element.draggable = true;
4799
4824
  this.addDisposables(this._onDrop, this._onDragStart, addDisposableListener(this._element, 'pointerdown', () => {
4800
4825
  this.accessor.doSetGroupActive(this.group);
@@ -4913,16 +4938,16 @@
4913
4938
  this._onWillShowOverlay = new Emitter();
4914
4939
  this.onWillShowOverlay = this._onWillShowOverlay.event;
4915
4940
  this._element = document.createElement('div');
4916
- this._element.className = 'tabs-and-actions-container';
4941
+ this._element.className = 'dv-tabs-and-actions-container';
4917
4942
  toggleClass(this._element, 'dv-full-width-single-tab', this.accessor.options.singleTabMode === 'fullwidth');
4918
4943
  this.rightActionsContainer = document.createElement('div');
4919
- this.rightActionsContainer.className = 'right-actions-container';
4944
+ this.rightActionsContainer.className = 'dv-right-actions-container';
4920
4945
  this.leftActionsContainer = document.createElement('div');
4921
- this.leftActionsContainer.className = 'left-actions-container';
4946
+ this.leftActionsContainer.className = 'dv-left-actions-container';
4922
4947
  this.preActionsContainer = document.createElement('div');
4923
- this.preActionsContainer.className = 'pre-actions-container';
4948
+ this.preActionsContainer.className = 'dv-pre-actions-container';
4924
4949
  this.tabContainer = document.createElement('div');
4925
- this.tabContainer.className = 'tabs-container';
4950
+ this.tabContainer.className = 'dv-tabs-container';
4926
4951
  this.voidContainer = new VoidContainer(this.accessor, this.group);
4927
4952
  this._element.appendChild(this.preActionsContainer);
4928
4953
  this._element.appendChild(this.tabContainer);
@@ -5011,14 +5036,10 @@
5011
5036
  });
5012
5037
  }
5013
5038
  openPanel(panel, index = this.tabs.length) {
5014
- var _a;
5015
5039
  if (this.tabs.find((tab) => tab.value.panel.id === panel.id)) {
5016
5040
  return;
5017
5041
  }
5018
5042
  const tab = new Tab(panel, this.accessor, this.group);
5019
- if (!((_a = panel.view) === null || _a === void 0 ? void 0 : _a.tab)) {
5020
- throw new Error('invalid header component');
5021
- }
5022
5043
  tab.setContent(panel.view.tab);
5023
5044
  const disposable = new CompositeDisposable(tab.onDragStart((event) => {
5024
5045
  this._onTabDragStart.fire({ nativeEvent: event, panel });
@@ -5112,6 +5133,7 @@
5112
5133
  disableDnd: undefined,
5113
5134
  gap: undefined,
5114
5135
  className: undefined,
5136
+ noPanelsOverlay: undefined,
5115
5137
  };
5116
5138
  return Object.keys(properties);
5117
5139
  })();
@@ -5208,7 +5230,7 @@
5208
5230
  }
5209
5231
  class DockviewGroupPanelModel extends CompositeDisposable {
5210
5232
  get element() {
5211
- throw new Error('not supported');
5233
+ throw new Error('dockview: not supported');
5212
5234
  }
5213
5235
  get activePanel() {
5214
5236
  return this._activePanel;
@@ -5218,7 +5240,7 @@
5218
5240
  }
5219
5241
  set locked(value) {
5220
5242
  this._locked = value;
5221
- toggleClass(this.container, 'locked-groupview', value === 'no-drop-target' || value);
5243
+ toggleClass(this.container, 'dv-locked-groupview', value === 'no-drop-target' || value);
5222
5244
  }
5223
5245
  get isActive() {
5224
5246
  return this._isGroupActive;
@@ -5289,6 +5311,7 @@
5289
5311
  this._locked = false;
5290
5312
  this._location = { type: 'grid' };
5291
5313
  this.mostRecentlyUsed = [];
5314
+ this._overwriteRenderContainer = null;
5292
5315
  this._onDidChange = new Emitter();
5293
5316
  this.onDidChange = this._onDidChange.event;
5294
5317
  this._width = 0;
@@ -5319,8 +5342,7 @@
5319
5342
  this.onDidActivePanelChange = this._onDidActivePanelChange.event;
5320
5343
  this._onUnhandledDragOverEvent = new Emitter();
5321
5344
  this.onUnhandledDragOverEvent = this._onUnhandledDragOverEvent.event;
5322
- this._overwriteRenderContainer = null;
5323
- toggleClass(this.container, 'groupview', true);
5345
+ toggleClass(this.container, 'dv-groupview', true);
5324
5346
  this._api = new DockviewApi(this.accessor);
5325
5347
  this.tabsContainer = new TabsContainer(this.accessor, this.groupPanel);
5326
5348
  this.contentContainer = new ContentContainer(this.accessor, this);
@@ -5552,7 +5574,10 @@
5552
5574
  this.doClose(panel);
5553
5575
  }
5554
5576
  doClose(panel) {
5555
- this.accessor.removePanel(panel);
5577
+ const isLast = this.panels.length === 1 && this.accessor.groups.length === 1;
5578
+ this.accessor.removePanel(panel, isLast && this.accessor.options.noPanelsOverlay === 'emptyGroup'
5579
+ ? { removeEmptyGroup: false }
5580
+ : undefined);
5556
5581
  }
5557
5582
  isPanelActive(panel) {
5558
5583
  return this._activePanel === panel;
@@ -5565,8 +5590,8 @@
5565
5590
  return;
5566
5591
  }
5567
5592
  this._isGroupActive = isGroupActive;
5568
- toggleClass(this.container, 'active-group', isGroupActive);
5569
- toggleClass(this.container, 'inactive-group', !isGroupActive);
5593
+ toggleClass(this.container, 'dv-active-group', isGroupActive);
5594
+ toggleClass(this.container, 'dv-inactive-group', !isGroupActive);
5570
5595
  this.tabsContainer.setActive(this.isActive);
5571
5596
  if (!this._activePanel && this.panels.length > 0) {
5572
5597
  this.doSetActivePanel(this.panels[0]);
@@ -5658,7 +5683,6 @@
5658
5683
  }
5659
5684
  updateContainer() {
5660
5685
  var _a, _b;
5661
- toggleClass(this.container, 'empty', this.isEmpty);
5662
5686
  this.panels.forEach((panel) => panel.runEvents());
5663
5687
  if (this.isEmpty && !this.watermark) {
5664
5688
  const watermark = this.accessor.createWatermarkComponent();
@@ -5672,14 +5696,12 @@
5672
5696
  this.accessor.doSetGroupActive(this.groupPanel);
5673
5697
  }
5674
5698
  });
5675
- this.tabsContainer.hide();
5676
5699
  this.contentContainer.element.appendChild(this.watermark.element);
5677
5700
  }
5678
5701
  if (!this.isEmpty && this.watermark) {
5679
5702
  this.watermark.element.remove();
5680
5703
  (_b = (_a = this.watermark).dispose) === null || _b === void 0 ? void 0 : _b.call(_a);
5681
5704
  this.watermark = undefined;
5682
- this.tabsContainer.show();
5683
5705
  }
5684
5706
  }
5685
5707
  canDisplayOverlay(event, position, target) {
@@ -5799,6 +5821,34 @@
5799
5821
  return this._snap;
5800
5822
  }
5801
5823
  get minimumWidth() {
5824
+ /**
5825
+ * defer to protected function to allow subclasses to override easily.
5826
+ * see https://github.com/microsoft/TypeScript/issues/338
5827
+ */
5828
+ return this.__minimumWidth();
5829
+ }
5830
+ get minimumHeight() {
5831
+ /**
5832
+ * defer to protected function to allow subclasses to override easily.
5833
+ * see https://github.com/microsoft/TypeScript/issues/338
5834
+ */
5835
+ return this.__minimumHeight();
5836
+ }
5837
+ get maximumHeight() {
5838
+ /**
5839
+ * defer to protected function to allow subclasses to override easily.
5840
+ * see https://github.com/microsoft/TypeScript/issues/338
5841
+ */
5842
+ return this.__maximumHeight();
5843
+ }
5844
+ get maximumWidth() {
5845
+ /**
5846
+ * defer to protected function to allow subclasses to override easily.
5847
+ * see https://github.com/microsoft/TypeScript/issues/338
5848
+ */
5849
+ return this.__maximumWidth();
5850
+ }
5851
+ __minimumWidth() {
5802
5852
  const width = typeof this._minimumWidth === 'function'
5803
5853
  ? this._minimumWidth()
5804
5854
  : this._minimumWidth;
@@ -5808,7 +5858,17 @@
5808
5858
  }
5809
5859
  return width;
5810
5860
  }
5811
- get minimumHeight() {
5861
+ __maximumWidth() {
5862
+ const width = typeof this._maximumWidth === 'function'
5863
+ ? this._maximumWidth()
5864
+ : this._maximumWidth;
5865
+ if (width !== this._evaluatedMaximumWidth) {
5866
+ this._evaluatedMaximumWidth = width;
5867
+ this.updateConstraints();
5868
+ }
5869
+ return width;
5870
+ }
5871
+ __minimumHeight() {
5812
5872
  const height = typeof this._minimumHeight === 'function'
5813
5873
  ? this._minimumHeight()
5814
5874
  : this._minimumHeight;
@@ -5818,7 +5878,7 @@
5818
5878
  }
5819
5879
  return height;
5820
5880
  }
5821
- get maximumHeight() {
5881
+ __maximumHeight() {
5822
5882
  const height = typeof this._maximumHeight === 'function'
5823
5883
  ? this._maximumHeight()
5824
5884
  : this._maximumHeight;
@@ -5828,16 +5888,6 @@
5828
5888
  }
5829
5889
  return height;
5830
5890
  }
5831
- get maximumWidth() {
5832
- const width = typeof this._maximumWidth === 'function'
5833
- ? this._maximumWidth()
5834
- : this._maximumWidth;
5835
- if (width !== this._evaluatedMaximumWidth) {
5836
- this._evaluatedMaximumWidth = width;
5837
- this.updateConstraints();
5838
- }
5839
- return width;
5840
- }
5841
5891
  get isActive() {
5842
5892
  return this.api.isActive;
5843
5893
  }
@@ -5988,6 +6038,7 @@
5988
6038
  position: options.group
5989
6039
  ? (_c = options.position) !== null && _c !== void 0 ? _c : 'center'
5990
6040
  : 'center',
6041
+ index: options.index,
5991
6042
  },
5992
6043
  });
5993
6044
  }
@@ -6039,30 +6090,34 @@
6039
6090
  get minimumWidth() {
6040
6091
  var _a;
6041
6092
  const activePanelMinimumWidth = (_a = this.activePanel) === null || _a === void 0 ? void 0 : _a.minimumWidth;
6042
- return typeof activePanelMinimumWidth === 'number'
6043
- ? activePanelMinimumWidth
6044
- : MINIMUM_DOCKVIEW_GROUP_PANEL_WIDTH;
6093
+ if (typeof activePanelMinimumWidth === 'number') {
6094
+ return activePanelMinimumWidth;
6095
+ }
6096
+ return super.__minimumWidth();
6045
6097
  }
6046
6098
  get minimumHeight() {
6047
6099
  var _a;
6048
6100
  const activePanelMinimumHeight = (_a = this.activePanel) === null || _a === void 0 ? void 0 : _a.minimumHeight;
6049
- return typeof activePanelMinimumHeight === 'number'
6050
- ? activePanelMinimumHeight
6051
- : MINIMUM_DOCKVIEW_GROUP_PANEL_HEIGHT;
6101
+ if (typeof activePanelMinimumHeight === 'number') {
6102
+ return activePanelMinimumHeight;
6103
+ }
6104
+ return super.__minimumHeight();
6052
6105
  }
6053
6106
  get maximumWidth() {
6054
6107
  var _a;
6055
6108
  const activePanelMaximumWidth = (_a = this.activePanel) === null || _a === void 0 ? void 0 : _a.maximumWidth;
6056
- return typeof activePanelMaximumWidth === 'number'
6057
- ? activePanelMaximumWidth
6058
- : Number.MAX_SAFE_INTEGER;
6109
+ if (typeof activePanelMaximumWidth === 'number') {
6110
+ return activePanelMaximumWidth;
6111
+ }
6112
+ return super.__maximumWidth();
6059
6113
  }
6060
6114
  get maximumHeight() {
6061
6115
  var _a;
6062
6116
  const activePanelMaximumHeight = (_a = this.activePanel) === null || _a === void 0 ? void 0 : _a.maximumHeight;
6063
- return typeof activePanelMaximumHeight === 'number'
6064
- ? activePanelMaximumHeight
6065
- : Number.MAX_SAFE_INTEGER;
6117
+ if (typeof activePanelMaximumHeight === 'number') {
6118
+ return activePanelMaximumHeight;
6119
+ }
6120
+ return super.__maximumHeight();
6066
6121
  }
6067
6122
  get panels() {
6068
6123
  return this._model.panels;
@@ -6176,12 +6231,14 @@
6176
6231
  return this.group.api.getWindow();
6177
6232
  }
6178
6233
  moveTo(options) {
6179
- var _a;
6234
+ var _a, _b;
6180
6235
  this.accessor.moveGroupOrPanel({
6181
6236
  from: { groupId: this._group.id, panelId: this.panel.id },
6182
6237
  to: {
6183
- group: options.group,
6184
- position: (_a = options.position) !== null && _a !== void 0 ? _a : 'center',
6238
+ group: (_a = options.group) !== null && _a !== void 0 ? _a : this._group,
6239
+ position: options.group
6240
+ ? (_b = options.position) !== null && _b !== void 0 ? _b : 'center'
6241
+ : 'center',
6185
6242
  index: options.index,
6186
6243
  },
6187
6244
  });
@@ -6400,7 +6457,7 @@
6400
6457
  svg.setAttributeNS(null, 'viewBox', params.viewbox);
6401
6458
  svg.setAttributeNS(null, 'aria-hidden', 'false');
6402
6459
  svg.setAttributeNS(null, 'focusable', 'false');
6403
- svg.classList.add('dockview-svg');
6460
+ svg.classList.add('dv-svg');
6404
6461
  const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
6405
6462
  path.setAttributeNS(null, 'd', params.path);
6406
6463
  svg.appendChild(path);
@@ -6571,39 +6628,10 @@
6571
6628
  constructor() {
6572
6629
  super();
6573
6630
  this._element = document.createElement('div');
6574
- this._element.className = 'watermark';
6575
- const title = document.createElement('div');
6576
- title.className = 'watermark-title';
6577
- const emptySpace = document.createElement('span');
6578
- emptySpace.style.flexGrow = '1';
6579
- const content = document.createElement('div');
6580
- content.className = 'watermark-content';
6581
- this._element.appendChild(title);
6582
- this._element.appendChild(content);
6583
- const actionsContainer = document.createElement('div');
6584
- actionsContainer.className = 'actions-container';
6585
- const closeAnchor = document.createElement('div');
6586
- closeAnchor.className = 'close-action';
6587
- closeAnchor.appendChild(createCloseButton());
6588
- actionsContainer.appendChild(closeAnchor);
6589
- title.appendChild(emptySpace);
6590
- title.appendChild(actionsContainer);
6591
- this.addDisposables(addDisposableListener(closeAnchor, 'click', (event) => {
6592
- var _a;
6593
- event.preventDefault();
6594
- if (this._group) {
6595
- (_a = this._api) === null || _a === void 0 ? void 0 : _a.removeGroup(this._group);
6596
- }
6597
- }));
6631
+ this._element.className = 'dv-watermark';
6598
6632
  }
6599
6633
  init(_params) {
6600
- this._api = _params.containerApi;
6601
- this._group = _params.group;
6602
- this.render();
6603
- }
6604
- render() {
6605
- const isOneGroup = !!(this._api && this._api.size <= 1);
6606
- toggleClass(this.element, 'has-actions', isOneGroup);
6634
+ // noop
6607
6635
  }
6608
6636
  }
6609
6637
 
@@ -6640,6 +6668,9 @@
6640
6668
  get element() {
6641
6669
  return this._element;
6642
6670
  }
6671
+ get isVisible() {
6672
+ return this._isVisible;
6673
+ }
6643
6674
  constructor(options) {
6644
6675
  super();
6645
6676
  this.options = options;
@@ -6650,6 +6681,7 @@
6650
6681
  this.onDidChangeEnd = this._onDidChangeEnd.event;
6651
6682
  this.addDisposables(this._onDidChange, this._onDidChangeEnd);
6652
6683
  this._element.className = 'dv-resize-container';
6684
+ this._isVisible = true;
6653
6685
  this.setupResize('top');
6654
6686
  this.setupResize('bottom');
6655
6687
  this.setupResize('left');
@@ -6664,6 +6696,13 @@
6664
6696
  this.setBounds(Object.assign(Object.assign(Object.assign(Object.assign({ height: this.options.height, width: this.options.width }, ('top' in this.options && { top: this.options.top })), ('bottom' in this.options && { bottom: this.options.bottom })), ('left' in this.options && { left: this.options.left })), ('right' in this.options && { right: this.options.right })));
6665
6697
  arialLevelTracker.push(this._element);
6666
6698
  }
6699
+ setVisible(isVisible) {
6700
+ if (isVisible === this.isVisible) {
6701
+ return;
6702
+ }
6703
+ this._isVisible = isVisible;
6704
+ toggleClass(this.element, 'dv-hidden', !this.isVisible);
6705
+ }
6667
6706
  bringToFront() {
6668
6707
  arialLevelTracker.push(this._element);
6669
6708
  }
@@ -7237,7 +7276,6 @@
7237
7276
  window: this._window.value,
7238
7277
  });
7239
7278
  this._window.disposable.dispose();
7240
- this._window.value.close();
7241
7279
  this._window = null;
7242
7280
  this._onDidClose.fire();
7243
7281
  }
@@ -7269,7 +7307,9 @@
7269
7307
  }
7270
7308
  const disposable = new CompositeDisposable();
7271
7309
  this._window = { value: externalWindow, disposable };
7272
- disposable.addDisposables(addDisposableWindowListener(window, 'beforeunload', () => {
7310
+ disposable.addDisposables(exports.DockviewDisposable.from(() => {
7311
+ externalWindow.close();
7312
+ }), addDisposableWindowListener(window, 'beforeunload', () => {
7273
7313
  /**
7274
7314
  * before the main window closes we should close this popup too
7275
7315
  * to be good citizens
@@ -7286,7 +7326,7 @@
7286
7326
  id: this.target,
7287
7327
  window: externalWindow,
7288
7328
  });
7289
- return new Promise((resolve) => {
7329
+ return new Promise((resolve, reject) => {
7290
7330
  externalWindow.addEventListener('unload', (e) => {
7291
7331
  // if page fails to load before unloading
7292
7332
  // this.close();
@@ -7295,21 +7335,27 @@
7295
7335
  /**
7296
7336
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/load_event
7297
7337
  */
7298
- const externalDocument = externalWindow.document;
7299
- externalDocument.title = document.title;
7300
- externalDocument.body.appendChild(container);
7301
- addStyles(externalDocument, window.document.styleSheets);
7302
- /**
7303
- * beforeunload must be registered after load for reasons I could not determine
7304
- * otherwise the beforeunload event will not fire when the window is closed
7305
- */
7306
- addDisposableWindowListener(externalWindow, 'beforeunload', () => {
7338
+ try {
7339
+ const externalDocument = externalWindow.document;
7340
+ externalDocument.title = document.title;
7341
+ externalDocument.body.appendChild(container);
7342
+ addStyles(externalDocument, window.document.styleSheets);
7307
7343
  /**
7308
- * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event
7344
+ * beforeunload must be registered after load for reasons I could not determine
7345
+ * otherwise the beforeunload event will not fire when the window is closed
7309
7346
  */
7310
- this.close();
7311
- });
7312
- resolve(container);
7347
+ addDisposableWindowListener(externalWindow, 'beforeunload', () => {
7348
+ /**
7349
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event
7350
+ */
7351
+ this.close();
7352
+ });
7353
+ resolve(container);
7354
+ }
7355
+ catch (err) {
7356
+ // only except this is the DOM isn't setup. e.g. in a in correctly configured test
7357
+ reject(err);
7358
+ }
7313
7359
  });
7314
7360
  });
7315
7361
  });
@@ -7416,6 +7462,8 @@
7416
7462
  this.onDidActivePanelChange = this._onDidActivePanelChange.event;
7417
7463
  this._onDidMovePanel = new Emitter();
7418
7464
  this.onDidMovePanel = this._onDidMovePanel.event;
7465
+ this._onDidMaximizedGroupChange = new Emitter();
7466
+ this.onDidMaximizedGroupChange = this._onDidMaximizedGroupChange.event;
7419
7467
  this._floatingGroups = [];
7420
7468
  this._popoutGroups = [];
7421
7469
  this._onDidRemoveGroup = new Emitter();
@@ -7442,6 +7490,11 @@
7442
7490
  if (!this._moving) {
7443
7491
  this._onDidActiveGroupChange.fire(event);
7444
7492
  }
7493
+ }), this.onDidMaximizedChange((event) => {
7494
+ this._onDidMaximizedGroupChange.fire({
7495
+ group: event.panel,
7496
+ isMaximized: event.isMaximized,
7497
+ });
7445
7498
  }), exports.DockviewEvent.any(this.onDidAdd, this.onDidRemove)(() => {
7446
7499
  this.updateWatermark();
7447
7500
  }), exports.DockviewEvent.any(this.onDidAddPanel, this.onDidRemovePanel, this.onDidAddGroup, this.onDidRemove, this.onDidMovePanel, this.onDidActivePanelChange)(() => {
@@ -7540,8 +7593,28 @@
7540
7593
  this._api = new DockviewApi(this);
7541
7594
  this.updateWatermark();
7542
7595
  }
7596
+ setVisible(panel, visible) {
7597
+ switch (panel.api.location.type) {
7598
+ case 'grid':
7599
+ super.setVisible(panel, visible);
7600
+ break;
7601
+ case 'floating': {
7602
+ const item = this.floatingGroups.find((floatingGroup) => floatingGroup.group === panel);
7603
+ if (item) {
7604
+ item.overlay.setVisible(visible);
7605
+ panel.api._onDidVisibilityChange.fire({
7606
+ isVisible: visible,
7607
+ });
7608
+ }
7609
+ break;
7610
+ }
7611
+ case 'popout':
7612
+ console.warn('dockview: You cannot hide a group that is in a popout window');
7613
+ break;
7614
+ }
7615
+ }
7543
7616
  addPopoutGroup(itemToPopout, options) {
7544
- var _a, _b, _c;
7617
+ var _a, _b, _c, _d, _e;
7545
7618
  if (itemToPopout instanceof DockviewPanel &&
7546
7619
  itemToPopout.group.size === 1) {
7547
7620
  return this.addPopoutGroup(itemToPopout.group, options);
@@ -7562,12 +7635,9 @@
7562
7635
  }
7563
7636
  const box = getBox();
7564
7637
  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();
7565
- if (itemToPopout.api.location.type === 'grid') {
7566
- itemToPopout.api.setVisible(false);
7567
- }
7568
7638
  const _window = new PopoutWindow(`${this.id}-${groupId}`, // unique id
7569
7639
  theme !== null && theme !== void 0 ? theme : '', {
7570
- url: (_c = options === null || options === void 0 ? void 0 : options.popoutUrl) !== null && _c !== void 0 ? _c : '/popout.html',
7640
+ url: (_e = (_c = options === null || options === void 0 ? void 0 : options.popoutUrl) !== null && _c !== void 0 ? _c : (_d = this.options) === null || _d === void 0 ? void 0 : _d.popoutUrl) !== null && _e !== void 0 ? _e : '/popout.html',
7571
7641
  left: window.screenX + box.left,
7572
7642
  top: window.screenY + box.top,
7573
7643
  width: box.width,
@@ -7581,13 +7651,12 @@
7581
7651
  return _window
7582
7652
  .open()
7583
7653
  .then((popoutContainer) => {
7584
- var _a;
7585
7654
  if (_window.isDisposed) {
7586
- return;
7655
+ return false;
7587
7656
  }
7588
7657
  if (popoutContainer === null) {
7589
7658
  popoutWindowDisposable.dispose();
7590
- return;
7659
+ return false;
7591
7660
  }
7592
7661
  const gready = document.createElement('div');
7593
7662
  gready.className = 'dv-overlay-render-container';
@@ -7596,30 +7665,45 @@
7596
7665
  ? itemToPopout.group
7597
7666
  : itemToPopout;
7598
7667
  const referenceLocation = itemToPopout.api.location.type;
7599
- const group = (_a = options === null || options === void 0 ? void 0 : options.overridePopoutGroup) !== null && _a !== void 0 ? _a : this.createGroup({ id: groupId });
7600
- group.model.renderContainer = overlayRenderContainer;
7601
- if (!(options === null || options === void 0 ? void 0 : options.overridePopoutGroup)) {
7602
- this._onDidAddGroup.fire(group);
7668
+ /**
7669
+ * The group that is being added doesn't already exist within the DOM, the most likely occurance
7670
+ * of this case is when being called from the `fromJSON(...)` method
7671
+ */
7672
+ const isGroupAddedToDom = referenceGroup.element.parentElement !== null;
7673
+ let group;
7674
+ if (!isGroupAddedToDom) {
7675
+ group = referenceGroup;
7603
7676
  }
7604
- if (itemToPopout instanceof DockviewPanel) {
7605
- this.movingLock(() => {
7606
- const panel = referenceGroup.model.removePanel(itemToPopout);
7607
- group.model.openPanel(panel);
7608
- });
7677
+ else if (options === null || options === void 0 ? void 0 : options.overridePopoutGroup) {
7678
+ group = options.overridePopoutGroup;
7609
7679
  }
7610
7680
  else {
7611
- this.movingLock(() => moveGroupWithoutDestroying({
7612
- from: referenceGroup,
7613
- to: group,
7614
- }));
7615
- switch (referenceLocation) {
7616
- case 'grid':
7617
- referenceGroup.api.setVisible(false);
7618
- break;
7619
- case 'floating':
7620
- case 'popout':
7621
- this.removeGroup(referenceGroup);
7622
- break;
7681
+ group = this.createGroup({ id: groupId });
7682
+ this._onDidAddGroup.fire(group);
7683
+ }
7684
+ group.model.renderContainer = overlayRenderContainer;
7685
+ group.layout(_window.window.innerWidth, _window.window.innerHeight);
7686
+ if (!(options === null || options === void 0 ? void 0 : options.overridePopoutGroup) && isGroupAddedToDom) {
7687
+ if (itemToPopout instanceof DockviewPanel) {
7688
+ this.movingLock(() => {
7689
+ const panel = referenceGroup.model.removePanel(itemToPopout);
7690
+ group.model.openPanel(panel);
7691
+ });
7692
+ }
7693
+ else {
7694
+ this.movingLock(() => moveGroupWithoutDestroying({
7695
+ from: referenceGroup,
7696
+ to: group,
7697
+ }));
7698
+ switch (referenceLocation) {
7699
+ case 'grid':
7700
+ referenceGroup.api.setVisible(false);
7701
+ break;
7702
+ case 'floating':
7703
+ case 'popout':
7704
+ this.removeGroup(referenceGroup);
7705
+ break;
7706
+ }
7623
7707
  }
7624
7708
  }
7625
7709
  popoutContainer.classList.add('dv-dockview');
@@ -7629,7 +7713,12 @@
7629
7713
  group.model.location = {
7630
7714
  type: 'popout',
7631
7715
  getWindow: () => _window.window,
7716
+ popoutUrl: options === null || options === void 0 ? void 0 : options.popoutUrl,
7632
7717
  };
7718
+ if (isGroupAddedToDom &&
7719
+ itemToPopout.api.location.type === 'grid') {
7720
+ itemToPopout.api.setVisible(false);
7721
+ }
7633
7722
  this.doSetGroupAndPanelActive(group);
7634
7723
  popoutWindowDisposable.addDisposables(group.api.onDidActiveChange((event) => {
7635
7724
  var _a;
@@ -7641,10 +7730,13 @@
7641
7730
  (_a = _window.window) === null || _a === void 0 ? void 0 : _a.focus();
7642
7731
  }));
7643
7732
  let returnedGroup;
7733
+ const isValidReferenceGroup = isGroupAddedToDom &&
7734
+ referenceGroup &&
7735
+ this.getPanel(referenceGroup.id);
7644
7736
  const value = {
7645
7737
  window: _window,
7646
7738
  popoutGroup: group,
7647
- referenceGroup: this.getPanel(referenceGroup.id)
7739
+ referenceGroup: isValidReferenceGroup
7648
7740
  ? referenceGroup.id
7649
7741
  : undefined,
7650
7742
  disposable: {
@@ -7661,9 +7753,10 @@
7661
7753
  * window dimensions
7662
7754
  */
7663
7755
  addDisposableWindowListener(_window.window, 'resize', () => {
7664
- group.layout(window.innerWidth, window.innerHeight);
7756
+ group.layout(_window.window.innerWidth, _window.window.innerHeight);
7665
7757
  }), overlayRenderContainer, exports.DockviewDisposable.from(() => {
7666
- if (this.getPanel(referenceGroup.id)) {
7758
+ if (isGroupAddedToDom &&
7759
+ this.getPanel(referenceGroup.id)) {
7667
7760
  this.movingLock(() => moveGroupWithoutDestroying({
7668
7761
  from: group,
7669
7762
  to: referenceGroup,
@@ -7678,21 +7771,27 @@
7678
7771
  }
7679
7772
  }
7680
7773
  else if (this.getPanel(group.id)) {
7681
- const removedGroup = this.doRemoveGroup(group, {
7774
+ this.doRemoveGroup(group, {
7682
7775
  skipDispose: true,
7683
7776
  skipActive: true,
7777
+ skipPopoutReturn: true,
7684
7778
  });
7779
+ const removedGroup = group;
7685
7780
  removedGroup.model.renderContainer =
7686
7781
  this.overlayRenderContainer;
7687
7782
  removedGroup.model.location = { type: 'grid' };
7688
7783
  returnedGroup = removedGroup;
7784
+ this.doAddGroup(removedGroup, [0]);
7785
+ this.doSetGroupAndPanelActive(removedGroup);
7689
7786
  }
7690
7787
  }));
7691
7788
  this._popoutGroups.push(value);
7692
7789
  this.updateWatermark();
7790
+ return true;
7693
7791
  })
7694
7792
  .catch((err) => {
7695
7793
  console.error('dockview: failed to create popout window', err);
7794
+ return false;
7696
7795
  });
7697
7796
  }
7698
7797
  addFloatingGroup(item, options) {
@@ -7796,7 +7895,7 @@
7796
7895
  : (_c = (_b = this.options.floatingGroupBounds) === null || _b === void 0 ? void 0 : _b.minimumWidthWithinViewport) !== null && _c !== void 0 ? _c : DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE, minimumInViewportHeight: this.options.floatingGroupBounds === 'boundedWithinViewport'
7797
7896
  ? undefined
7798
7897
  : (_e = (_d = this.options.floatingGroupBounds) === null || _d === void 0 ? void 0 : _d.minimumHeightWithinViewport) !== null && _e !== void 0 ? _e : DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE }));
7799
- const el = group.element.querySelector('.void-container');
7898
+ const el = group.element.querySelector('.dv-void-container');
7800
7899
  if (!el) {
7801
7900
  throw new Error('failed to find drag handle');
7802
7901
  }
@@ -7988,6 +8087,9 @@
7988
8087
  data: group.popoutGroup.toJSON(),
7989
8088
  gridReferenceGroup: group.referenceGroup,
7990
8089
  position: group.window.dimensions(),
8090
+ url: group.popoutGroup.api.location.type === 'popout'
8091
+ ? group.popoutGroup.api.location.popoutUrl
8092
+ : undefined,
7991
8093
  };
7992
8094
  });
7993
8095
  const result = {
@@ -8074,16 +8176,16 @@
8074
8176
  }
8075
8177
  const serializedPopoutGroups = (_b = data.popoutGroups) !== null && _b !== void 0 ? _b : [];
8076
8178
  for (const serializedPopoutGroup of serializedPopoutGroups) {
8077
- const { data, position, gridReferenceGroup } = serializedPopoutGroup;
8179
+ const { data, position, gridReferenceGroup, url } = serializedPopoutGroup;
8078
8180
  const group = createGroupFromSerializedState(data);
8079
8181
  this.addPopoutGroup((_c = (gridReferenceGroup
8080
8182
  ? this.getPanel(gridReferenceGroup)
8081
8183
  : undefined)) !== null && _c !== void 0 ? _c : group, {
8082
- skipRemoveGroup: true,
8083
8184
  position: position !== null && position !== void 0 ? position : undefined,
8084
8185
  overridePopoutGroup: gridReferenceGroup
8085
8186
  ? group
8086
8187
  : undefined,
8188
+ popoutUrl: url,
8087
8189
  });
8088
8190
  }
8089
8191
  for (const floatingGroup of this._floatingGroups) {
@@ -8097,6 +8199,7 @@
8097
8199
  }
8098
8200
  }
8099
8201
  catch (err) {
8202
+ console.error('dockview: failed to deserialize layout. Reverting changes', err);
8100
8203
  /**
8101
8204
  * Takes all the successfully created groups and remove all of their panels.
8102
8205
  */
@@ -8164,11 +8267,13 @@
8164
8267
  width: options.initialWidth,
8165
8268
  height: options.initialHeight,
8166
8269
  };
8270
+ let index;
8167
8271
  if (options.position) {
8168
8272
  if (isPanelOptionsWithPanel(options.position)) {
8169
8273
  const referencePanel = typeof options.position.referencePanel === 'string'
8170
8274
  ? this.getGroupPanel(options.position.referencePanel)
8171
8275
  : options.position.referencePanel;
8276
+ index = options.position.index;
8172
8277
  if (!referencePanel) {
8173
8278
  throw new Error(`referencePanel '${options.position.referencePanel}' does not exist`);
8174
8279
  }
@@ -8179,6 +8284,7 @@
8179
8284
  typeof options.position.referenceGroup === 'string'
8180
8285
  ? (_a = this._groups.get(options.position.referenceGroup)) === null || _a === void 0 ? void 0 : _a.value
8181
8286
  : options.position.referenceGroup;
8287
+ index = options.position.index;
8182
8288
  if (!referenceGroup) {
8183
8289
  throw new Error(`referenceGroup '${options.position.referenceGroup}' does not exist`);
8184
8290
  }
@@ -8189,6 +8295,7 @@
8189
8295
  group.model.openPanel(panel, {
8190
8296
  skipSetActive: options.inactive,
8191
8297
  skipSetGroupActive: options.inactive,
8298
+ index,
8192
8299
  });
8193
8300
  if (!options.inactive) {
8194
8301
  this.doSetGroupAndPanelActive(group);
@@ -8218,6 +8325,7 @@
8218
8325
  group.model.openPanel(panel, {
8219
8326
  skipSetActive: options.inactive,
8220
8327
  skipSetGroupActive: options.inactive,
8328
+ index,
8221
8329
  });
8222
8330
  }
8223
8331
  else if (referenceGroup.api.location.type === 'floating' ||
@@ -8226,6 +8334,7 @@
8226
8334
  referenceGroup.model.openPanel(panel, {
8227
8335
  skipSetActive: options.inactive,
8228
8336
  skipSetGroupActive: options.inactive,
8337
+ index,
8229
8338
  });
8230
8339
  referenceGroup.api.setSize({
8231
8340
  width: initial === null || initial === void 0 ? void 0 : initial.width,
@@ -8246,6 +8355,7 @@
8246
8355
  group.model.openPanel(panel, {
8247
8356
  skipSetActive: options.inactive,
8248
8357
  skipSetGroupActive: options.inactive,
8358
+ index,
8249
8359
  });
8250
8360
  if (!options.inactive) {
8251
8361
  this.doSetGroupAndPanelActive(group);
@@ -8264,6 +8374,7 @@
8264
8374
  group.model.openPanel(panel, {
8265
8375
  skipSetActive: options.inactive,
8266
8376
  skipSetGroupActive: options.inactive,
8377
+ index,
8267
8378
  });
8268
8379
  }
8269
8380
  else {
@@ -8274,6 +8385,7 @@
8274
8385
  group.model.openPanel(panel, {
8275
8386
  skipSetActive: options.inactive,
8276
8387
  skipSetGroupActive: options.inactive,
8388
+ index,
8277
8389
  });
8278
8390
  if (!options.inactive) {
8279
8391
  this.doSetGroupAndPanelActive(group);
@@ -8283,7 +8395,6 @@
8283
8395
  }
8284
8396
  removePanel(panel, options = {
8285
8397
  removeEmptyGroup: true,
8286
- skipDispose: false,
8287
8398
  }) {
8288
8399
  const group = panel.group;
8289
8400
  if (!group) {
@@ -8814,6 +8925,31 @@
8814
8925
  }
8815
8926
  }
8816
8927
 
8928
+ function createComponent(id, componentName, components = {}, frameworkComponents = {}, createFrameworkComponent, fallback) {
8929
+ const Component = typeof componentName === 'string'
8930
+ ? components[componentName]
8931
+ : undefined;
8932
+ const FrameworkComponent = typeof componentName === 'string'
8933
+ ? frameworkComponents[componentName]
8934
+ : undefined;
8935
+ if (Component && FrameworkComponent) {
8936
+ throw new Error(`Cannot create '${id}'. component '${componentName}' registered as both a component and frameworkComponent`);
8937
+ }
8938
+ if (FrameworkComponent) {
8939
+ if (!createFrameworkComponent) {
8940
+ throw new Error(`Cannot create '${id}' for framework component '${componentName}'. you must register a frameworkPanelWrapper to use framework components`);
8941
+ }
8942
+ return createFrameworkComponent.createComponent(id, componentName, FrameworkComponent);
8943
+ }
8944
+ if (!Component) {
8945
+ if (fallback) {
8946
+ return fallback();
8947
+ }
8948
+ throw new Error(`Cannot create '${id}', no component '${componentName}' provided`);
8949
+ }
8950
+ return new Component(id, componentName);
8951
+ }
8952
+
8817
8953
  class GridviewComponent extends BaseGrid {
8818
8954
  get orientation() {
8819
8955
  return this.gridview.orientation;
@@ -9362,12 +9498,14 @@
9362
9498
  this._expandedIcon = createExpandMoreButton();
9363
9499
  this._collapsedIcon = createChevronRightButton();
9364
9500
  this.disposable = new MutableDisposable();
9365
- this.apiRef = { api: null };
9501
+ this.apiRef = {
9502
+ api: null,
9503
+ };
9366
9504
  this._element = document.createElement('div');
9367
- this.element.className = 'default-header';
9505
+ this.element.className = 'dv-default-header';
9368
9506
  this._content = document.createElement('span');
9369
9507
  this._expander = document.createElement('div');
9370
- this._expander.className = 'dockview-pane-header-icon';
9508
+ this._expander.className = 'dv-pane-header-icon';
9371
9509
  this.element.appendChild(this._expander);
9372
9510
  this.element.appendChild(this._content);
9373
9511
  this.addDisposables(addDisposableListener(this._element, 'click', () => {
@@ -9838,7 +9976,6 @@
9838
9976
  exports.GridviewApi = GridviewApi;
9839
9977
  exports.GridviewComponent = GridviewComponent;
9840
9978
  exports.GridviewPanel = GridviewPanel;
9841
- exports.LocalSelectionTransfer = LocalSelectionTransfer;
9842
9979
  exports.PROPERTY_KEYS = PROPERTY_KEYS;
9843
9980
  exports.PaneFramework = PaneFramework;
9844
9981
  exports.PaneTransfer = PaneTransfer;
@@ -9853,7 +9990,6 @@
9853
9990
  exports.SplitviewPanel = SplitviewPanel;
9854
9991
  exports.Tab = Tab;
9855
9992
  exports.WillShowOverlayLocationEvent = WillShowOverlayLocationEvent;
9856
- exports.createComponent = createComponent;
9857
9993
  exports.createDockview = createDockview;
9858
9994
  exports.createGridview = createGridview;
9859
9995
  exports.createPaneview = createPaneview;