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
  */
@@ -2800,7 +2800,7 @@
2800
2800
  this._bufferOnDidLayoutChange.fire();
2801
2801
  }), exports.DockviewEvent.any(this.onDidAdd, this.onDidRemove, this.onDidActiveChange)(() => {
2802
2802
  this._bufferOnDidLayoutChange.fire();
2803
- }), this._bufferOnDidLayoutChange);
2803
+ }), this._onDidMaximizedChange, this._onDidViewVisibilityChangeMicroTaskQueue, this._bufferOnDidLayoutChange);
2804
2804
  }
2805
2805
  setVisible(panel, visible) {
2806
2806
  this.gridview.setViewVisible(getGridLocation(panel.element), visible);
@@ -5401,7 +5401,7 @@
5401
5401
  group: this.groupPanel,
5402
5402
  getData: getPanelData,
5403
5403
  }));
5404
- }), this._onMove, this._onDidChange, this._onDidDrop, this._onWillDrop, this._onDidAddPanel, this._onDidRemovePanel, this._onDidActivePanelChange, this._onUnhandledDragOverEvent);
5404
+ }), this._onMove, this._onDidChange, this._onDidDrop, this._onWillDrop, this._onDidAddPanel, this._onDidRemovePanel, this._onDidActivePanelChange, this._onUnhandledDragOverEvent, this._onDidPanelTitleChange, this._onDidPanelParametersChange);
5405
5405
  }
5406
5406
  focusContent() {
5407
5407
  this.contentContainer.element.focus();
@@ -7380,6 +7380,47 @@
7380
7380
  }
7381
7381
  }
7382
7382
 
7383
+ class StrictEventsSequencing extends CompositeDisposable {
7384
+ constructor(accessor) {
7385
+ super();
7386
+ this.accessor = accessor;
7387
+ this.init();
7388
+ }
7389
+ init() {
7390
+ const panels = new Set();
7391
+ const groups = new Set();
7392
+ this.addDisposables(this.accessor.onDidAddPanel((panel) => {
7393
+ if (panels.has(panel.api.id)) {
7394
+ throw new Error(`dockview: Invalid event sequence. [onDidAddPanel] called for panel ${panel.api.id} but panel already exists`);
7395
+ }
7396
+ else {
7397
+ panels.add(panel.api.id);
7398
+ }
7399
+ }), this.accessor.onDidRemovePanel((panel) => {
7400
+ if (!panels.has(panel.api.id)) {
7401
+ throw new Error(`dockview: Invalid event sequence. [onDidRemovePanel] called for panel ${panel.api.id} but panel does not exists`);
7402
+ }
7403
+ else {
7404
+ panels.delete(panel.api.id);
7405
+ }
7406
+ }), this.accessor.onDidAddGroup((group) => {
7407
+ if (groups.has(group.api.id)) {
7408
+ throw new Error(`dockview: Invalid event sequence. [onDidAddGroup] called for group ${group.api.id} but group already exists`);
7409
+ }
7410
+ else {
7411
+ groups.add(group.api.id);
7412
+ }
7413
+ }), this.accessor.onDidRemoveGroup((group) => {
7414
+ if (!groups.has(group.api.id)) {
7415
+ throw new Error(`dockview: Invalid event sequence. [onDidRemoveGroup] called for group ${group.api.id} but group does not exists`);
7416
+ }
7417
+ else {
7418
+ groups.delete(group.api.id);
7419
+ }
7420
+ }));
7421
+ }
7422
+ }
7423
+
7383
7424
  const DEFAULT_ROOT_OVERLAY_MODEL = {
7384
7425
  activationSize: { type: 'pixels', value: 10 },
7385
7426
  size: { type: 'pixels', value: 20 },
@@ -7483,7 +7524,10 @@
7483
7524
  this.overlayRenderContainer = new OverlayRenderContainer(this.gridview.element, this);
7484
7525
  toggleClass(this.gridview.element, 'dv-dockview', true);
7485
7526
  toggleClass(this.element, 'dv-debug', !!options.debug);
7486
- 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(() => {
7527
+ if (options.debug) {
7528
+ this.addDisposables(new StrictEventsSequencing(this));
7529
+ }
7530
+ 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(() => {
7487
7531
  this.updateWatermark();
7488
7532
  }), this.onDidAdd((event) => {
7489
7533
  if (!this._moving) {
@@ -7600,6 +7644,10 @@
7600
7644
  this._api = new DockviewApi(this);
7601
7645
  this.updateWatermark();
7602
7646
  }
7647
+ dispose() {
7648
+ this.clear(); // explicitly clear the layout before cleaning up
7649
+ super.dispose();
7650
+ }
7603
7651
  setVisible(panel, visible) {
7604
7652
  switch (panel.api.location.type) {
7605
7653
  case 'grid':
@@ -7658,6 +7706,7 @@
7658
7706
  return _window
7659
7707
  .open()
7660
7708
  .then((popoutContainer) => {
7709
+ var _a;
7661
7710
  if (_window.isDisposed) {
7662
7711
  return false;
7663
7712
  }
@@ -7690,6 +7739,7 @@
7690
7739
  }
7691
7740
  group.model.renderContainer = overlayRenderContainer;
7692
7741
  group.layout(_window.window.innerWidth, _window.window.innerHeight);
7742
+ let floatingBox;
7693
7743
  if (!(options === null || options === void 0 ? void 0 : options.overridePopoutGroup) && isGroupAddedToDom) {
7694
7744
  if (itemToPopout instanceof DockviewPanel) {
7695
7745
  this.movingLock(() => {
@@ -7708,6 +7758,9 @@
7708
7758
  break;
7709
7759
  case 'floating':
7710
7760
  case 'popout':
7761
+ floatingBox = (_a = this._floatingGroups
7762
+ .find((value) => value.group.api.id ===
7763
+ itemToPopout.api.id)) === null || _a === void 0 ? void 0 : _a.overlay.toJSON();
7711
7764
  this.removeGroup(referenceGroup);
7712
7765
  break;
7713
7766
  }
@@ -7778,17 +7831,29 @@
7778
7831
  }
7779
7832
  }
7780
7833
  else if (this.getPanel(group.id)) {
7781
- this.doRemoveGroup(group, {
7782
- skipDispose: true,
7783
- skipActive: true,
7784
- skipPopoutReturn: true,
7785
- });
7786
7834
  const removedGroup = group;
7787
- removedGroup.model.renderContainer =
7788
- this.overlayRenderContainer;
7789
- removedGroup.model.location = { type: 'grid' };
7790
- returnedGroup = removedGroup;
7791
- this.doAddGroup(removedGroup, [0]);
7835
+ if (floatingBox) {
7836
+ this.addFloatingGroup(removedGroup, {
7837
+ height: floatingBox.height,
7838
+ width: floatingBox.width,
7839
+ position: floatingBox,
7840
+ });
7841
+ }
7842
+ else {
7843
+ this.doRemoveGroup(removedGroup, {
7844
+ skipDispose: true,
7845
+ skipActive: true,
7846
+ skipPopoutReturn: true,
7847
+ });
7848
+ removedGroup.model.renderContainer =
7849
+ this.overlayRenderContainer;
7850
+ removedGroup.model.location = { type: 'grid' };
7851
+ returnedGroup = removedGroup;
7852
+ this.movingLock(() => {
7853
+ // suppress group add events since the group already exists
7854
+ this.doAddGroup(removedGroup, [0]);
7855
+ });
7856
+ }
7792
7857
  this.doSetGroupAndPanelActive(removedGroup);
7793
7858
  }
7794
7859
  }));
@@ -8136,6 +8201,7 @@
8136
8201
  locked: !!locked,
8137
8202
  hideHeader: !!hideHeader,
8138
8203
  });
8204
+ this._onDidAddGroup.fire(group);
8139
8205
  const createdPanels = [];
8140
8206
  for (const child of views) {
8141
8207
  /**
@@ -8146,7 +8212,6 @@
8146
8212
  const panel = this._deserializer.fromJSON(panels[child], group);
8147
8213
  createdPanels.push(panel);
8148
8214
  }
8149
- this._onDidAddGroup.fire(group);
8150
8215
  for (let i = 0; i < views.length; i++) {
8151
8216
  const panel = createdPanels[i];
8152
8217
  const isActive = typeof activeView === 'string' &&
@@ -8545,7 +8610,7 @@
8545
8610
  const refGroup = selectedGroup.referenceGroup
8546
8611
  ? this.getPanel(selectedGroup.referenceGroup)
8547
8612
  : undefined;
8548
- if (refGroup) {
8613
+ if (refGroup && refGroup.panels.length === 0) {
8549
8614
  this.removeGroup(refGroup);
8550
8615
  }
8551
8616
  }