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
  */
@@ -2770,7 +2770,7 @@
2770
2770
  this._bufferOnDidLayoutChange.fire();
2771
2771
  }), exports.DockviewEvent.any(this.onDidAdd, this.onDidRemove, this.onDidActiveChange)(() => {
2772
2772
  this._bufferOnDidLayoutChange.fire();
2773
- }), this._bufferOnDidLayoutChange);
2773
+ }), this._onDidMaximizedChange, this._onDidViewVisibilityChangeMicroTaskQueue, this._bufferOnDidLayoutChange);
2774
2774
  }
2775
2775
  setVisible(panel, visible) {
2776
2776
  this.gridview.setViewVisible(getGridLocation(panel.element), visible);
@@ -5371,7 +5371,7 @@
5371
5371
  group: this.groupPanel,
5372
5372
  getData: getPanelData,
5373
5373
  }));
5374
- }), this._onMove, this._onDidChange, this._onDidDrop, this._onWillDrop, this._onDidAddPanel, this._onDidRemovePanel, this._onDidActivePanelChange, this._onUnhandledDragOverEvent);
5374
+ }), this._onMove, this._onDidChange, this._onDidDrop, this._onWillDrop, this._onDidAddPanel, this._onDidRemovePanel, this._onDidActivePanelChange, this._onUnhandledDragOverEvent, this._onDidPanelTitleChange, this._onDidPanelParametersChange);
5375
5375
  }
5376
5376
  focusContent() {
5377
5377
  this.contentContainer.element.focus();
@@ -7350,6 +7350,47 @@
7350
7350
  }
7351
7351
  }
7352
7352
 
7353
+ class StrictEventsSequencing extends CompositeDisposable {
7354
+ constructor(accessor) {
7355
+ super();
7356
+ this.accessor = accessor;
7357
+ this.init();
7358
+ }
7359
+ init() {
7360
+ const panels = new Set();
7361
+ const groups = new Set();
7362
+ this.addDisposables(this.accessor.onDidAddPanel((panel) => {
7363
+ if (panels.has(panel.api.id)) {
7364
+ throw new Error(`dockview: Invalid event sequence. [onDidAddPanel] called for panel ${panel.api.id} but panel already exists`);
7365
+ }
7366
+ else {
7367
+ panels.add(panel.api.id);
7368
+ }
7369
+ }), this.accessor.onDidRemovePanel((panel) => {
7370
+ if (!panels.has(panel.api.id)) {
7371
+ throw new Error(`dockview: Invalid event sequence. [onDidRemovePanel] called for panel ${panel.api.id} but panel does not exists`);
7372
+ }
7373
+ else {
7374
+ panels.delete(panel.api.id);
7375
+ }
7376
+ }), this.accessor.onDidAddGroup((group) => {
7377
+ if (groups.has(group.api.id)) {
7378
+ throw new Error(`dockview: Invalid event sequence. [onDidAddGroup] called for group ${group.api.id} but group already exists`);
7379
+ }
7380
+ else {
7381
+ groups.add(group.api.id);
7382
+ }
7383
+ }), this.accessor.onDidRemoveGroup((group) => {
7384
+ if (!groups.has(group.api.id)) {
7385
+ throw new Error(`dockview: Invalid event sequence. [onDidRemoveGroup] called for group ${group.api.id} but group does not exists`);
7386
+ }
7387
+ else {
7388
+ groups.delete(group.api.id);
7389
+ }
7390
+ }));
7391
+ }
7392
+ }
7393
+
7353
7394
  const DEFAULT_ROOT_OVERLAY_MODEL = {
7354
7395
  activationSize: { type: 'pixels', value: 10 },
7355
7396
  size: { type: 'pixels', value: 20 },
@@ -7453,7 +7494,10 @@
7453
7494
  this.overlayRenderContainer = new OverlayRenderContainer(this.gridview.element, this);
7454
7495
  toggleClass(this.gridview.element, 'dv-dockview', true);
7455
7496
  toggleClass(this.element, 'dv-debug', !!options.debug);
7456
- 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(() => {
7497
+ if (options.debug) {
7498
+ this.addDisposables(new StrictEventsSequencing(this));
7499
+ }
7500
+ 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(() => {
7457
7501
  this.updateWatermark();
7458
7502
  }), this.onDidAdd((event) => {
7459
7503
  if (!this._moving) {
@@ -7570,6 +7614,10 @@
7570
7614
  this._api = new DockviewApi(this);
7571
7615
  this.updateWatermark();
7572
7616
  }
7617
+ dispose() {
7618
+ this.clear(); // explicitly clear the layout before cleaning up
7619
+ super.dispose();
7620
+ }
7573
7621
  setVisible(panel, visible) {
7574
7622
  switch (panel.api.location.type) {
7575
7623
  case 'grid':
@@ -7628,6 +7676,7 @@
7628
7676
  return _window
7629
7677
  .open()
7630
7678
  .then((popoutContainer) => {
7679
+ var _a;
7631
7680
  if (_window.isDisposed) {
7632
7681
  return false;
7633
7682
  }
@@ -7660,6 +7709,7 @@
7660
7709
  }
7661
7710
  group.model.renderContainer = overlayRenderContainer;
7662
7711
  group.layout(_window.window.innerWidth, _window.window.innerHeight);
7712
+ let floatingBox;
7663
7713
  if (!(options === null || options === void 0 ? void 0 : options.overridePopoutGroup) && isGroupAddedToDom) {
7664
7714
  if (itemToPopout instanceof DockviewPanel) {
7665
7715
  this.movingLock(() => {
@@ -7678,6 +7728,9 @@
7678
7728
  break;
7679
7729
  case 'floating':
7680
7730
  case 'popout':
7731
+ floatingBox = (_a = this._floatingGroups
7732
+ .find((value) => value.group.api.id ===
7733
+ itemToPopout.api.id)) === null || _a === void 0 ? void 0 : _a.overlay.toJSON();
7681
7734
  this.removeGroup(referenceGroup);
7682
7735
  break;
7683
7736
  }
@@ -7748,17 +7801,29 @@
7748
7801
  }
7749
7802
  }
7750
7803
  else if (this.getPanel(group.id)) {
7751
- this.doRemoveGroup(group, {
7752
- skipDispose: true,
7753
- skipActive: true,
7754
- skipPopoutReturn: true,
7755
- });
7756
7804
  const removedGroup = group;
7757
- removedGroup.model.renderContainer =
7758
- this.overlayRenderContainer;
7759
- removedGroup.model.location = { type: 'grid' };
7760
- returnedGroup = removedGroup;
7761
- this.doAddGroup(removedGroup, [0]);
7805
+ if (floatingBox) {
7806
+ this.addFloatingGroup(removedGroup, {
7807
+ height: floatingBox.height,
7808
+ width: floatingBox.width,
7809
+ position: floatingBox,
7810
+ });
7811
+ }
7812
+ else {
7813
+ this.doRemoveGroup(removedGroup, {
7814
+ skipDispose: true,
7815
+ skipActive: true,
7816
+ skipPopoutReturn: true,
7817
+ });
7818
+ removedGroup.model.renderContainer =
7819
+ this.overlayRenderContainer;
7820
+ removedGroup.model.location = { type: 'grid' };
7821
+ returnedGroup = removedGroup;
7822
+ this.movingLock(() => {
7823
+ // suppress group add events since the group already exists
7824
+ this.doAddGroup(removedGroup, [0]);
7825
+ });
7826
+ }
7762
7827
  this.doSetGroupAndPanelActive(removedGroup);
7763
7828
  }
7764
7829
  }));
@@ -8106,6 +8171,7 @@
8106
8171
  locked: !!locked,
8107
8172
  hideHeader: !!hideHeader,
8108
8173
  });
8174
+ this._onDidAddGroup.fire(group);
8109
8175
  const createdPanels = [];
8110
8176
  for (const child of views) {
8111
8177
  /**
@@ -8116,7 +8182,6 @@
8116
8182
  const panel = this._deserializer.fromJSON(panels[child], group);
8117
8183
  createdPanels.push(panel);
8118
8184
  }
8119
- this._onDidAddGroup.fire(group);
8120
8185
  for (let i = 0; i < views.length; i++) {
8121
8186
  const panel = createdPanels[i];
8122
8187
  const isActive = typeof activeView === 'string' &&
@@ -8515,7 +8580,7 @@
8515
8580
  const refGroup = selectedGroup.referenceGroup
8516
8581
  ? this.getPanel(selectedGroup.referenceGroup)
8517
8582
  : undefined;
8518
- if (refGroup) {
8583
+ if (refGroup && refGroup.panels.length === 0) {
8519
8584
  this.removeGroup(refGroup);
8520
8585
  }
8521
8586
  }