dockview-react 2.1.1 → 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.1
3
+ * @version 2.1.2
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -2766,7 +2766,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2766
2766
  this._bufferOnDidLayoutChange.fire();
2767
2767
  }), exports.DockviewEvent.any(this.onDidAdd, this.onDidRemove, this.onDidActiveChange)(() => {
2768
2768
  this._bufferOnDidLayoutChange.fire();
2769
- }), this._bufferOnDidLayoutChange);
2769
+ }), this._onDidMaximizedChange, this._onDidViewVisibilityChangeMicroTaskQueue, this._bufferOnDidLayoutChange);
2770
2770
  }
2771
2771
  setVisible(panel, visible) {
2772
2772
  this.gridview.setViewVisible(getGridLocation(panel.element), visible);
@@ -5367,7 +5367,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5367
5367
  group: this.groupPanel,
5368
5368
  getData: getPanelData,
5369
5369
  }));
5370
- }), this._onMove, this._onDidChange, this._onDidDrop, this._onWillDrop, this._onDidAddPanel, this._onDidRemovePanel, this._onDidActivePanelChange, this._onUnhandledDragOverEvent);
5370
+ }), this._onMove, this._onDidChange, this._onDidDrop, this._onWillDrop, this._onDidAddPanel, this._onDidRemovePanel, this._onDidActivePanelChange, this._onUnhandledDragOverEvent, this._onDidPanelTitleChange, this._onDidPanelParametersChange);
5371
5371
  }
5372
5372
  focusContent() {
5373
5373
  this.contentContainer.element.focus();
@@ -7346,6 +7346,47 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7346
7346
  }
7347
7347
  }
7348
7348
 
7349
+ class StrictEventsSequencing extends CompositeDisposable {
7350
+ constructor(accessor) {
7351
+ super();
7352
+ this.accessor = accessor;
7353
+ this.init();
7354
+ }
7355
+ init() {
7356
+ const panels = new Set();
7357
+ const groups = new Set();
7358
+ this.addDisposables(this.accessor.onDidAddPanel((panel) => {
7359
+ if (panels.has(panel.api.id)) {
7360
+ throw new Error(`dockview: Invalid event sequence. [onDidAddPanel] called for panel ${panel.api.id} but panel already exists`);
7361
+ }
7362
+ else {
7363
+ panels.add(panel.api.id);
7364
+ }
7365
+ }), this.accessor.onDidRemovePanel((panel) => {
7366
+ if (!panels.has(panel.api.id)) {
7367
+ throw new Error(`dockview: Invalid event sequence. [onDidRemovePanel] called for panel ${panel.api.id} but panel does not exists`);
7368
+ }
7369
+ else {
7370
+ panels.delete(panel.api.id);
7371
+ }
7372
+ }), this.accessor.onDidAddGroup((group) => {
7373
+ if (groups.has(group.api.id)) {
7374
+ throw new Error(`dockview: Invalid event sequence. [onDidAddGroup] called for group ${group.api.id} but group already exists`);
7375
+ }
7376
+ else {
7377
+ groups.add(group.api.id);
7378
+ }
7379
+ }), this.accessor.onDidRemoveGroup((group) => {
7380
+ if (!groups.has(group.api.id)) {
7381
+ throw new Error(`dockview: Invalid event sequence. [onDidRemoveGroup] called for group ${group.api.id} but group does not exists`);
7382
+ }
7383
+ else {
7384
+ groups.delete(group.api.id);
7385
+ }
7386
+ }));
7387
+ }
7388
+ }
7389
+
7349
7390
  const DEFAULT_ROOT_OVERLAY_MODEL = {
7350
7391
  activationSize: { type: 'pixels', value: 10 },
7351
7392
  size: { type: 'pixels', value: 20 },
@@ -7449,7 +7490,10 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7449
7490
  this.overlayRenderContainer = new OverlayRenderContainer(this.gridview.element, this);
7450
7491
  toggleClass(this.gridview.element, 'dv-dockview', true);
7451
7492
  toggleClass(this.element, 'dv-debug', !!options.debug);
7452
- 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(() => {
7493
+ if (options.debug) {
7494
+ this.addDisposables(new StrictEventsSequencing(this));
7495
+ }
7496
+ 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(() => {
7453
7497
  this.updateWatermark();
7454
7498
  }), this.onDidAdd((event) => {
7455
7499
  if (!this._moving) {
@@ -7566,6 +7610,10 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7566
7610
  this._api = new DockviewApi(this);
7567
7611
  this.updateWatermark();
7568
7612
  }
7613
+ dispose() {
7614
+ this.clear(); // explicitly clear the layout before cleaning up
7615
+ super.dispose();
7616
+ }
7569
7617
  setVisible(panel, visible) {
7570
7618
  switch (panel.api.location.type) {
7571
7619
  case 'grid':
@@ -7624,6 +7672,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7624
7672
  return _window
7625
7673
  .open()
7626
7674
  .then((popoutContainer) => {
7675
+ var _a;
7627
7676
  if (_window.isDisposed) {
7628
7677
  return false;
7629
7678
  }
@@ -7656,6 +7705,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7656
7705
  }
7657
7706
  group.model.renderContainer = overlayRenderContainer;
7658
7707
  group.layout(_window.window.innerWidth, _window.window.innerHeight);
7708
+ let floatingBox;
7659
7709
  if (!(options === null || options === void 0 ? void 0 : options.overridePopoutGroup) && isGroupAddedToDom) {
7660
7710
  if (itemToPopout instanceof DockviewPanel) {
7661
7711
  this.movingLock(() => {
@@ -7674,6 +7724,9 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7674
7724
  break;
7675
7725
  case 'floating':
7676
7726
  case 'popout':
7727
+ floatingBox = (_a = this._floatingGroups
7728
+ .find((value) => value.group.api.id ===
7729
+ itemToPopout.api.id)) === null || _a === void 0 ? void 0 : _a.overlay.toJSON();
7677
7730
  this.removeGroup(referenceGroup);
7678
7731
  break;
7679
7732
  }
@@ -7744,17 +7797,29 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7744
7797
  }
7745
7798
  }
7746
7799
  else if (this.getPanel(group.id)) {
7747
- this.doRemoveGroup(group, {
7748
- skipDispose: true,
7749
- skipActive: true,
7750
- skipPopoutReturn: true,
7751
- });
7752
7800
  const removedGroup = group;
7753
- removedGroup.model.renderContainer =
7754
- this.overlayRenderContainer;
7755
- removedGroup.model.location = { type: 'grid' };
7756
- returnedGroup = removedGroup;
7757
- this.doAddGroup(removedGroup, [0]);
7801
+ if (floatingBox) {
7802
+ this.addFloatingGroup(removedGroup, {
7803
+ height: floatingBox.height,
7804
+ width: floatingBox.width,
7805
+ position: floatingBox,
7806
+ });
7807
+ }
7808
+ else {
7809
+ this.doRemoveGroup(removedGroup, {
7810
+ skipDispose: true,
7811
+ skipActive: true,
7812
+ skipPopoutReturn: true,
7813
+ });
7814
+ removedGroup.model.renderContainer =
7815
+ this.overlayRenderContainer;
7816
+ removedGroup.model.location = { type: 'grid' };
7817
+ returnedGroup = removedGroup;
7818
+ this.movingLock(() => {
7819
+ // suppress group add events since the group already exists
7820
+ this.doAddGroup(removedGroup, [0]);
7821
+ });
7822
+ }
7758
7823
  this.doSetGroupAndPanelActive(removedGroup);
7759
7824
  }
7760
7825
  }));
@@ -8102,6 +8167,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
8102
8167
  locked: !!locked,
8103
8168
  hideHeader: !!hideHeader,
8104
8169
  });
8170
+ this._onDidAddGroup.fire(group);
8105
8171
  const createdPanels = [];
8106
8172
  for (const child of views) {
8107
8173
  /**
@@ -8112,7 +8178,6 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
8112
8178
  const panel = this._deserializer.fromJSON(panels[child], group);
8113
8179
  createdPanels.push(panel);
8114
8180
  }
8115
- this._onDidAddGroup.fire(group);
8116
8181
  for (let i = 0; i < views.length; i++) {
8117
8182
  const panel = createdPanels[i];
8118
8183
  const isActive = typeof activeView === 'string' &&