dockview-react 2.1.0 → 2.1.2

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 2.1.0
3
+ * @version 2.1.2
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -2797,7 +2797,7 @@ class BaseGrid extends Resizable {
2797
2797
  this._bufferOnDidLayoutChange.fire();
2798
2798
  }), Event.any(this.onDidAdd, this.onDidRemove, this.onDidActiveChange)(() => {
2799
2799
  this._bufferOnDidLayoutChange.fire();
2800
- }), this._bufferOnDidLayoutChange);
2800
+ }), this._onDidMaximizedChange, this._onDidViewVisibilityChangeMicroTaskQueue, this._bufferOnDidLayoutChange);
2801
2801
  }
2802
2802
  setVisible(panel, visible) {
2803
2803
  this.gridview.setViewVisible(getGridLocation(panel.element), visible);
@@ -5398,7 +5398,7 @@ class DockviewGroupPanelModel extends CompositeDisposable {
5398
5398
  group: this.groupPanel,
5399
5399
  getData: getPanelData,
5400
5400
  }));
5401
- }), this._onMove, this._onDidChange, this._onDidDrop, this._onWillDrop, this._onDidAddPanel, this._onDidRemovePanel, this._onDidActivePanelChange, this._onUnhandledDragOverEvent);
5401
+ }), this._onMove, this._onDidChange, this._onDidDrop, this._onWillDrop, this._onDidAddPanel, this._onDidRemovePanel, this._onDidActivePanelChange, this._onUnhandledDragOverEvent, this._onDidPanelTitleChange, this._onDidPanelParametersChange);
5402
5402
  }
5403
5403
  focusContent() {
5404
5404
  this.contentContainer.element.focus();
@@ -7377,6 +7377,47 @@ class PopoutWindow extends CompositeDisposable {
7377
7377
  }
7378
7378
  }
7379
7379
 
7380
+ class StrictEventsSequencing extends CompositeDisposable {
7381
+ constructor(accessor) {
7382
+ super();
7383
+ this.accessor = accessor;
7384
+ this.init();
7385
+ }
7386
+ init() {
7387
+ const panels = new Set();
7388
+ const groups = new Set();
7389
+ this.addDisposables(this.accessor.onDidAddPanel((panel) => {
7390
+ if (panels.has(panel.api.id)) {
7391
+ throw new Error(`dockview: Invalid event sequence. [onDidAddPanel] called for panel ${panel.api.id} but panel already exists`);
7392
+ }
7393
+ else {
7394
+ panels.add(panel.api.id);
7395
+ }
7396
+ }), this.accessor.onDidRemovePanel((panel) => {
7397
+ if (!panels.has(panel.api.id)) {
7398
+ throw new Error(`dockview: Invalid event sequence. [onDidRemovePanel] called for panel ${panel.api.id} but panel does not exists`);
7399
+ }
7400
+ else {
7401
+ panels.delete(panel.api.id);
7402
+ }
7403
+ }), this.accessor.onDidAddGroup((group) => {
7404
+ if (groups.has(group.api.id)) {
7405
+ throw new Error(`dockview: Invalid event sequence. [onDidAddGroup] called for group ${group.api.id} but group already exists`);
7406
+ }
7407
+ else {
7408
+ groups.add(group.api.id);
7409
+ }
7410
+ }), this.accessor.onDidRemoveGroup((group) => {
7411
+ if (!groups.has(group.api.id)) {
7412
+ throw new Error(`dockview: Invalid event sequence. [onDidRemoveGroup] called for group ${group.api.id} but group does not exists`);
7413
+ }
7414
+ else {
7415
+ groups.delete(group.api.id);
7416
+ }
7417
+ }));
7418
+ }
7419
+ }
7420
+
7380
7421
  const DEFAULT_ROOT_OVERLAY_MODEL = {
7381
7422
  activationSize: { type: 'pixels', value: 10 },
7382
7423
  size: { type: 'pixels', value: 20 },
@@ -7480,7 +7521,10 @@ class DockviewComponent extends BaseGrid {
7480
7521
  this.overlayRenderContainer = new OverlayRenderContainer(this.gridview.element, this);
7481
7522
  toggleClass(this.gridview.element, 'dv-dockview', true);
7482
7523
  toggleClass(this.element, 'dv-debug', !!options.debug);
7483
- this.addDisposables(this.overlayRenderContainer, this._onWillDragPanel, this._onWillDragGroup, this._onWillShowOverlay, this._onDidActivePanelChange, this._onDidAddPanel, this._onDidRemovePanel, this._onDidLayoutFromJSON, this._onDidDrop, this._onWillDrop, this._onDidMovePanel, this._onDidAddGroup, this._onDidRemoveGroup, this._onDidActiveGroupChange, this._onUnhandledDragOverEvent, this.onDidViewVisibilityChangeMicroTaskQueue(() => {
7524
+ if (options.debug) {
7525
+ this.addDisposables(new StrictEventsSequencing(this));
7526
+ }
7527
+ this.addDisposables(this.overlayRenderContainer, this._onWillDragPanel, this._onWillDragGroup, this._onWillShowOverlay, this._onDidActivePanelChange, this._onDidAddPanel, this._onDidRemovePanel, this._onDidLayoutFromJSON, this._onDidDrop, this._onWillDrop, this._onDidMovePanel, this._onDidAddGroup, this._onDidRemoveGroup, this._onDidActiveGroupChange, this._onUnhandledDragOverEvent, this._onDidMaximizedGroupChange, this.onDidViewVisibilityChangeMicroTaskQueue(() => {
7484
7528
  this.updateWatermark();
7485
7529
  }), this.onDidAdd((event) => {
7486
7530
  if (!this._moving) {
@@ -7597,6 +7641,10 @@ class DockviewComponent extends BaseGrid {
7597
7641
  this._api = new DockviewApi(this);
7598
7642
  this.updateWatermark();
7599
7643
  }
7644
+ dispose() {
7645
+ this.clear(); // explicitly clear the layout before cleaning up
7646
+ super.dispose();
7647
+ }
7600
7648
  setVisible(panel, visible) {
7601
7649
  switch (panel.api.location.type) {
7602
7650
  case 'grid':
@@ -7655,6 +7703,7 @@ class DockviewComponent extends BaseGrid {
7655
7703
  return _window
7656
7704
  .open()
7657
7705
  .then((popoutContainer) => {
7706
+ var _a;
7658
7707
  if (_window.isDisposed) {
7659
7708
  return false;
7660
7709
  }
@@ -7687,6 +7736,7 @@ class DockviewComponent extends BaseGrid {
7687
7736
  }
7688
7737
  group.model.renderContainer = overlayRenderContainer;
7689
7738
  group.layout(_window.window.innerWidth, _window.window.innerHeight);
7739
+ let floatingBox;
7690
7740
  if (!(options === null || options === void 0 ? void 0 : options.overridePopoutGroup) && isGroupAddedToDom) {
7691
7741
  if (itemToPopout instanceof DockviewPanel) {
7692
7742
  this.movingLock(() => {
@@ -7705,6 +7755,9 @@ class DockviewComponent extends BaseGrid {
7705
7755
  break;
7706
7756
  case 'floating':
7707
7757
  case 'popout':
7758
+ floatingBox = (_a = this._floatingGroups
7759
+ .find((value) => value.group.api.id ===
7760
+ itemToPopout.api.id)) === null || _a === void 0 ? void 0 : _a.overlay.toJSON();
7708
7761
  this.removeGroup(referenceGroup);
7709
7762
  break;
7710
7763
  }
@@ -7775,17 +7828,29 @@ class DockviewComponent extends BaseGrid {
7775
7828
  }
7776
7829
  }
7777
7830
  else if (this.getPanel(group.id)) {
7778
- this.doRemoveGroup(group, {
7779
- skipDispose: true,
7780
- skipActive: true,
7781
- skipPopoutReturn: true,
7782
- });
7783
7831
  const removedGroup = group;
7784
- removedGroup.model.renderContainer =
7785
- this.overlayRenderContainer;
7786
- removedGroup.model.location = { type: 'grid' };
7787
- returnedGroup = removedGroup;
7788
- this.doAddGroup(removedGroup, [0]);
7832
+ if (floatingBox) {
7833
+ this.addFloatingGroup(removedGroup, {
7834
+ height: floatingBox.height,
7835
+ width: floatingBox.width,
7836
+ position: floatingBox,
7837
+ });
7838
+ }
7839
+ else {
7840
+ this.doRemoveGroup(removedGroup, {
7841
+ skipDispose: true,
7842
+ skipActive: true,
7843
+ skipPopoutReturn: true,
7844
+ });
7845
+ removedGroup.model.renderContainer =
7846
+ this.overlayRenderContainer;
7847
+ removedGroup.model.location = { type: 'grid' };
7848
+ returnedGroup = removedGroup;
7849
+ this.movingLock(() => {
7850
+ // suppress group add events since the group already exists
7851
+ this.doAddGroup(removedGroup, [0]);
7852
+ });
7853
+ }
7789
7854
  this.doSetGroupAndPanelActive(removedGroup);
7790
7855
  }
7791
7856
  }));
@@ -8133,6 +8198,7 @@ class DockviewComponent extends BaseGrid {
8133
8198
  locked: !!locked,
8134
8199
  hideHeader: !!hideHeader,
8135
8200
  });
8201
+ this._onDidAddGroup.fire(group);
8136
8202
  const createdPanels = [];
8137
8203
  for (const child of views) {
8138
8204
  /**
@@ -8143,7 +8209,6 @@ class DockviewComponent extends BaseGrid {
8143
8209
  const panel = this._deserializer.fromJSON(panels[child], group);
8144
8210
  createdPanels.push(panel);
8145
8211
  }
8146
- this._onDidAddGroup.fire(group);
8147
8212
  for (let i = 0; i < views.length; i++) {
8148
8213
  const panel = createdPanels[i];
8149
8214
  const isActive = typeof activeView === 'string' &&
@@ -8542,7 +8607,7 @@ class DockviewComponent extends BaseGrid {
8542
8607
  const refGroup = selectedGroup.referenceGroup
8543
8608
  ? this.getPanel(selectedGroup.referenceGroup)
8544
8609
  : undefined;
8545
- if (refGroup) {
8610
+ if (refGroup && refGroup.panels.length === 0) {
8546
8611
  this.removeGroup(refGroup);
8547
8612
  }
8548
8613
  }