dockview-react 3.0.2 → 3.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 3.0.2
3
+ * @version 3.1.0
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -5057,6 +5057,9 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5057
5057
  delete(id) {
5058
5058
  const index = this.tabs.findIndex((tab) => tab.value.panel.id === id);
5059
5059
  const tabToRemove = this.tabs.splice(index, 1)[0];
5060
+ if (!tabToRemove) {
5061
+ throw new Error(`dockview: Tab not found`);
5062
+ }
5060
5063
  const { value, disposable } = tabToRemove;
5061
5064
  disposable.dispose();
5062
5065
  value.dispose();
@@ -5078,6 +5081,9 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5078
5081
  const disposable = new CompositeDisposable(tab.onDragStart((event) => {
5079
5082
  this._onTabDragStart.fire({ nativeEvent: event, panel });
5080
5083
  }), tab.onChanged((event) => {
5084
+ if (event.defaultPrevented) {
5085
+ return;
5086
+ }
5081
5087
  const isFloatingGroupsEnabled = !this.accessor.options.disableFloatingGroups;
5082
5088
  const isFloatingWithOnePanel = this.group.api.location.type === 'floating' &&
5083
5089
  this.size === 1;
@@ -5095,12 +5101,15 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5095
5101
  });
5096
5102
  return;
5097
5103
  }
5098
- const isLeftClick = event.button === 0;
5099
- if (!isLeftClick || event.defaultPrevented) {
5100
- return;
5101
- }
5102
- if (this.group.activePanel !== panel) {
5103
- this.group.model.openPanel(panel);
5104
+ switch (event.button) {
5105
+ case 0: // left click or touch
5106
+ if (this.group.activePanel !== panel) {
5107
+ this.group.model.openPanel(panel);
5108
+ }
5109
+ break;
5110
+ case 1: // middle click
5111
+ panel.api.close();
5112
+ break;
5104
5113
  }
5105
5114
  }), tab.onDrop((event) => {
5106
5115
  this._onDrop.fire({
@@ -6050,12 +6059,11 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6050
6059
  constructor(id, accessor) {
6051
6060
  super(id, '__dockviewgroup__');
6052
6061
  this.accessor = accessor;
6053
- this._mutableDisposable = new MutableDisposable();
6054
6062
  this._onDidLocationChange = new Emitter();
6055
6063
  this.onDidLocationChange = this._onDidLocationChange.event;
6056
6064
  this._onDidActivePanelChange = new Emitter();
6057
6065
  this.onDidActivePanelChange = this._onDidActivePanelChange.event;
6058
- this.addDisposables(this._onDidLocationChange, this._onDidActivePanelChange, this._mutableDisposable);
6066
+ this.addDisposables(this._onDidLocationChange, this._onDidActivePanelChange);
6059
6067
  }
6060
6068
  close() {
6061
6069
  if (!this._group) {
@@ -6113,20 +6121,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6113
6121
  }
6114
6122
  }
6115
6123
  initialize(group) {
6116
- /**
6117
- * TODO: Annoying initialization order caveat, find a better way to initialize and avoid needing null checks
6118
- *
6119
- * Due to the order on initialization we know that the model isn't defined until later in the same stack-frame of setup.
6120
- * By queuing a microtask we can ensure the setup is completed within the same stack-frame, but after everything else has
6121
- * finished ensuring the `model` is defined.
6122
- */
6123
6124
  this._group = group;
6124
- queueMicrotask(() => {
6125
- this._mutableDisposable.value =
6126
- this._group.model.onDidActivePanelChange((event) => {
6127
- this._onDidActivePanelChange.fire(event);
6128
- });
6129
- });
6130
6125
  }
6131
6126
  }
6132
6127
 
@@ -6196,6 +6191,9 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6196
6191
  }, new DockviewGroupPanelApiImpl(id, accessor));
6197
6192
  this.api.initialize(this); // cannot use 'this' after after 'super' call
6198
6193
  this._model = new DockviewGroupPanelModel(this.element, accessor, id, options, this);
6194
+ this.addDisposables(this.model.onDidActivePanelChange((event) => {
6195
+ this.api._onDidActivePanelChange.fire(event);
6196
+ }));
6199
6197
  }
6200
6198
  focus() {
6201
6199
  if (!this.api.isActive) {
@@ -6543,9 +6541,6 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6543
6541
  this.action.appendChild(createCloseButton());
6544
6542
  this._element.appendChild(this._content);
6545
6543
  this._element.appendChild(this.action);
6546
- this.addDisposables(addDisposableListener(this.action, 'pointerdown', (ev) => {
6547
- ev.preventDefault();
6548
- }));
6549
6544
  this.render();
6550
6545
  }
6551
6546
  init(params) {
@@ -7827,6 +7822,9 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7827
7822
  addDisposableWindowListener(_window.window, 'resize', () => {
7828
7823
  group.layout(_window.window.innerWidth, _window.window.innerHeight);
7829
7824
  }), overlayRenderContainer, exports.DockviewDisposable.from(() => {
7825
+ if (this.isDisposed) {
7826
+ return; // cleanup may run after instance is disposed
7827
+ }
7830
7828
  if (isGroupAddedToDom &&
7831
7829
  this.getPanel(referenceGroup.id)) {
7832
7830
  this.movingLock(() => moveGroupWithoutDestroying({
@@ -10540,16 +10538,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
10540
10538
  const onPointerDown = React.useCallback((e) => {
10541
10539
  e.preventDefault();
10542
10540
  }, []);
10543
- const onClick = React.useCallback((event) => {
10544
- if (event.defaultPrevented) {
10545
- return;
10546
- }
10547
- api.setActive();
10548
- if (rest.onClick) {
10549
- rest.onClick(event);
10550
- }
10551
- }, [api, rest.onClick]);
10552
- return (React.createElement("div", Object.assign({ "data-testid": "dockview-dv-default-tab" }, rest, { onClick: onClick, className: "dv-default-tab" }),
10541
+ return (React.createElement("div", Object.assign({ "data-testid": "dockview-dv-default-tab" }, rest, { className: "dv-default-tab" }),
10553
10542
  React.createElement("span", { className: "dv-default-tab-content" }, title),
10554
10543
  !hideClose && (React.createElement("div", { className: "dv-default-tab-action", onPointerDown: onPointerDown, onClick: onClose },
10555
10544
  React.createElement(CloseButton, null)))));