dockview-react 3.0.1 → 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.1
3
+ * @version 3.1.0
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -850,7 +850,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
850
850
  this._margin = value;
851
851
  }
852
852
  constructor(container, options) {
853
- var _a;
853
+ var _a, _b;
854
854
  this.container = container;
855
855
  this.viewItems = [];
856
856
  this.sashes = [];
@@ -948,9 +948,9 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
948
948
  //
949
949
  return delta;
950
950
  };
951
- this._orientation = options.orientation;
951
+ this._orientation = (_a = options.orientation) !== null && _a !== void 0 ? _a : exports.Orientation.VERTICAL;
952
952
  this.element = this.createContainer();
953
- this.margin = (_a = options.margin) !== null && _a !== void 0 ? _a : 0;
953
+ this.margin = (_b = options.margin) !== null && _b !== void 0 ? _b : 0;
954
954
  this.proportionalLayout =
955
955
  options.proportionalLayout === undefined
956
956
  ? true
@@ -2769,9 +2769,9 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2769
2769
  set locked(value) {
2770
2770
  this.gridview.locked = value;
2771
2771
  }
2772
- constructor(parentElement, options) {
2772
+ constructor(container, options) {
2773
2773
  var _a;
2774
- super(parentElement, options.disableAutoResizing);
2774
+ super(document.createElement('div'), options.disableAutoResizing);
2775
2775
  this._id = nextLayoutId$1.next();
2776
2776
  this._groups = new Map();
2777
2777
  this._onDidRemove = new Emitter();
@@ -2790,6 +2790,8 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2790
2790
  this.element.style.width = '100%';
2791
2791
  this._classNames = new Classnames(this.element);
2792
2792
  this._classNames.setClassNames((_a = options.className) !== null && _a !== void 0 ? _a : '');
2793
+ // the container is owned by the third-party, do not modify/delete it
2794
+ container.appendChild(this.element);
2793
2795
  this.gridview = new Gridview(!!options.proportionalLayout, options.styles, options.orientation, options.locked, options.margin);
2794
2796
  this.gridview.locked = !!options.locked;
2795
2797
  this.element.appendChild(this.gridview.element);
@@ -5055,6 +5057,9 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5055
5057
  delete(id) {
5056
5058
  const index = this.tabs.findIndex((tab) => tab.value.panel.id === id);
5057
5059
  const tabToRemove = this.tabs.splice(index, 1)[0];
5060
+ if (!tabToRemove) {
5061
+ throw new Error(`dockview: Tab not found`);
5062
+ }
5058
5063
  const { value, disposable } = tabToRemove;
5059
5064
  disposable.dispose();
5060
5065
  value.dispose();
@@ -5076,6 +5081,9 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5076
5081
  const disposable = new CompositeDisposable(tab.onDragStart((event) => {
5077
5082
  this._onTabDragStart.fire({ nativeEvent: event, panel });
5078
5083
  }), tab.onChanged((event) => {
5084
+ if (event.defaultPrevented) {
5085
+ return;
5086
+ }
5079
5087
  const isFloatingGroupsEnabled = !this.accessor.options.disableFloatingGroups;
5080
5088
  const isFloatingWithOnePanel = this.group.api.location.type === 'floating' &&
5081
5089
  this.size === 1;
@@ -5093,12 +5101,15 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5093
5101
  });
5094
5102
  return;
5095
5103
  }
5096
- const isLeftClick = event.button === 0;
5097
- if (!isLeftClick || event.defaultPrevented) {
5098
- return;
5099
- }
5100
- if (this.group.activePanel !== panel) {
5101
- 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;
5102
5113
  }
5103
5114
  }), tab.onDrop((event) => {
5104
5115
  this._onDrop.fire({
@@ -6048,12 +6059,11 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6048
6059
  constructor(id, accessor) {
6049
6060
  super(id, '__dockviewgroup__');
6050
6061
  this.accessor = accessor;
6051
- this._mutableDisposable = new MutableDisposable();
6052
6062
  this._onDidLocationChange = new Emitter();
6053
6063
  this.onDidLocationChange = this._onDidLocationChange.event;
6054
6064
  this._onDidActivePanelChange = new Emitter();
6055
6065
  this.onDidActivePanelChange = this._onDidActivePanelChange.event;
6056
- this.addDisposables(this._onDidLocationChange, this._onDidActivePanelChange, this._mutableDisposable);
6066
+ this.addDisposables(this._onDidLocationChange, this._onDidActivePanelChange);
6057
6067
  }
6058
6068
  close() {
6059
6069
  if (!this._group) {
@@ -6111,20 +6121,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6111
6121
  }
6112
6122
  }
6113
6123
  initialize(group) {
6114
- /**
6115
- * TODO: Annoying initialization order caveat, find a better way to initialize and avoid needing null checks
6116
- *
6117
- * Due to the order on initialization we know that the model isn't defined until later in the same stack-frame of setup.
6118
- * By queuing a microtask we can ensure the setup is completed within the same stack-frame, but after everything else has
6119
- * finished ensuring the `model` is defined.
6120
- */
6121
6124
  this._group = group;
6122
- queueMicrotask(() => {
6123
- this._mutableDisposable.value =
6124
- this._group.model.onDidActivePanelChange((event) => {
6125
- this._onDidActivePanelChange.fire(event);
6126
- });
6127
- });
6128
6125
  }
6129
6126
  }
6130
6127
 
@@ -6194,6 +6191,9 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6194
6191
  }, new DockviewGroupPanelApiImpl(id, accessor));
6195
6192
  this.api.initialize(this); // cannot use 'this' after after 'super' call
6196
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
+ }));
6197
6197
  }
6198
6198
  focus() {
6199
6199
  if (!this.api.isActive) {
@@ -6541,9 +6541,6 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6541
6541
  this.action.appendChild(createCloseButton());
6542
6542
  this._element.appendChild(this._content);
6543
6543
  this._element.appendChild(this.action);
6544
- this.addDisposables(addDisposableListener(this.action, 'pointerdown', (ev) => {
6545
- ev.preventDefault();
6546
- }));
6547
6544
  this.render();
6548
6545
  }
6549
6546
  init(params) {
@@ -7486,9 +7483,9 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7486
7483
  get floatingGroups() {
7487
7484
  return this._floatingGroups;
7488
7485
  }
7489
- constructor(parentElement, options) {
7486
+ constructor(container, options) {
7490
7487
  var _a;
7491
- super(parentElement, {
7488
+ super(container, {
7492
7489
  proportionalLayout: true,
7493
7490
  orientation: exports.Orientation.HORIZONTAL,
7494
7491
  styles: options.hideBorders
@@ -7825,6 +7822,9 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7825
7822
  addDisposableWindowListener(_window.window, 'resize', () => {
7826
7823
  group.layout(_window.window.innerWidth, _window.window.innerHeight);
7827
7824
  }), overlayRenderContainer, exports.DockviewDisposable.from(() => {
7825
+ if (this.isDisposed) {
7826
+ return; // cleanup may run after instance is disposed
7827
+ }
7828
7828
  if (isGroupAddedToDom &&
7829
7829
  this.getPanel(referenceGroup.id)) {
7830
7830
  this.movingLock(() => moveGroupWithoutDestroying({
@@ -7844,6 +7844,16 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7844
7844
  group.model.renderContainer =
7845
7845
  this.overlayRenderContainer;
7846
7846
  returnedGroup = group;
7847
+ const alreadyRemoved = !this._popoutGroups.find((p) => p.popoutGroup === group);
7848
+ if (alreadyRemoved) {
7849
+ /**
7850
+ * If this popout group was explicitly removed then we shouldn't run the additional
7851
+ * steps. To tell if the running of this disposable is the result of this popout group
7852
+ * being explicitly removed we can check if this popout group is still referenced in
7853
+ * the `this._popoutGroups` list.
7854
+ */
7855
+ return;
7856
+ }
7847
7857
  if (floatingBox) {
7848
7858
  this.addFloatingGroup(group, {
7849
7859
  height: floatingBox.height,
@@ -9020,9 +9030,9 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
9020
9030
  set deserializer(value) {
9021
9031
  this._deserializer = value;
9022
9032
  }
9023
- constructor(parentElement, options) {
9033
+ constructor(container, options) {
9024
9034
  var _a;
9025
- super(parentElement, {
9035
+ super(container, {
9026
9036
  proportionalLayout: (_a = options.proportionalLayout) !== null && _a !== void 0 ? _a : true,
9027
9037
  orientation: options.orientation,
9028
9038
  styles: options.hideBorders
@@ -9311,9 +9321,9 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
9311
9321
  ? this.splitview.size
9312
9322
  : this.splitview.orthogonalSize;
9313
9323
  }
9314
- constructor(parentElement, options) {
9324
+ constructor(container, options) {
9315
9325
  var _a;
9316
- super(parentElement, options.disableAutoResizing);
9326
+ super(document.createElement('div'), options.disableAutoResizing);
9317
9327
  this._splitviewChangeDisposable = new MutableDisposable();
9318
9328
  this._panels = new Map();
9319
9329
  this._onDidLayoutfromJSON = new Emitter();
@@ -9324,8 +9334,12 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
9324
9334
  this.onDidRemoveView = this._onDidRemoveView.event;
9325
9335
  this._onDidLayoutChange = new Emitter();
9326
9336
  this.onDidLayoutChange = this._onDidLayoutChange.event;
9337
+ this.element.style.height = '100%';
9338
+ this.element.style.width = '100%';
9327
9339
  this._classNames = new Classnames(this.element);
9328
9340
  this._classNames.setClassNames((_a = options.className) !== null && _a !== void 0 ? _a : '');
9341
+ // the container is owned by the third-party, do not modify/delete it
9342
+ container.appendChild(this.element);
9329
9343
  this._options = options;
9330
9344
  this.splitview = new Splitview(this.element, options);
9331
9345
  this.addDisposables(this._onDidAddView, this._onDidLayoutfromJSON, this._onDidRemoveView, this._onDidLayoutChange);
@@ -9635,9 +9649,9 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
9635
9649
  get options() {
9636
9650
  return this._options;
9637
9651
  }
9638
- constructor(parentElement, options) {
9652
+ constructor(container, options) {
9639
9653
  var _a;
9640
- super(parentElement, options.disableAutoResizing);
9654
+ super(document.createElement('div'), options.disableAutoResizing);
9641
9655
  this._id = nextLayoutId.next();
9642
9656
  this._disposable = new MutableDisposable();
9643
9657
  this._viewDisposables = new Map();
@@ -9653,9 +9667,13 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
9653
9667
  this.onDidRemoveView = this._onDidRemoveView.event;
9654
9668
  this._onUnhandledDragOverEvent = new Emitter();
9655
9669
  this.onUnhandledDragOverEvent = this._onUnhandledDragOverEvent.event;
9670
+ this.element.style.height = '100%';
9671
+ this.element.style.width = '100%';
9656
9672
  this.addDisposables(this._onDidLayoutChange, this._onDidLayoutfromJSON, this._onDidDrop, this._onDidAddView, this._onDidRemoveView, this._onUnhandledDragOverEvent);
9657
9673
  this._classNames = new Classnames(this.element);
9658
9674
  this._classNames.setClassNames((_a = options.className) !== null && _a !== void 0 ? _a : '');
9675
+ // the container is owned by the third-party, do not modify/delete it
9676
+ container.appendChild(this.element);
9659
9677
  this._options = options;
9660
9678
  this.paneview = new Paneview(this.element, {
9661
9679
  // only allow paneview in the vertical orientation for now
@@ -10475,7 +10493,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
10475
10493
  createPrefixHeaderActionComponent: createGroupControlElement(props.prefixHeaderActionsComponent, { addPortal }),
10476
10494
  });
10477
10495
  }, [props.prefixHeaderActionsComponent]);
10478
- return (React.createElement("div", { className: props.className, style: { height: '100%', width: '100%' }, ref: domRef }, portals));
10496
+ return (React.createElement("div", { style: { height: '100%', width: '100%' }, ref: domRef }, portals));
10479
10497
  });
10480
10498
  DockviewReact.displayName = 'DockviewComponent';
10481
10499
 
@@ -10520,16 +10538,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
10520
10538
  const onPointerDown = React.useCallback((e) => {
10521
10539
  e.preventDefault();
10522
10540
  }, []);
10523
- const onClick = React.useCallback((event) => {
10524
- if (event.defaultPrevented) {
10525
- return;
10526
- }
10527
- api.setActive();
10528
- if (rest.onClick) {
10529
- rest.onClick(event);
10530
- }
10531
- }, [api, rest.onClick]);
10532
- 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" }),
10533
10542
  React.createElement("span", { className: "dv-default-tab-content" }, title),
10534
10543
  !hideClose && (React.createElement("div", { className: "dv-default-tab-action", onPointerDown: onPointerDown, onClick: onClose },
10535
10544
  React.createElement(CloseButton, null)))));
@@ -10612,7 +10621,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
10612
10621
  },
10613
10622
  });
10614
10623
  }, [props.components]);
10615
- return (React.createElement("div", { className: props.className, style: { height: '100%', width: '100%' }, ref: domRef }, portals));
10624
+ return (React.createElement("div", { style: { height: '100%', width: '100%' }, ref: domRef }, portals));
10616
10625
  });
10617
10626
  SplitviewReact.displayName = 'SplitviewComponent';
10618
10627
 
@@ -10695,7 +10704,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
10695
10704
  },
10696
10705
  });
10697
10706
  }, [props.components]);
10698
- return (React.createElement("div", { className: props.className, style: { height: '100%', width: '100%' }, ref: domRef }, portals));
10707
+ return (React.createElement("div", { style: { height: '100%', width: '100%' }, ref: domRef }, portals));
10699
10708
  });
10700
10709
  GridviewReact.displayName = 'GridviewComponent';
10701
10710
 
@@ -10827,7 +10836,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
10827
10836
  disposable.dispose();
10828
10837
  };
10829
10838
  }, [props.onDidDrop]);
10830
- return (React.createElement("div", { className: props.className, style: { height: '100%', width: '100%' }, ref: domRef }, portals));
10839
+ return (React.createElement("div", { style: { height: '100%', width: '100%' }, ref: domRef }, portals));
10831
10840
  });
10832
10841
  PaneviewReact.displayName = 'PaneviewComponent';
10833
10842