dockview-react 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.
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * dockview-react
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
  }
@@ -7214,7 +7253,6 @@
7214
7253
  window: this._window.value,
7215
7254
  });
7216
7255
  this._window.disposable.dispose();
7217
- this._window.value.close();
7218
7256
  this._window = null;
7219
7257
  this._onDidClose.fire();
7220
7258
  }
@@ -7246,7 +7284,9 @@
7246
7284
  }
7247
7285
  const disposable = new CompositeDisposable();
7248
7286
  this._window = { value: externalWindow, disposable };
7249
- disposable.addDisposables(addDisposableWindowListener(window, 'beforeunload', () => {
7287
+ disposable.addDisposables(exports.DockviewDisposable.from(() => {
7288
+ externalWindow.close();
7289
+ }), addDisposableWindowListener(window, 'beforeunload', () => {
7250
7290
  /**
7251
7291
  * before the main window closes we should close this popup too
7252
7292
  * to be good citizens
@@ -7263,7 +7303,7 @@
7263
7303
  id: this.target,
7264
7304
  window: externalWindow,
7265
7305
  });
7266
- return new Promise((resolve) => {
7306
+ return new Promise((resolve, reject) => {
7267
7307
  externalWindow.addEventListener('unload', (e) => {
7268
7308
  // if page fails to load before unloading
7269
7309
  // this.close();
@@ -7272,21 +7312,27 @@
7272
7312
  /**
7273
7313
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/load_event
7274
7314
  */
7275
- const externalDocument = externalWindow.document;
7276
- externalDocument.title = document.title;
7277
- externalDocument.body.appendChild(container);
7278
- addStyles(externalDocument, window.document.styleSheets);
7279
- /**
7280
- * beforeunload must be registered after load for reasons I could not determine
7281
- * otherwise the beforeunload event will not fire when the window is closed
7282
- */
7283
- addDisposableWindowListener(externalWindow, 'beforeunload', () => {
7315
+ try {
7316
+ const externalDocument = externalWindow.document;
7317
+ externalDocument.title = document.title;
7318
+ externalDocument.body.appendChild(container);
7319
+ addStyles(externalDocument, window.document.styleSheets);
7284
7320
  /**
7285
- * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event
7321
+ * beforeunload must be registered after load for reasons I could not determine
7322
+ * otherwise the beforeunload event will not fire when the window is closed
7286
7323
  */
7287
- this.close();
7288
- });
7289
- resolve(container);
7324
+ addDisposableWindowListener(externalWindow, 'beforeunload', () => {
7325
+ /**
7326
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event
7327
+ */
7328
+ this.close();
7329
+ });
7330
+ resolve(container);
7331
+ }
7332
+ catch (err) {
7333
+ // only except this is the DOM isn't setup. e.g. in a in correctly configured test
7334
+ reject(err);
7335
+ }
7290
7336
  });
7291
7337
  });
7292
7338
  });
@@ -7393,6 +7439,8 @@
7393
7439
  this.onDidActivePanelChange = this._onDidActivePanelChange.event;
7394
7440
  this._onDidMovePanel = new Emitter();
7395
7441
  this.onDidMovePanel = this._onDidMovePanel.event;
7442
+ this._onDidMaximizedGroupChange = new Emitter();
7443
+ this.onDidMaximizedGroupChange = this._onDidMaximizedGroupChange.event;
7396
7444
  this._floatingGroups = [];
7397
7445
  this._popoutGroups = [];
7398
7446
  this._onDidRemoveGroup = new Emitter();
@@ -7419,6 +7467,11 @@
7419
7467
  if (!this._moving) {
7420
7468
  this._onDidActiveGroupChange.fire(event);
7421
7469
  }
7470
+ }), this.onDidMaximizedChange((event) => {
7471
+ this._onDidMaximizedGroupChange.fire({
7472
+ group: event.panel,
7473
+ isMaximized: event.isMaximized,
7474
+ });
7422
7475
  }), exports.DockviewEvent.any(this.onDidAdd, this.onDidRemove)(() => {
7423
7476
  this.updateWatermark();
7424
7477
  }), exports.DockviewEvent.any(this.onDidAddPanel, this.onDidRemovePanel, this.onDidAddGroup, this.onDidRemove, this.onDidMovePanel, this.onDidActivePanelChange)(() => {
@@ -7517,8 +7570,28 @@
7517
7570
  this._api = new DockviewApi(this);
7518
7571
  this.updateWatermark();
7519
7572
  }
7573
+ setVisible(panel, visible) {
7574
+ switch (panel.api.location.type) {
7575
+ case 'grid':
7576
+ super.setVisible(panel, visible);
7577
+ break;
7578
+ case 'floating': {
7579
+ const item = this.floatingGroups.find((floatingGroup) => floatingGroup.group === panel);
7580
+ if (item) {
7581
+ item.overlay.setVisible(visible);
7582
+ panel.api._onDidVisibilityChange.fire({
7583
+ isVisible: visible,
7584
+ });
7585
+ }
7586
+ break;
7587
+ }
7588
+ case 'popout':
7589
+ console.warn('dockview: You cannot hide a group that is in a popout window');
7590
+ break;
7591
+ }
7592
+ }
7520
7593
  addPopoutGroup(itemToPopout, options) {
7521
- var _a, _b, _c;
7594
+ var _a, _b, _c, _d, _e;
7522
7595
  if (itemToPopout instanceof DockviewPanel &&
7523
7596
  itemToPopout.group.size === 1) {
7524
7597
  return this.addPopoutGroup(itemToPopout.group, options);
@@ -7539,12 +7612,9 @@
7539
7612
  }
7540
7613
  const box = getBox();
7541
7614
  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();
7542
- if (itemToPopout.api.location.type === 'grid') {
7543
- itemToPopout.api.setVisible(false);
7544
- }
7545
7615
  const _window = new PopoutWindow(`${this.id}-${groupId}`, // unique id
7546
7616
  theme !== null && theme !== void 0 ? theme : '', {
7547
- url: (_c = options === null || options === void 0 ? void 0 : options.popoutUrl) !== null && _c !== void 0 ? _c : '/popout.html',
7617
+ 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',
7548
7618
  left: window.screenX + box.left,
7549
7619
  top: window.screenY + box.top,
7550
7620
  width: box.width,
@@ -7558,13 +7628,12 @@
7558
7628
  return _window
7559
7629
  .open()
7560
7630
  .then((popoutContainer) => {
7561
- var _a;
7562
7631
  if (_window.isDisposed) {
7563
- return;
7632
+ return false;
7564
7633
  }
7565
7634
  if (popoutContainer === null) {
7566
7635
  popoutWindowDisposable.dispose();
7567
- return;
7636
+ return false;
7568
7637
  }
7569
7638
  const gready = document.createElement('div');
7570
7639
  gready.className = 'dv-overlay-render-container';
@@ -7573,30 +7642,45 @@
7573
7642
  ? itemToPopout.group
7574
7643
  : itemToPopout;
7575
7644
  const referenceLocation = itemToPopout.api.location.type;
7576
- const group = (_a = options === null || options === void 0 ? void 0 : options.overridePopoutGroup) !== null && _a !== void 0 ? _a : this.createGroup({ id: groupId });
7577
- group.model.renderContainer = overlayRenderContainer;
7578
- if (!(options === null || options === void 0 ? void 0 : options.overridePopoutGroup)) {
7579
- this._onDidAddGroup.fire(group);
7645
+ /**
7646
+ * The group that is being added doesn't already exist within the DOM, the most likely occurance
7647
+ * of this case is when being called from the `fromJSON(...)` method
7648
+ */
7649
+ const isGroupAddedToDom = referenceGroup.element.parentElement !== null;
7650
+ let group;
7651
+ if (!isGroupAddedToDom) {
7652
+ group = referenceGroup;
7580
7653
  }
7581
- if (itemToPopout instanceof DockviewPanel) {
7582
- this.movingLock(() => {
7583
- const panel = referenceGroup.model.removePanel(itemToPopout);
7584
- group.model.openPanel(panel);
7585
- });
7654
+ else if (options === null || options === void 0 ? void 0 : options.overridePopoutGroup) {
7655
+ group = options.overridePopoutGroup;
7586
7656
  }
7587
7657
  else {
7588
- this.movingLock(() => moveGroupWithoutDestroying({
7589
- from: referenceGroup,
7590
- to: group,
7591
- }));
7592
- switch (referenceLocation) {
7593
- case 'grid':
7594
- referenceGroup.api.setVisible(false);
7595
- break;
7596
- case 'floating':
7597
- case 'popout':
7598
- this.removeGroup(referenceGroup);
7599
- break;
7658
+ group = this.createGroup({ id: groupId });
7659
+ this._onDidAddGroup.fire(group);
7660
+ }
7661
+ group.model.renderContainer = overlayRenderContainer;
7662
+ group.layout(_window.window.innerWidth, _window.window.innerHeight);
7663
+ if (!(options === null || options === void 0 ? void 0 : options.overridePopoutGroup) && isGroupAddedToDom) {
7664
+ if (itemToPopout instanceof DockviewPanel) {
7665
+ this.movingLock(() => {
7666
+ const panel = referenceGroup.model.removePanel(itemToPopout);
7667
+ group.model.openPanel(panel);
7668
+ });
7669
+ }
7670
+ else {
7671
+ this.movingLock(() => moveGroupWithoutDestroying({
7672
+ from: referenceGroup,
7673
+ to: group,
7674
+ }));
7675
+ switch (referenceLocation) {
7676
+ case 'grid':
7677
+ referenceGroup.api.setVisible(false);
7678
+ break;
7679
+ case 'floating':
7680
+ case 'popout':
7681
+ this.removeGroup(referenceGroup);
7682
+ break;
7683
+ }
7600
7684
  }
7601
7685
  }
7602
7686
  popoutContainer.classList.add('dv-dockview');
@@ -7606,7 +7690,12 @@
7606
7690
  group.model.location = {
7607
7691
  type: 'popout',
7608
7692
  getWindow: () => _window.window,
7693
+ popoutUrl: options === null || options === void 0 ? void 0 : options.popoutUrl,
7609
7694
  };
7695
+ if (isGroupAddedToDom &&
7696
+ itemToPopout.api.location.type === 'grid') {
7697
+ itemToPopout.api.setVisible(false);
7698
+ }
7610
7699
  this.doSetGroupAndPanelActive(group);
7611
7700
  popoutWindowDisposable.addDisposables(group.api.onDidActiveChange((event) => {
7612
7701
  var _a;
@@ -7618,10 +7707,13 @@
7618
7707
  (_a = _window.window) === null || _a === void 0 ? void 0 : _a.focus();
7619
7708
  }));
7620
7709
  let returnedGroup;
7710
+ const isValidReferenceGroup = isGroupAddedToDom &&
7711
+ referenceGroup &&
7712
+ this.getPanel(referenceGroup.id);
7621
7713
  const value = {
7622
7714
  window: _window,
7623
7715
  popoutGroup: group,
7624
- referenceGroup: this.getPanel(referenceGroup.id)
7716
+ referenceGroup: isValidReferenceGroup
7625
7717
  ? referenceGroup.id
7626
7718
  : undefined,
7627
7719
  disposable: {
@@ -7638,9 +7730,10 @@
7638
7730
  * window dimensions
7639
7731
  */
7640
7732
  addDisposableWindowListener(_window.window, 'resize', () => {
7641
- group.layout(window.innerWidth, window.innerHeight);
7733
+ group.layout(_window.window.innerWidth, _window.window.innerHeight);
7642
7734
  }), overlayRenderContainer, exports.DockviewDisposable.from(() => {
7643
- if (this.getPanel(referenceGroup.id)) {
7735
+ if (isGroupAddedToDom &&
7736
+ this.getPanel(referenceGroup.id)) {
7644
7737
  this.movingLock(() => moveGroupWithoutDestroying({
7645
7738
  from: group,
7646
7739
  to: referenceGroup,
@@ -7655,21 +7748,27 @@
7655
7748
  }
7656
7749
  }
7657
7750
  else if (this.getPanel(group.id)) {
7658
- const removedGroup = this.doRemoveGroup(group, {
7751
+ this.doRemoveGroup(group, {
7659
7752
  skipDispose: true,
7660
7753
  skipActive: true,
7754
+ skipPopoutReturn: true,
7661
7755
  });
7756
+ const removedGroup = group;
7662
7757
  removedGroup.model.renderContainer =
7663
7758
  this.overlayRenderContainer;
7664
7759
  removedGroup.model.location = { type: 'grid' };
7665
7760
  returnedGroup = removedGroup;
7761
+ this.doAddGroup(removedGroup, [0]);
7762
+ this.doSetGroupAndPanelActive(removedGroup);
7666
7763
  }
7667
7764
  }));
7668
7765
  this._popoutGroups.push(value);
7669
7766
  this.updateWatermark();
7767
+ return true;
7670
7768
  })
7671
7769
  .catch((err) => {
7672
7770
  console.error('dockview: failed to create popout window', err);
7771
+ return false;
7673
7772
  });
7674
7773
  }
7675
7774
  addFloatingGroup(item, options) {
@@ -7773,7 +7872,7 @@
7773
7872
  : (_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'
7774
7873
  ? undefined
7775
7874
  : (_e = (_d = this.options.floatingGroupBounds) === null || _d === void 0 ? void 0 : _d.minimumHeightWithinViewport) !== null && _e !== void 0 ? _e : DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE }));
7776
- const el = group.element.querySelector('.void-container');
7875
+ const el = group.element.querySelector('.dv-void-container');
7777
7876
  if (!el) {
7778
7877
  throw new Error('failed to find drag handle');
7779
7878
  }
@@ -7965,6 +8064,9 @@
7965
8064
  data: group.popoutGroup.toJSON(),
7966
8065
  gridReferenceGroup: group.referenceGroup,
7967
8066
  position: group.window.dimensions(),
8067
+ url: group.popoutGroup.api.location.type === 'popout'
8068
+ ? group.popoutGroup.api.location.popoutUrl
8069
+ : undefined,
7968
8070
  };
7969
8071
  });
7970
8072
  const result = {
@@ -8051,16 +8153,16 @@
8051
8153
  }
8052
8154
  const serializedPopoutGroups = (_b = data.popoutGroups) !== null && _b !== void 0 ? _b : [];
8053
8155
  for (const serializedPopoutGroup of serializedPopoutGroups) {
8054
- const { data, position, gridReferenceGroup } = serializedPopoutGroup;
8156
+ const { data, position, gridReferenceGroup, url } = serializedPopoutGroup;
8055
8157
  const group = createGroupFromSerializedState(data);
8056
8158
  this.addPopoutGroup((_c = (gridReferenceGroup
8057
8159
  ? this.getPanel(gridReferenceGroup)
8058
8160
  : undefined)) !== null && _c !== void 0 ? _c : group, {
8059
- skipRemoveGroup: true,
8060
8161
  position: position !== null && position !== void 0 ? position : undefined,
8061
8162
  overridePopoutGroup: gridReferenceGroup
8062
8163
  ? group
8063
8164
  : undefined,
8165
+ popoutUrl: url,
8064
8166
  });
8065
8167
  }
8066
8168
  for (const floatingGroup of this._floatingGroups) {
@@ -8074,6 +8176,7 @@
8074
8176
  }
8075
8177
  }
8076
8178
  catch (err) {
8179
+ console.error('dockview: failed to deserialize layout. Reverting changes', err);
8077
8180
  /**
8078
8181
  * Takes all the successfully created groups and remove all of their panels.
8079
8182
  */
@@ -8141,11 +8244,13 @@
8141
8244
  width: options.initialWidth,
8142
8245
  height: options.initialHeight,
8143
8246
  };
8247
+ let index;
8144
8248
  if (options.position) {
8145
8249
  if (isPanelOptionsWithPanel(options.position)) {
8146
8250
  const referencePanel = typeof options.position.referencePanel === 'string'
8147
8251
  ? this.getGroupPanel(options.position.referencePanel)
8148
8252
  : options.position.referencePanel;
8253
+ index = options.position.index;
8149
8254
  if (!referencePanel) {
8150
8255
  throw new Error(`referencePanel '${options.position.referencePanel}' does not exist`);
8151
8256
  }
@@ -8156,6 +8261,7 @@
8156
8261
  typeof options.position.referenceGroup === 'string'
8157
8262
  ? (_a = this._groups.get(options.position.referenceGroup)) === null || _a === void 0 ? void 0 : _a.value
8158
8263
  : options.position.referenceGroup;
8264
+ index = options.position.index;
8159
8265
  if (!referenceGroup) {
8160
8266
  throw new Error(`referenceGroup '${options.position.referenceGroup}' does not exist`);
8161
8267
  }
@@ -8166,6 +8272,7 @@
8166
8272
  group.model.openPanel(panel, {
8167
8273
  skipSetActive: options.inactive,
8168
8274
  skipSetGroupActive: options.inactive,
8275
+ index,
8169
8276
  });
8170
8277
  if (!options.inactive) {
8171
8278
  this.doSetGroupAndPanelActive(group);
@@ -8195,6 +8302,7 @@
8195
8302
  group.model.openPanel(panel, {
8196
8303
  skipSetActive: options.inactive,
8197
8304
  skipSetGroupActive: options.inactive,
8305
+ index,
8198
8306
  });
8199
8307
  }
8200
8308
  else if (referenceGroup.api.location.type === 'floating' ||
@@ -8203,6 +8311,7 @@
8203
8311
  referenceGroup.model.openPanel(panel, {
8204
8312
  skipSetActive: options.inactive,
8205
8313
  skipSetGroupActive: options.inactive,
8314
+ index,
8206
8315
  });
8207
8316
  referenceGroup.api.setSize({
8208
8317
  width: initial === null || initial === void 0 ? void 0 : initial.width,
@@ -8223,6 +8332,7 @@
8223
8332
  group.model.openPanel(panel, {
8224
8333
  skipSetActive: options.inactive,
8225
8334
  skipSetGroupActive: options.inactive,
8335
+ index,
8226
8336
  });
8227
8337
  if (!options.inactive) {
8228
8338
  this.doSetGroupAndPanelActive(group);
@@ -8241,6 +8351,7 @@
8241
8351
  group.model.openPanel(panel, {
8242
8352
  skipSetActive: options.inactive,
8243
8353
  skipSetGroupActive: options.inactive,
8354
+ index,
8244
8355
  });
8245
8356
  }
8246
8357
  else {
@@ -8251,6 +8362,7 @@
8251
8362
  group.model.openPanel(panel, {
8252
8363
  skipSetActive: options.inactive,
8253
8364
  skipSetGroupActive: options.inactive,
8365
+ index,
8254
8366
  });
8255
8367
  if (!options.inactive) {
8256
8368
  this.doSetGroupAndPanelActive(group);
@@ -8260,7 +8372,6 @@
8260
8372
  }
8261
8373
  removePanel(panel, options = {
8262
8374
  removeEmptyGroup: true,
8263
- skipDispose: false,
8264
8375
  }) {
8265
8376
  const group = panel.group;
8266
8377
  if (!group) {
@@ -8791,6 +8902,31 @@
8791
8902
  }
8792
8903
  }
8793
8904
 
8905
+ function createComponent(id, componentName, components = {}, frameworkComponents = {}, createFrameworkComponent, fallback) {
8906
+ const Component = typeof componentName === 'string'
8907
+ ? components[componentName]
8908
+ : undefined;
8909
+ const FrameworkComponent = typeof componentName === 'string'
8910
+ ? frameworkComponents[componentName]
8911
+ : undefined;
8912
+ if (Component && FrameworkComponent) {
8913
+ throw new Error(`Cannot create '${id}'. component '${componentName}' registered as both a component and frameworkComponent`);
8914
+ }
8915
+ if (FrameworkComponent) {
8916
+ if (!createFrameworkComponent) {
8917
+ throw new Error(`Cannot create '${id}' for framework component '${componentName}'. you must register a frameworkPanelWrapper to use framework components`);
8918
+ }
8919
+ return createFrameworkComponent.createComponent(id, componentName, FrameworkComponent);
8920
+ }
8921
+ if (!Component) {
8922
+ if (fallback) {
8923
+ return fallback();
8924
+ }
8925
+ throw new Error(`Cannot create '${id}', no component '${componentName}' provided`);
8926
+ }
8927
+ return new Component(id, componentName);
8928
+ }
8929
+
8794
8930
  class GridviewComponent extends BaseGrid {
8795
8931
  get orientation() {
8796
8932
  return this.gridview.orientation;
@@ -9339,12 +9475,14 @@
9339
9475
  this._expandedIcon = createExpandMoreButton();
9340
9476
  this._collapsedIcon = createChevronRightButton();
9341
9477
  this.disposable = new MutableDisposable();
9342
- this.apiRef = { api: null };
9478
+ this.apiRef = {
9479
+ api: null,
9480
+ };
9343
9481
  this._element = document.createElement('div');
9344
- this.element.className = 'default-header';
9482
+ this.element.className = 'dv-default-header';
9345
9483
  this._content = document.createElement('span');
9346
9484
  this._expander = document.createElement('div');
9347
- this._expander.className = 'dockview-pane-header-icon';
9485
+ this._expander.className = 'dv-pane-header-icon';
9348
9486
  this.element.appendChild(this._expander);
9349
9487
  this.element.appendChild(this._content);
9350
9488
  this.addDisposables(addDisposableListener(this._element, 'click', () => {
@@ -10201,22 +10339,6 @@
10201
10339
  disposable.dispose();
10202
10340
  };
10203
10341
  }, [props.onDidDrop]);
10204
- React.useEffect(() => {
10205
- if (!dockviewRef.current) {
10206
- return () => {
10207
- // noop
10208
- };
10209
- }
10210
- const disposable = dockviewRef.current.onUnhandledDragOverEvent((event) => {
10211
- var _a;
10212
- if ((_a = props.showDndOverlay) === null || _a === void 0 ? void 0 : _a.call(props, event)) {
10213
- event.accept();
10214
- }
10215
- });
10216
- return () => {
10217
- disposable.dispose();
10218
- };
10219
- }, [props.showDndOverlay]);
10220
10342
  React.useEffect(() => {
10221
10343
  if (!dockviewRef.current) {
10222
10344
  return () => {
@@ -10634,7 +10756,6 @@
10634
10756
  exports.GridviewComponent = GridviewComponent;
10635
10757
  exports.GridviewPanel = GridviewPanel;
10636
10758
  exports.GridviewReact = GridviewReact;
10637
- exports.LocalSelectionTransfer = LocalSelectionTransfer;
10638
10759
  exports.PROPERTY_KEYS = PROPERTY_KEYS;
10639
10760
  exports.PaneFramework = PaneFramework;
10640
10761
  exports.PaneTransfer = PaneTransfer;
@@ -10653,7 +10774,6 @@
10653
10774
  exports.SplitviewReact = SplitviewReact;
10654
10775
  exports.Tab = Tab;
10655
10776
  exports.WillShowOverlayLocationEvent = WillShowOverlayLocationEvent;
10656
- exports.createComponent = createComponent;
10657
10777
  exports.createDockview = createDockview;
10658
10778
  exports.createGridview = createGridview;
10659
10779
  exports.createPaneview = createPaneview;