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
  */
@@ -1501,6 +1501,9 @@ class Paneview extends CompositeDisposable {
1501
1501
  this._onDidChange.fire();
1502
1502
  }));
1503
1503
  }
1504
+ setViewVisible(index, visible) {
1505
+ this.splitview.setViewVisible(index, visible);
1506
+ }
1504
1507
  addPane(pane, size, index = this.splitview.length, skipLayout = false) {
1505
1508
  const disposable = pane.onDidChangeExpansionState(() => {
1506
1509
  this.setupAnimation();
@@ -3005,19 +3008,27 @@ class DockviewApi {
3005
3008
  return this.component.onWillDrop;
3006
3009
  }
3007
3010
  /**
3011
+ * Invoked before an overlay is shown indicating a drop target.
3008
3012
  *
3013
+ * Calling `event.preventDefault()` will prevent the overlay being shown and prevent
3014
+ * the any subsequent drop event.
3009
3015
  */
3010
3016
  get onWillShowOverlay() {
3011
3017
  return this.component.onWillShowOverlay;
3012
3018
  }
3013
3019
  /**
3014
- * Invoked before a group is dragged. Exposed for custom Drag'n'Drop functionality.
3020
+ * Invoked before a group is dragged.
3021
+ *
3022
+ * Calling `event.nativeEvent.preventDefault()` will prevent the group drag starting.
3023
+ *
3015
3024
  */
3016
3025
  get onWillDragGroup() {
3017
3026
  return this.component.onWillDragGroup;
3018
3027
  }
3019
3028
  /**
3020
- * Invoked before a panel is dragged. Exposed for custom Drag'n'Drop functionality.
3029
+ * Invoked before a panel is dragged.
3030
+ *
3031
+ * Calling `event.nativeEvent.preventDefault()` will prevent the panel drag starting.
3021
3032
  */
3022
3033
  get onWillDragPanel() {
3023
3034
  return this.component.onWillDragPanel;
@@ -3561,7 +3572,7 @@ class ContentContainer extends CompositeDisposable {
3561
3572
  data.groupId === this.group.id;
3562
3573
  return !groupHasOnePanelAndIsActiveDragElement;
3563
3574
  }
3564
- return this.group.canDisplayOverlay(event, position, 'panel');
3575
+ return this.group.canDisplayOverlay(event, position, 'content');
3565
3576
  },
3566
3577
  });
3567
3578
  this.addDisposables(this.dropTarget);
@@ -3884,7 +3895,7 @@ class VoidContainer extends CompositeDisposable {
3884
3895
  // don't show the overlay if the tab being dragged is the last panel of this group
3885
3896
  return ((_a = last(this.group.panels)) === null || _a === void 0 ? void 0 : _a.id) !== data.panelId;
3886
3897
  }
3887
- return group.model.canDisplayOverlay(event, position, 'panel');
3898
+ return group.model.canDisplayOverlay(event, position, 'header_space');
3888
3899
  },
3889
3900
  });
3890
3901
  this.onWillShowOverlay = this.dropTraget.onWillShowOverlay;
@@ -5013,9 +5024,6 @@ class PanelApiImpl extends CompositeDisposable {
5013
5024
  get isVisible() {
5014
5025
  return this._isVisible;
5015
5026
  }
5016
- get isHidden() {
5017
- return this._isHidden;
5018
- }
5019
5027
  get width() {
5020
5028
  return this._width;
5021
5029
  }
@@ -5028,7 +5036,6 @@ class PanelApiImpl extends CompositeDisposable {
5028
5036
  this._isFocused = false;
5029
5037
  this._isActive = false;
5030
5038
  this._isVisible = true;
5031
- this._isHidden = false;
5032
5039
  this._width = 0;
5033
5040
  this._height = 0;
5034
5041
  this.panelUpdatesDisposable = new MutableDisposable();
@@ -5042,8 +5049,8 @@ class PanelApiImpl extends CompositeDisposable {
5042
5049
  //
5043
5050
  this._onDidVisibilityChange = new Emitter();
5044
5051
  this.onDidVisibilityChange = this._onDidVisibilityChange.event;
5045
- this._onDidHiddenChange = new Emitter();
5046
- this.onDidHiddenChange = this._onDidHiddenChange.event;
5052
+ this._onWillVisibilityChange = new Emitter();
5053
+ this.onWillVisibilityChange = this._onWillVisibilityChange.event;
5047
5054
  this._onDidActiveChange = new Emitter();
5048
5055
  this.onDidActiveChange = this._onDidActiveChange.event;
5049
5056
  this._onActiveChange = new Emitter();
@@ -5056,12 +5063,10 @@ class PanelApiImpl extends CompositeDisposable {
5056
5063
  this._isActive = event.isActive;
5057
5064
  }), this.onDidVisibilityChange((event) => {
5058
5065
  this._isVisible = event.isVisible;
5059
- }), this.onDidHiddenChange((event) => {
5060
- this._isHidden = event.isHidden;
5061
5066
  }), this.onDidDimensionsChange((event) => {
5062
5067
  this._width = event.width;
5063
5068
  this._height = event.height;
5064
- }), this.panelUpdatesDisposable, this._onDidDimensionChange, this._onDidChangeFocus, this._onDidVisibilityChange, this._onDidActiveChange, this._onWillFocus, this._onActiveChange, this._onUpdateParameters, this._onWillFocus, this._onDidHiddenChange, this._onUpdateParameters);
5069
+ }), this.panelUpdatesDisposable, this._onDidDimensionChange, this._onDidChangeFocus, this._onDidVisibilityChange, this._onDidActiveChange, this._onWillFocus, this._onActiveChange, this._onUpdateParameters, this._onWillFocus, this._onWillVisibilityChange, this._onUpdateParameters);
5065
5070
  }
5066
5071
  initialize(panel) {
5067
5072
  this.panelUpdatesDisposable.value = this._onUpdateParameters.event((parameters) => {
@@ -5070,8 +5075,8 @@ class PanelApiImpl extends CompositeDisposable {
5070
5075
  });
5071
5076
  });
5072
5077
  }
5073
- setHidden(isHidden) {
5074
- this._onDidHiddenChange.fire({ isHidden });
5078
+ setVisible(isVisible) {
5079
+ this._onWillVisibilityChange.fire({ isVisible });
5075
5080
  }
5076
5081
  setActive() {
5077
5082
  this._onActiveChange.fire();
@@ -5289,7 +5294,11 @@ class PaneviewPanel extends BasePanelView {
5289
5294
  this._onDidChangeExpansionState.fire(this.isExpanded()); // initialize value
5290
5295
  this._orientation = orientation;
5291
5296
  this.element.classList.add('pane');
5292
- this.addDisposables(this.api.onDidSizeChange((event) => {
5297
+ this.addDisposables(this.api.onWillVisibilityChange((event) => {
5298
+ const { isVisible } = event;
5299
+ const { accessor } = this._params;
5300
+ accessor.setVisible(this, isVisible);
5301
+ }), this.api.onDidSizeChange((event) => {
5293
5302
  this._onDidChange.fire({ size: event.size });
5294
5303
  }), addDisposableListener(this.element, 'mouseenter', (ev) => {
5295
5304
  this.api._onMouseEnter.fire(ev);
@@ -5593,10 +5602,10 @@ class GridviewPanel extends BasePanelView {
5593
5602
  this._maximumHeight = options.maximumHeight;
5594
5603
  }
5595
5604
  this.api.initialize(this); // TODO: required to by-pass 'super before this' requirement
5596
- this.addDisposables(this.api.onDidHiddenChange((event) => {
5597
- const { isHidden } = event;
5605
+ this.addDisposables(this.api.onWillVisibilityChange((event) => {
5606
+ const { isVisible } = event;
5598
5607
  const { accessor } = this._params;
5599
- accessor.setVisible(this, !isHidden);
5608
+ accessor.setVisible(this, isVisible);
5600
5609
  }), this.api.onActiveChange(() => {
5601
5610
  const { accessor } = this._params;
5602
5611
  accessor.doSetGroupActive(this);
@@ -5837,32 +5846,11 @@ class DockviewPanelApiImpl extends GridviewPanelApiImpl {
5837
5846
  return this.panel.renderer;
5838
5847
  }
5839
5848
  set group(value) {
5840
- const isOldGroupActive = this.isGroupActive;
5849
+ const oldGroup = this._group;
5841
5850
  if (this._group !== value) {
5842
5851
  this._group = value;
5843
5852
  this._onDidGroupChange.fire({});
5844
- let _trackGroupActive = isOldGroupActive; // prevent duplicate events with same state
5845
- this.groupEventsDisposable.value = new CompositeDisposable(this.group.api.onDidLocationChange((event) => {
5846
- if (this.group !== this.panel.group) {
5847
- return;
5848
- }
5849
- this._onDidLocationChange.fire(event);
5850
- }), this.group.api.onDidActiveChange(() => {
5851
- if (this.group !== this.panel.group) {
5852
- return;
5853
- }
5854
- if (_trackGroupActive !== this.isGroupActive) {
5855
- _trackGroupActive = this.isGroupActive;
5856
- this._onDidActiveGroupChange.fire({
5857
- isActive: this.isGroupActive,
5858
- });
5859
- }
5860
- }));
5861
- // if (this.isGroupActive !== isOldGroupActive) {
5862
- // this._onDidActiveGroupChange.fire({
5863
- // isActive: this.isGroupActive,
5864
- // });
5865
- // }
5853
+ this.setupGroupEventListeners(oldGroup);
5866
5854
  this._onDidLocationChange.fire({
5867
5855
  location: this.group.api.location,
5868
5856
  });
@@ -5888,6 +5876,7 @@ class DockviewPanelApiImpl extends GridviewPanelApiImpl {
5888
5876
  this.groupEventsDisposable = new MutableDisposable();
5889
5877
  this.initialize(panel);
5890
5878
  this._group = group;
5879
+ this.setupGroupEventListeners();
5891
5880
  this.addDisposables(this.groupEventsDisposable, this._onDidRendererChange, this._onDidTitleChange, this._onDidGroupChange, this._onDidActiveGroupChange, this._onDidLocationChange);
5892
5881
  }
5893
5882
  getWindow() {
@@ -5922,6 +5911,35 @@ class DockviewPanelApiImpl extends GridviewPanelApiImpl {
5922
5911
  exitMaximized() {
5923
5912
  this.group.api.exitMaximized();
5924
5913
  }
5914
+ setupGroupEventListeners(previousGroup) {
5915
+ var _a;
5916
+ let _trackGroupActive = (_a = previousGroup === null || previousGroup === void 0 ? void 0 : previousGroup.isActive) !== null && _a !== void 0 ? _a : false; // prevent duplicate events with same state
5917
+ this.groupEventsDisposable.value = new CompositeDisposable(this.group.api.onDidVisibilityChange((event) => {
5918
+ if (!event.isVisible && this.isVisible) {
5919
+ this._onDidVisibilityChange.fire(event);
5920
+ }
5921
+ else if (event.isVisible &&
5922
+ !this.isVisible &&
5923
+ this.group.model.isPanelActive(this.panel)) {
5924
+ this._onDidVisibilityChange.fire(event);
5925
+ }
5926
+ }), this.group.api.onDidLocationChange((event) => {
5927
+ if (this.group !== this.panel.group) {
5928
+ return;
5929
+ }
5930
+ this._onDidLocationChange.fire(event);
5931
+ }), this.group.api.onDidActiveChange(() => {
5932
+ if (this.group !== this.panel.group) {
5933
+ return;
5934
+ }
5935
+ if (_trackGroupActive !== this.isGroupActive) {
5936
+ _trackGroupActive = this.isGroupActive;
5937
+ this._onDidActiveGroupChange.fire({
5938
+ isActive: this.isGroupActive,
5939
+ });
5940
+ }
5941
+ }));
5942
+ }
5925
5943
  }
5926
5944
 
5927
5945
  class DockviewPanel extends CompositeDisposable {
@@ -7079,7 +7097,15 @@ class DockviewComponent extends BaseGrid {
7079
7097
  acceptedTargetZones: ['top', 'bottom', 'left', 'right', 'center'],
7080
7098
  overlayModel: (_b = this.options.rootOverlayModel) !== null && _b !== void 0 ? _b : DEFAULT_ROOT_OVERLAY_MODEL,
7081
7099
  });
7082
- this.addDisposables(this._rootDropTarget.onDrop((event) => {
7100
+ this.addDisposables(this._rootDropTarget, this._rootDropTarget.onWillShowOverlay((event) => {
7101
+ if (this.gridview.length > 0 && event.position === 'center') {
7102
+ // option only available when no panels in primary grid
7103
+ return;
7104
+ }
7105
+ this._onWillShowOverlay.fire(new WillShowOverlayLocationEvent(event, {
7106
+ kind: 'edge',
7107
+ }));
7108
+ }), this._rootDropTarget.onDrop((event) => {
7083
7109
  var _a;
7084
7110
  const willDropEvent = new DockviewWillDropEvent({
7085
7111
  nativeEvent: event.nativeEvent,
@@ -7088,7 +7114,7 @@ class DockviewComponent extends BaseGrid {
7088
7114
  api: this._api,
7089
7115
  group: undefined,
7090
7116
  getData: getPanelData,
7091
- kind: 'content',
7117
+ kind: 'edge',
7092
7118
  });
7093
7119
  this._onWillDrop.fire(willDropEvent);
7094
7120
  if (willDropEvent.defaultPrevented) {
@@ -7144,7 +7170,7 @@ class DockviewComponent extends BaseGrid {
7144
7170
  const box = getBox();
7145
7171
  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;
7146
7172
  if (itemToPopout.api.location.type === 'grid') {
7147
- itemToPopout.api.setHidden(true);
7173
+ itemToPopout.api.setVisible(false);
7148
7174
  }
7149
7175
  const _window = new PopoutWindow(`${this.id}-${groupId}`, // unique id
7150
7176
  theme !== null && theme !== void 0 ? theme : '', {
@@ -7195,7 +7221,7 @@ class DockviewComponent extends BaseGrid {
7195
7221
  }));
7196
7222
  switch (referenceLocation) {
7197
7223
  case 'grid':
7198
- referenceGroup.api.setHidden(true);
7224
+ referenceGroup.api.setVisible(false);
7199
7225
  break;
7200
7226
  case 'floating':
7201
7227
  case 'popout':
@@ -7249,8 +7275,8 @@ class DockviewComponent extends BaseGrid {
7249
7275
  from: group,
7250
7276
  to: referenceGroup,
7251
7277
  }));
7252
- if (referenceGroup.api.isHidden) {
7253
- referenceGroup.api.setHidden(false);
7278
+ if (!referenceGroup.api.isVisible) {
7279
+ referenceGroup.api.setVisible(true);
7254
7280
  }
7255
7281
  if (this.getPanel(group.id)) {
7256
7282
  this.doRemoveGroup(group, {
@@ -7823,7 +7849,7 @@ class DockviewComponent extends BaseGrid {
7823
7849
  }
7824
7850
  updateWatermark() {
7825
7851
  var _a, _b;
7826
- if (this.groups.filter((x) => x.api.location.type === 'grid' && !x.api.isHidden).length === 0) {
7852
+ if (this.groups.filter((x) => x.api.location.type === 'grid' && x.api.isVisible).length === 0) {
7827
7853
  if (!this.watermark) {
7828
7854
  this.watermark = this.createWatermarkComponent();
7829
7855
  this.watermark.init({
@@ -8606,19 +8632,19 @@ class SplitviewComponent extends Resizable {
8606
8632
  const index = this.panels.indexOf(panel);
8607
8633
  this.splitview.setViewVisible(index, visible);
8608
8634
  }
8609
- setActive(view, skipFocus) {
8610
- this._activePanel = view;
8635
+ setActive(panel, skipFocus) {
8636
+ this._activePanel = panel;
8611
8637
  this.panels
8612
- .filter((v) => v !== view)
8638
+ .filter((v) => v !== panel)
8613
8639
  .forEach((v) => {
8614
8640
  v.api._onDidActiveChange.fire({ isActive: false });
8615
8641
  if (!skipFocus) {
8616
8642
  v.focus();
8617
8643
  }
8618
8644
  });
8619
- view.api._onDidActiveChange.fire({ isActive: true });
8645
+ panel.api._onDidActiveChange.fire({ isActive: true });
8620
8646
  if (!skipFocus) {
8621
- view.focus();
8647
+ panel.focus();
8622
8648
  }
8623
8649
  }
8624
8650
  removePanel(panel, sizing) {
@@ -8917,6 +8943,10 @@ class PaneviewComponent extends Resizable {
8917
8943
  });
8918
8944
  this.addDisposables(this._disposable);
8919
8945
  }
8946
+ setVisible(panel, visible) {
8947
+ const index = this.panels.indexOf(panel);
8948
+ this.paneview.setViewVisible(index, visible);
8949
+ }
8920
8950
  focus() {
8921
8951
  //noop
8922
8952
  }
@@ -8963,6 +8993,7 @@ class PaneviewComponent extends Resizable {
8963
8993
  isExpanded: options.isExpanded,
8964
8994
  title: options.title,
8965
8995
  containerApi: new PaneviewApi(this),
8996
+ accessor: this,
8966
8997
  });
8967
8998
  this.paneview.addPane(view, size, index);
8968
8999
  view.orientation = this.paneview.orientation;
@@ -9062,6 +9093,7 @@ class PaneviewComponent extends Resizable {
9062
9093
  title: data.title,
9063
9094
  isExpanded: !!view.expanded,
9064
9095
  containerApi: new PaneviewApi(this),
9096
+ accessor: this,
9065
9097
  });
9066
9098
  panel.orientation = this.paneview.orientation;
9067
9099
  });
@@ -9150,10 +9182,10 @@ class SplitviewPanel extends BasePanelView {
9150
9182
  this._onDidChange = new Emitter();
9151
9183
  this.onDidChange = this._onDidChange.event;
9152
9184
  this.api.initialize(this);
9153
- this.addDisposables(this._onDidChange, this.api.onDidHiddenChange((event) => {
9154
- const { isHidden } = event;
9185
+ this.addDisposables(this._onDidChange, this.api.onWillVisibilityChange((event) => {
9186
+ const { isVisible } = event;
9155
9187
  const { accessor } = this._params;
9156
- accessor.setVisible(this, !isHidden);
9188
+ accessor.setVisible(this, isVisible);
9157
9189
  }), this.api.onActiveChange(() => {
9158
9190
  const { accessor } = this._params;
9159
9191
  accessor.setActive(this);