dockview 1.10.0 → 1.10.1

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
3
- * @version 1.10.0
3
+ * @version 1.10.1
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -1468,6 +1468,9 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1468
1468
  this._onDidChange.fire();
1469
1469
  }));
1470
1470
  }
1471
+ setViewVisible(index, visible) {
1472
+ this.splitview.setViewVisible(index, visible);
1473
+ }
1471
1474
  addPane(pane, size, index = this.splitview.length, skipLayout = false) {
1472
1475
  const disposable = pane.onDidChangeExpansionState(() => {
1473
1476
  this.setupAnimation();
@@ -2972,19 +2975,27 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2972
2975
  return this.component.onWillDrop;
2973
2976
  }
2974
2977
  /**
2978
+ * Invoked before an overlay is shown indicating a drop target.
2975
2979
  *
2980
+ * Calling `event.preventDefault()` will prevent the overlay being shown and prevent
2981
+ * the any subsequent drop event.
2976
2982
  */
2977
2983
  get onWillShowOverlay() {
2978
2984
  return this.component.onWillShowOverlay;
2979
2985
  }
2980
2986
  /**
2981
- * Invoked before a group is dragged. Exposed for custom Drag'n'Drop functionality.
2987
+ * Invoked before a group is dragged.
2988
+ *
2989
+ * Calling `event.nativeEvent.preventDefault()` will prevent the group drag starting.
2990
+ *
2982
2991
  */
2983
2992
  get onWillDragGroup() {
2984
2993
  return this.component.onWillDragGroup;
2985
2994
  }
2986
2995
  /**
2987
- * Invoked before a panel is dragged. Exposed for custom Drag'n'Drop functionality.
2996
+ * Invoked before a panel is dragged.
2997
+ *
2998
+ * Calling `event.nativeEvent.preventDefault()` will prevent the panel drag starting.
2988
2999
  */
2989
3000
  get onWillDragPanel() {
2990
3001
  return this.component.onWillDragPanel;
@@ -3528,7 +3539,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3528
3539
  data.groupId === this.group.id;
3529
3540
  return !groupHasOnePanelAndIsActiveDragElement;
3530
3541
  }
3531
- return this.group.canDisplayOverlay(event, position, 'panel');
3542
+ return this.group.canDisplayOverlay(event, position, 'content');
3532
3543
  },
3533
3544
  });
3534
3545
  this.addDisposables(this.dropTarget);
@@ -3851,7 +3862,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3851
3862
  // don't show the overlay if the tab being dragged is the last panel of this group
3852
3863
  return ((_a = last(this.group.panels)) === null || _a === void 0 ? void 0 : _a.id) !== data.panelId;
3853
3864
  }
3854
- return group.model.canDisplayOverlay(event, position, 'panel');
3865
+ return group.model.canDisplayOverlay(event, position, 'header_space');
3855
3866
  },
3856
3867
  });
3857
3868
  this.onWillShowOverlay = this.dropTraget.onWillShowOverlay;
@@ -4980,9 +4991,6 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4980
4991
  get isVisible() {
4981
4992
  return this._isVisible;
4982
4993
  }
4983
- get isHidden() {
4984
- return this._isHidden;
4985
- }
4986
4994
  get width() {
4987
4995
  return this._width;
4988
4996
  }
@@ -4995,7 +5003,6 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4995
5003
  this._isFocused = false;
4996
5004
  this._isActive = false;
4997
5005
  this._isVisible = true;
4998
- this._isHidden = false;
4999
5006
  this._width = 0;
5000
5007
  this._height = 0;
5001
5008
  this.panelUpdatesDisposable = new MutableDisposable();
@@ -5009,8 +5016,8 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5009
5016
  //
5010
5017
  this._onDidVisibilityChange = new Emitter();
5011
5018
  this.onDidVisibilityChange = this._onDidVisibilityChange.event;
5012
- this._onDidHiddenChange = new Emitter();
5013
- this.onDidHiddenChange = this._onDidHiddenChange.event;
5019
+ this._onWillVisibilityChange = new Emitter();
5020
+ this.onWillVisibilityChange = this._onWillVisibilityChange.event;
5014
5021
  this._onDidActiveChange = new Emitter();
5015
5022
  this.onDidActiveChange = this._onDidActiveChange.event;
5016
5023
  this._onActiveChange = new Emitter();
@@ -5023,12 +5030,10 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5023
5030
  this._isActive = event.isActive;
5024
5031
  }), this.onDidVisibilityChange((event) => {
5025
5032
  this._isVisible = event.isVisible;
5026
- }), this.onDidHiddenChange((event) => {
5027
- this._isHidden = event.isHidden;
5028
5033
  }), this.onDidDimensionsChange((event) => {
5029
5034
  this._width = event.width;
5030
5035
  this._height = event.height;
5031
- }), this.panelUpdatesDisposable, this._onDidDimensionChange, this._onDidChangeFocus, this._onDidVisibilityChange, this._onDidActiveChange, this._onWillFocus, this._onActiveChange, this._onUpdateParameters, this._onWillFocus, this._onDidHiddenChange, this._onUpdateParameters);
5036
+ }), this.panelUpdatesDisposable, this._onDidDimensionChange, this._onDidChangeFocus, this._onDidVisibilityChange, this._onDidActiveChange, this._onWillFocus, this._onActiveChange, this._onUpdateParameters, this._onWillFocus, this._onWillVisibilityChange, this._onUpdateParameters);
5032
5037
  }
5033
5038
  initialize(panel) {
5034
5039
  this.panelUpdatesDisposable.value = this._onUpdateParameters.event((parameters) => {
@@ -5037,8 +5042,8 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5037
5042
  });
5038
5043
  });
5039
5044
  }
5040
- setHidden(isHidden) {
5041
- this._onDidHiddenChange.fire({ isHidden });
5045
+ setVisible(isVisible) {
5046
+ this._onWillVisibilityChange.fire({ isVisible });
5042
5047
  }
5043
5048
  setActive() {
5044
5049
  this._onActiveChange.fire();
@@ -5256,7 +5261,11 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5256
5261
  this._onDidChangeExpansionState.fire(this.isExpanded()); // initialize value
5257
5262
  this._orientation = orientation;
5258
5263
  this.element.classList.add('pane');
5259
- this.addDisposables(this.api.onDidSizeChange((event) => {
5264
+ this.addDisposables(this.api.onWillVisibilityChange((event) => {
5265
+ const { isVisible } = event;
5266
+ const { accessor } = this._params;
5267
+ accessor.setVisible(this, isVisible);
5268
+ }), this.api.onDidSizeChange((event) => {
5260
5269
  this._onDidChange.fire({ size: event.size });
5261
5270
  }), addDisposableListener(this.element, 'mouseenter', (ev) => {
5262
5271
  this.api._onMouseEnter.fire(ev);
@@ -5560,10 +5569,10 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5560
5569
  this._maximumHeight = options.maximumHeight;
5561
5570
  }
5562
5571
  this.api.initialize(this); // TODO: required to by-pass 'super before this' requirement
5563
- this.addDisposables(this.api.onDidHiddenChange((event) => {
5564
- const { isHidden } = event;
5572
+ this.addDisposables(this.api.onWillVisibilityChange((event) => {
5573
+ const { isVisible } = event;
5565
5574
  const { accessor } = this._params;
5566
- accessor.setVisible(this, !isHidden);
5575
+ accessor.setVisible(this, isVisible);
5567
5576
  }), this.api.onActiveChange(() => {
5568
5577
  const { accessor } = this._params;
5569
5578
  accessor.doSetGroupActive(this);
@@ -5804,32 +5813,11 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5804
5813
  return this.panel.renderer;
5805
5814
  }
5806
5815
  set group(value) {
5807
- const isOldGroupActive = this.isGroupActive;
5816
+ const oldGroup = this._group;
5808
5817
  if (this._group !== value) {
5809
5818
  this._group = value;
5810
5819
  this._onDidGroupChange.fire({});
5811
- let _trackGroupActive = isOldGroupActive; // prevent duplicate events with same state
5812
- this.groupEventsDisposable.value = new CompositeDisposable(this.group.api.onDidLocationChange((event) => {
5813
- if (this.group !== this.panel.group) {
5814
- return;
5815
- }
5816
- this._onDidLocationChange.fire(event);
5817
- }), this.group.api.onDidActiveChange(() => {
5818
- if (this.group !== this.panel.group) {
5819
- return;
5820
- }
5821
- if (_trackGroupActive !== this.isGroupActive) {
5822
- _trackGroupActive = this.isGroupActive;
5823
- this._onDidActiveGroupChange.fire({
5824
- isActive: this.isGroupActive,
5825
- });
5826
- }
5827
- }));
5828
- // if (this.isGroupActive !== isOldGroupActive) {
5829
- // this._onDidActiveGroupChange.fire({
5830
- // isActive: this.isGroupActive,
5831
- // });
5832
- // }
5820
+ this.setupGroupEventListeners(oldGroup);
5833
5821
  this._onDidLocationChange.fire({
5834
5822
  location: this.group.api.location,
5835
5823
  });
@@ -5855,6 +5843,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5855
5843
  this.groupEventsDisposable = new MutableDisposable();
5856
5844
  this.initialize(panel);
5857
5845
  this._group = group;
5846
+ this.setupGroupEventListeners();
5858
5847
  this.addDisposables(this.groupEventsDisposable, this._onDidRendererChange, this._onDidTitleChange, this._onDidGroupChange, this._onDidActiveGroupChange, this._onDidLocationChange);
5859
5848
  }
5860
5849
  getWindow() {
@@ -5889,6 +5878,35 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5889
5878
  exitMaximized() {
5890
5879
  this.group.api.exitMaximized();
5891
5880
  }
5881
+ setupGroupEventListeners(previousGroup) {
5882
+ var _a;
5883
+ let _trackGroupActive = (_a = previousGroup === null || previousGroup === void 0 ? void 0 : previousGroup.isActive) !== null && _a !== void 0 ? _a : false; // prevent duplicate events with same state
5884
+ this.groupEventsDisposable.value = new CompositeDisposable(this.group.api.onDidVisibilityChange((event) => {
5885
+ if (!event.isVisible && this.isVisible) {
5886
+ this._onDidVisibilityChange.fire(event);
5887
+ }
5888
+ else if (event.isVisible &&
5889
+ !this.isVisible &&
5890
+ this.group.model.isPanelActive(this.panel)) {
5891
+ this._onDidVisibilityChange.fire(event);
5892
+ }
5893
+ }), this.group.api.onDidLocationChange((event) => {
5894
+ if (this.group !== this.panel.group) {
5895
+ return;
5896
+ }
5897
+ this._onDidLocationChange.fire(event);
5898
+ }), this.group.api.onDidActiveChange(() => {
5899
+ if (this.group !== this.panel.group) {
5900
+ return;
5901
+ }
5902
+ if (_trackGroupActive !== this.isGroupActive) {
5903
+ _trackGroupActive = this.isGroupActive;
5904
+ this._onDidActiveGroupChange.fire({
5905
+ isActive: this.isGroupActive,
5906
+ });
5907
+ }
5908
+ }));
5909
+ }
5892
5910
  }
5893
5911
 
5894
5912
  class DockviewPanel extends CompositeDisposable {
@@ -7046,7 +7064,15 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7046
7064
  acceptedTargetZones: ['top', 'bottom', 'left', 'right', 'center'],
7047
7065
  overlayModel: (_b = this.options.rootOverlayModel) !== null && _b !== void 0 ? _b : DEFAULT_ROOT_OVERLAY_MODEL,
7048
7066
  });
7049
- this.addDisposables(this._rootDropTarget.onDrop((event) => {
7067
+ this.addDisposables(this._rootDropTarget, this._rootDropTarget.onWillShowOverlay((event) => {
7068
+ if (this.gridview.length > 0 && event.position === 'center') {
7069
+ // option only available when no panels in primary grid
7070
+ return;
7071
+ }
7072
+ this._onWillShowOverlay.fire(new WillShowOverlayLocationEvent(event, {
7073
+ kind: 'edge',
7074
+ }));
7075
+ }), this._rootDropTarget.onDrop((event) => {
7050
7076
  var _a;
7051
7077
  const willDropEvent = new DockviewWillDropEvent({
7052
7078
  nativeEvent: event.nativeEvent,
@@ -7055,7 +7081,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7055
7081
  api: this._api,
7056
7082
  group: undefined,
7057
7083
  getData: getPanelData,
7058
- kind: 'content',
7084
+ kind: 'edge',
7059
7085
  });
7060
7086
  this._onWillDrop.fire(willDropEvent);
7061
7087
  if (willDropEvent.defaultPrevented) {
@@ -7111,7 +7137,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7111
7137
  const box = getBox();
7112
7138
  const groupId = (_b = (_a = options === null || options === void 0 ? void 0 : options.overridePopoutGroup) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : this.getNextGroupId(); //item.id;
7113
7139
  if (itemToPopout.api.location.type === 'grid') {
7114
- itemToPopout.api.setHidden(true);
7140
+ itemToPopout.api.setVisible(false);
7115
7141
  }
7116
7142
  const _window = new PopoutWindow(`${this.id}-${groupId}`, // unique id
7117
7143
  theme !== null && theme !== void 0 ? theme : '', {
@@ -7162,7 +7188,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7162
7188
  }));
7163
7189
  switch (referenceLocation) {
7164
7190
  case 'grid':
7165
- referenceGroup.api.setHidden(true);
7191
+ referenceGroup.api.setVisible(false);
7166
7192
  break;
7167
7193
  case 'floating':
7168
7194
  case 'popout':
@@ -7216,8 +7242,8 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7216
7242
  from: group,
7217
7243
  to: referenceGroup,
7218
7244
  }));
7219
- if (referenceGroup.api.isHidden) {
7220
- referenceGroup.api.setHidden(false);
7245
+ if (!referenceGroup.api.isVisible) {
7246
+ referenceGroup.api.setVisible(true);
7221
7247
  }
7222
7248
  if (this.getPanel(group.id)) {
7223
7249
  this.doRemoveGroup(group, {
@@ -7790,7 +7816,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7790
7816
  }
7791
7817
  updateWatermark() {
7792
7818
  var _a, _b;
7793
- if (this.groups.filter((x) => x.api.location.type === 'grid' && !x.api.isHidden).length === 0) {
7819
+ if (this.groups.filter((x) => x.api.location.type === 'grid' && x.api.isVisible).length === 0) {
7794
7820
  if (!this.watermark) {
7795
7821
  this.watermark = this.createWatermarkComponent();
7796
7822
  this.watermark.init({
@@ -8573,19 +8599,19 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
8573
8599
  const index = this.panels.indexOf(panel);
8574
8600
  this.splitview.setViewVisible(index, visible);
8575
8601
  }
8576
- setActive(view, skipFocus) {
8577
- this._activePanel = view;
8602
+ setActive(panel, skipFocus) {
8603
+ this._activePanel = panel;
8578
8604
  this.panels
8579
- .filter((v) => v !== view)
8605
+ .filter((v) => v !== panel)
8580
8606
  .forEach((v) => {
8581
8607
  v.api._onDidActiveChange.fire({ isActive: false });
8582
8608
  if (!skipFocus) {
8583
8609
  v.focus();
8584
8610
  }
8585
8611
  });
8586
- view.api._onDidActiveChange.fire({ isActive: true });
8612
+ panel.api._onDidActiveChange.fire({ isActive: true });
8587
8613
  if (!skipFocus) {
8588
- view.focus();
8614
+ panel.focus();
8589
8615
  }
8590
8616
  }
8591
8617
  removePanel(panel, sizing) {
@@ -8884,6 +8910,10 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
8884
8910
  });
8885
8911
  this.addDisposables(this._disposable);
8886
8912
  }
8913
+ setVisible(panel, visible) {
8914
+ const index = this.panels.indexOf(panel);
8915
+ this.paneview.setViewVisible(index, visible);
8916
+ }
8887
8917
  focus() {
8888
8918
  //noop
8889
8919
  }
@@ -8930,6 +8960,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
8930
8960
  isExpanded: options.isExpanded,
8931
8961
  title: options.title,
8932
8962
  containerApi: new PaneviewApi(this),
8963
+ accessor: this,
8933
8964
  });
8934
8965
  this.paneview.addPane(view, size, index);
8935
8966
  view.orientation = this.paneview.orientation;
@@ -9029,6 +9060,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
9029
9060
  title: data.title,
9030
9061
  isExpanded: !!view.expanded,
9031
9062
  containerApi: new PaneviewApi(this),
9063
+ accessor: this,
9032
9064
  });
9033
9065
  panel.orientation = this.paneview.orientation;
9034
9066
  });
@@ -9117,10 +9149,10 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
9117
9149
  this._onDidChange = new Emitter();
9118
9150
  this.onDidChange = this._onDidChange.event;
9119
9151
  this.api.initialize(this);
9120
- this.addDisposables(this._onDidChange, this.api.onDidHiddenChange((event) => {
9121
- const { isHidden } = event;
9152
+ this.addDisposables(this._onDidChange, this.api.onWillVisibilityChange((event) => {
9153
+ const { isVisible } = event;
9122
9154
  const { accessor } = this._params;
9123
- accessor.setVisible(this, !isHidden);
9155
+ accessor.setVisible(this, isVisible);
9124
9156
  }), this.api.onActiveChange(() => {
9125
9157
  const { accessor } = this._params;
9126
9158
  accessor.setActive(this);