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
  */
@@ -1498,6 +1498,9 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1498
1498
  this._onDidChange.fire();
1499
1499
  }));
1500
1500
  }
1501
+ setViewVisible(index, visible) {
1502
+ this.splitview.setViewVisible(index, visible);
1503
+ }
1501
1504
  addPane(pane, size, index = this.splitview.length, skipLayout = false) {
1502
1505
  const disposable = pane.onDidChangeExpansionState(() => {
1503
1506
  this.setupAnimation();
@@ -3002,19 +3005,27 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3002
3005
  return this.component.onWillDrop;
3003
3006
  }
3004
3007
  /**
3008
+ * Invoked before an overlay is shown indicating a drop target.
3005
3009
  *
3010
+ * Calling `event.preventDefault()` will prevent the overlay being shown and prevent
3011
+ * the any subsequent drop event.
3006
3012
  */
3007
3013
  get onWillShowOverlay() {
3008
3014
  return this.component.onWillShowOverlay;
3009
3015
  }
3010
3016
  /**
3011
- * Invoked before a group is dragged. Exposed for custom Drag'n'Drop functionality.
3017
+ * Invoked before a group is dragged.
3018
+ *
3019
+ * Calling `event.nativeEvent.preventDefault()` will prevent the group drag starting.
3020
+ *
3012
3021
  */
3013
3022
  get onWillDragGroup() {
3014
3023
  return this.component.onWillDragGroup;
3015
3024
  }
3016
3025
  /**
3017
- * Invoked before a panel is dragged. Exposed for custom Drag'n'Drop functionality.
3026
+ * Invoked before a panel is dragged.
3027
+ *
3028
+ * Calling `event.nativeEvent.preventDefault()` will prevent the panel drag starting.
3018
3029
  */
3019
3030
  get onWillDragPanel() {
3020
3031
  return this.component.onWillDragPanel;
@@ -3558,7 +3569,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3558
3569
  data.groupId === this.group.id;
3559
3570
  return !groupHasOnePanelAndIsActiveDragElement;
3560
3571
  }
3561
- return this.group.canDisplayOverlay(event, position, 'panel');
3572
+ return this.group.canDisplayOverlay(event, position, 'content');
3562
3573
  },
3563
3574
  });
3564
3575
  this.addDisposables(this.dropTarget);
@@ -3881,7 +3892,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3881
3892
  // don't show the overlay if the tab being dragged is the last panel of this group
3882
3893
  return ((_a = last(this.group.panels)) === null || _a === void 0 ? void 0 : _a.id) !== data.panelId;
3883
3894
  }
3884
- return group.model.canDisplayOverlay(event, position, 'panel');
3895
+ return group.model.canDisplayOverlay(event, position, 'header_space');
3885
3896
  },
3886
3897
  });
3887
3898
  this.onWillShowOverlay = this.dropTraget.onWillShowOverlay;
@@ -5010,9 +5021,6 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5010
5021
  get isVisible() {
5011
5022
  return this._isVisible;
5012
5023
  }
5013
- get isHidden() {
5014
- return this._isHidden;
5015
- }
5016
5024
  get width() {
5017
5025
  return this._width;
5018
5026
  }
@@ -5025,7 +5033,6 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5025
5033
  this._isFocused = false;
5026
5034
  this._isActive = false;
5027
5035
  this._isVisible = true;
5028
- this._isHidden = false;
5029
5036
  this._width = 0;
5030
5037
  this._height = 0;
5031
5038
  this.panelUpdatesDisposable = new MutableDisposable();
@@ -5039,8 +5046,8 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5039
5046
  //
5040
5047
  this._onDidVisibilityChange = new Emitter();
5041
5048
  this.onDidVisibilityChange = this._onDidVisibilityChange.event;
5042
- this._onDidHiddenChange = new Emitter();
5043
- this.onDidHiddenChange = this._onDidHiddenChange.event;
5049
+ this._onWillVisibilityChange = new Emitter();
5050
+ this.onWillVisibilityChange = this._onWillVisibilityChange.event;
5044
5051
  this._onDidActiveChange = new Emitter();
5045
5052
  this.onDidActiveChange = this._onDidActiveChange.event;
5046
5053
  this._onActiveChange = new Emitter();
@@ -5053,12 +5060,10 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5053
5060
  this._isActive = event.isActive;
5054
5061
  }), this.onDidVisibilityChange((event) => {
5055
5062
  this._isVisible = event.isVisible;
5056
- }), this.onDidHiddenChange((event) => {
5057
- this._isHidden = event.isHidden;
5058
5063
  }), this.onDidDimensionsChange((event) => {
5059
5064
  this._width = event.width;
5060
5065
  this._height = event.height;
5061
- }), this.panelUpdatesDisposable, this._onDidDimensionChange, this._onDidChangeFocus, this._onDidVisibilityChange, this._onDidActiveChange, this._onWillFocus, this._onActiveChange, this._onUpdateParameters, this._onWillFocus, this._onDidHiddenChange, this._onUpdateParameters);
5066
+ }), this.panelUpdatesDisposable, this._onDidDimensionChange, this._onDidChangeFocus, this._onDidVisibilityChange, this._onDidActiveChange, this._onWillFocus, this._onActiveChange, this._onUpdateParameters, this._onWillFocus, this._onWillVisibilityChange, this._onUpdateParameters);
5062
5067
  }
5063
5068
  initialize(panel) {
5064
5069
  this.panelUpdatesDisposable.value = this._onUpdateParameters.event((parameters) => {
@@ -5067,8 +5072,8 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5067
5072
  });
5068
5073
  });
5069
5074
  }
5070
- setHidden(isHidden) {
5071
- this._onDidHiddenChange.fire({ isHidden });
5075
+ setVisible(isVisible) {
5076
+ this._onWillVisibilityChange.fire({ isVisible });
5072
5077
  }
5073
5078
  setActive() {
5074
5079
  this._onActiveChange.fire();
@@ -5286,7 +5291,11 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5286
5291
  this._onDidChangeExpansionState.fire(this.isExpanded()); // initialize value
5287
5292
  this._orientation = orientation;
5288
5293
  this.element.classList.add('pane');
5289
- this.addDisposables(this.api.onDidSizeChange((event) => {
5294
+ this.addDisposables(this.api.onWillVisibilityChange((event) => {
5295
+ const { isVisible } = event;
5296
+ const { accessor } = this._params;
5297
+ accessor.setVisible(this, isVisible);
5298
+ }), this.api.onDidSizeChange((event) => {
5290
5299
  this._onDidChange.fire({ size: event.size });
5291
5300
  }), addDisposableListener(this.element, 'mouseenter', (ev) => {
5292
5301
  this.api._onMouseEnter.fire(ev);
@@ -5590,10 +5599,10 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5590
5599
  this._maximumHeight = options.maximumHeight;
5591
5600
  }
5592
5601
  this.api.initialize(this); // TODO: required to by-pass 'super before this' requirement
5593
- this.addDisposables(this.api.onDidHiddenChange((event) => {
5594
- const { isHidden } = event;
5602
+ this.addDisposables(this.api.onWillVisibilityChange((event) => {
5603
+ const { isVisible } = event;
5595
5604
  const { accessor } = this._params;
5596
- accessor.setVisible(this, !isHidden);
5605
+ accessor.setVisible(this, isVisible);
5597
5606
  }), this.api.onActiveChange(() => {
5598
5607
  const { accessor } = this._params;
5599
5608
  accessor.doSetGroupActive(this);
@@ -5834,32 +5843,11 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5834
5843
  return this.panel.renderer;
5835
5844
  }
5836
5845
  set group(value) {
5837
- const isOldGroupActive = this.isGroupActive;
5846
+ const oldGroup = this._group;
5838
5847
  if (this._group !== value) {
5839
5848
  this._group = value;
5840
5849
  this._onDidGroupChange.fire({});
5841
- let _trackGroupActive = isOldGroupActive; // prevent duplicate events with same state
5842
- this.groupEventsDisposable.value = new CompositeDisposable(this.group.api.onDidLocationChange((event) => {
5843
- if (this.group !== this.panel.group) {
5844
- return;
5845
- }
5846
- this._onDidLocationChange.fire(event);
5847
- }), this.group.api.onDidActiveChange(() => {
5848
- if (this.group !== this.panel.group) {
5849
- return;
5850
- }
5851
- if (_trackGroupActive !== this.isGroupActive) {
5852
- _trackGroupActive = this.isGroupActive;
5853
- this._onDidActiveGroupChange.fire({
5854
- isActive: this.isGroupActive,
5855
- });
5856
- }
5857
- }));
5858
- // if (this.isGroupActive !== isOldGroupActive) {
5859
- // this._onDidActiveGroupChange.fire({
5860
- // isActive: this.isGroupActive,
5861
- // });
5862
- // }
5850
+ this.setupGroupEventListeners(oldGroup);
5863
5851
  this._onDidLocationChange.fire({
5864
5852
  location: this.group.api.location,
5865
5853
  });
@@ -5885,6 +5873,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5885
5873
  this.groupEventsDisposable = new MutableDisposable();
5886
5874
  this.initialize(panel);
5887
5875
  this._group = group;
5876
+ this.setupGroupEventListeners();
5888
5877
  this.addDisposables(this.groupEventsDisposable, this._onDidRendererChange, this._onDidTitleChange, this._onDidGroupChange, this._onDidActiveGroupChange, this._onDidLocationChange);
5889
5878
  }
5890
5879
  getWindow() {
@@ -5919,6 +5908,35 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5919
5908
  exitMaximized() {
5920
5909
  this.group.api.exitMaximized();
5921
5910
  }
5911
+ setupGroupEventListeners(previousGroup) {
5912
+ var _a;
5913
+ let _trackGroupActive = (_a = previousGroup === null || previousGroup === void 0 ? void 0 : previousGroup.isActive) !== null && _a !== void 0 ? _a : false; // prevent duplicate events with same state
5914
+ this.groupEventsDisposable.value = new CompositeDisposable(this.group.api.onDidVisibilityChange((event) => {
5915
+ if (!event.isVisible && this.isVisible) {
5916
+ this._onDidVisibilityChange.fire(event);
5917
+ }
5918
+ else if (event.isVisible &&
5919
+ !this.isVisible &&
5920
+ this.group.model.isPanelActive(this.panel)) {
5921
+ this._onDidVisibilityChange.fire(event);
5922
+ }
5923
+ }), this.group.api.onDidLocationChange((event) => {
5924
+ if (this.group !== this.panel.group) {
5925
+ return;
5926
+ }
5927
+ this._onDidLocationChange.fire(event);
5928
+ }), this.group.api.onDidActiveChange(() => {
5929
+ if (this.group !== this.panel.group) {
5930
+ return;
5931
+ }
5932
+ if (_trackGroupActive !== this.isGroupActive) {
5933
+ _trackGroupActive = this.isGroupActive;
5934
+ this._onDidActiveGroupChange.fire({
5935
+ isActive: this.isGroupActive,
5936
+ });
5937
+ }
5938
+ }));
5939
+ }
5922
5940
  }
5923
5941
 
5924
5942
  class DockviewPanel extends CompositeDisposable {
@@ -7076,7 +7094,15 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7076
7094
  acceptedTargetZones: ['top', 'bottom', 'left', 'right', 'center'],
7077
7095
  overlayModel: (_b = this.options.rootOverlayModel) !== null && _b !== void 0 ? _b : DEFAULT_ROOT_OVERLAY_MODEL,
7078
7096
  });
7079
- this.addDisposables(this._rootDropTarget.onDrop((event) => {
7097
+ this.addDisposables(this._rootDropTarget, this._rootDropTarget.onWillShowOverlay((event) => {
7098
+ if (this.gridview.length > 0 && event.position === 'center') {
7099
+ // option only available when no panels in primary grid
7100
+ return;
7101
+ }
7102
+ this._onWillShowOverlay.fire(new WillShowOverlayLocationEvent(event, {
7103
+ kind: 'edge',
7104
+ }));
7105
+ }), this._rootDropTarget.onDrop((event) => {
7080
7106
  var _a;
7081
7107
  const willDropEvent = new DockviewWillDropEvent({
7082
7108
  nativeEvent: event.nativeEvent,
@@ -7085,7 +7111,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7085
7111
  api: this._api,
7086
7112
  group: undefined,
7087
7113
  getData: getPanelData,
7088
- kind: 'content',
7114
+ kind: 'edge',
7089
7115
  });
7090
7116
  this._onWillDrop.fire(willDropEvent);
7091
7117
  if (willDropEvent.defaultPrevented) {
@@ -7141,7 +7167,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7141
7167
  const box = getBox();
7142
7168
  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;
7143
7169
  if (itemToPopout.api.location.type === 'grid') {
7144
- itemToPopout.api.setHidden(true);
7170
+ itemToPopout.api.setVisible(false);
7145
7171
  }
7146
7172
  const _window = new PopoutWindow(`${this.id}-${groupId}`, // unique id
7147
7173
  theme !== null && theme !== void 0 ? theme : '', {
@@ -7192,7 +7218,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7192
7218
  }));
7193
7219
  switch (referenceLocation) {
7194
7220
  case 'grid':
7195
- referenceGroup.api.setHidden(true);
7221
+ referenceGroup.api.setVisible(false);
7196
7222
  break;
7197
7223
  case 'floating':
7198
7224
  case 'popout':
@@ -7246,8 +7272,8 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7246
7272
  from: group,
7247
7273
  to: referenceGroup,
7248
7274
  }));
7249
- if (referenceGroup.api.isHidden) {
7250
- referenceGroup.api.setHidden(false);
7275
+ if (!referenceGroup.api.isVisible) {
7276
+ referenceGroup.api.setVisible(true);
7251
7277
  }
7252
7278
  if (this.getPanel(group.id)) {
7253
7279
  this.doRemoveGroup(group, {
@@ -7820,7 +7846,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7820
7846
  }
7821
7847
  updateWatermark() {
7822
7848
  var _a, _b;
7823
- if (this.groups.filter((x) => x.api.location.type === 'grid' && !x.api.isHidden).length === 0) {
7849
+ if (this.groups.filter((x) => x.api.location.type === 'grid' && x.api.isVisible).length === 0) {
7824
7850
  if (!this.watermark) {
7825
7851
  this.watermark = this.createWatermarkComponent();
7826
7852
  this.watermark.init({
@@ -8603,19 +8629,19 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
8603
8629
  const index = this.panels.indexOf(panel);
8604
8630
  this.splitview.setViewVisible(index, visible);
8605
8631
  }
8606
- setActive(view, skipFocus) {
8607
- this._activePanel = view;
8632
+ setActive(panel, skipFocus) {
8633
+ this._activePanel = panel;
8608
8634
  this.panels
8609
- .filter((v) => v !== view)
8635
+ .filter((v) => v !== panel)
8610
8636
  .forEach((v) => {
8611
8637
  v.api._onDidActiveChange.fire({ isActive: false });
8612
8638
  if (!skipFocus) {
8613
8639
  v.focus();
8614
8640
  }
8615
8641
  });
8616
- view.api._onDidActiveChange.fire({ isActive: true });
8642
+ panel.api._onDidActiveChange.fire({ isActive: true });
8617
8643
  if (!skipFocus) {
8618
- view.focus();
8644
+ panel.focus();
8619
8645
  }
8620
8646
  }
8621
8647
  removePanel(panel, sizing) {
@@ -8914,6 +8940,10 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
8914
8940
  });
8915
8941
  this.addDisposables(this._disposable);
8916
8942
  }
8943
+ setVisible(panel, visible) {
8944
+ const index = this.panels.indexOf(panel);
8945
+ this.paneview.setViewVisible(index, visible);
8946
+ }
8917
8947
  focus() {
8918
8948
  //noop
8919
8949
  }
@@ -8960,6 +8990,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
8960
8990
  isExpanded: options.isExpanded,
8961
8991
  title: options.title,
8962
8992
  containerApi: new PaneviewApi(this),
8993
+ accessor: this,
8963
8994
  });
8964
8995
  this.paneview.addPane(view, size, index);
8965
8996
  view.orientation = this.paneview.orientation;
@@ -9059,6 +9090,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
9059
9090
  title: data.title,
9060
9091
  isExpanded: !!view.expanded,
9061
9092
  containerApi: new PaneviewApi(this),
9093
+ accessor: this,
9062
9094
  });
9063
9095
  panel.orientation = this.paneview.orientation;
9064
9096
  });
@@ -9147,10 +9179,10 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
9147
9179
  this._onDidChange = new Emitter();
9148
9180
  this.onDidChange = this._onDidChange.event;
9149
9181
  this.api.initialize(this);
9150
- this.addDisposables(this._onDidChange, this.api.onDidHiddenChange((event) => {
9151
- const { isHidden } = event;
9182
+ this.addDisposables(this._onDidChange, this.api.onWillVisibilityChange((event) => {
9183
+ const { isVisible } = event;
9152
9184
  const { accessor } = this._params;
9153
- accessor.setVisible(this, !isHidden);
9185
+ accessor.setVisible(this, isVisible);
9154
9186
  }), this.api.onActiveChange(() => {
9155
9187
  const { accessor } = this._params;
9156
9188
  accessor.setActive(this);