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
  */
@@ -1479,6 +1479,9 @@ class Paneview extends CompositeDisposable {
1479
1479
  this._onDidChange.fire();
1480
1480
  }));
1481
1481
  }
1482
+ setViewVisible(index, visible) {
1483
+ this.splitview.setViewVisible(index, visible);
1484
+ }
1482
1485
  addPane(pane, size, index = this.splitview.length, skipLayout = false) {
1483
1486
  const disposable = pane.onDidChangeExpansionState(() => {
1484
1487
  this.setupAnimation();
@@ -2983,19 +2986,27 @@ class DockviewApi {
2983
2986
  return this.component.onWillDrop;
2984
2987
  }
2985
2988
  /**
2989
+ * Invoked before an overlay is shown indicating a drop target.
2986
2990
  *
2991
+ * Calling `event.preventDefault()` will prevent the overlay being shown and prevent
2992
+ * the any subsequent drop event.
2987
2993
  */
2988
2994
  get onWillShowOverlay() {
2989
2995
  return this.component.onWillShowOverlay;
2990
2996
  }
2991
2997
  /**
2992
- * Invoked before a group is dragged. Exposed for custom Drag'n'Drop functionality.
2998
+ * Invoked before a group is dragged.
2999
+ *
3000
+ * Calling `event.nativeEvent.preventDefault()` will prevent the group drag starting.
3001
+ *
2993
3002
  */
2994
3003
  get onWillDragGroup() {
2995
3004
  return this.component.onWillDragGroup;
2996
3005
  }
2997
3006
  /**
2998
- * Invoked before a panel is dragged. Exposed for custom Drag'n'Drop functionality.
3007
+ * Invoked before a panel is dragged.
3008
+ *
3009
+ * Calling `event.nativeEvent.preventDefault()` will prevent the panel drag starting.
2999
3010
  */
3000
3011
  get onWillDragPanel() {
3001
3012
  return this.component.onWillDragPanel;
@@ -3539,7 +3550,7 @@ class ContentContainer extends CompositeDisposable {
3539
3550
  data.groupId === this.group.id;
3540
3551
  return !groupHasOnePanelAndIsActiveDragElement;
3541
3552
  }
3542
- return this.group.canDisplayOverlay(event, position, 'panel');
3553
+ return this.group.canDisplayOverlay(event, position, 'content');
3543
3554
  },
3544
3555
  });
3545
3556
  this.addDisposables(this.dropTarget);
@@ -3862,7 +3873,7 @@ class VoidContainer extends CompositeDisposable {
3862
3873
  // don't show the overlay if the tab being dragged is the last panel of this group
3863
3874
  return ((_a = last(this.group.panels)) === null || _a === void 0 ? void 0 : _a.id) !== data.panelId;
3864
3875
  }
3865
- return group.model.canDisplayOverlay(event, position, 'panel');
3876
+ return group.model.canDisplayOverlay(event, position, 'header_space');
3866
3877
  },
3867
3878
  });
3868
3879
  this.onWillShowOverlay = this.dropTraget.onWillShowOverlay;
@@ -4991,9 +5002,6 @@ class PanelApiImpl extends CompositeDisposable {
4991
5002
  get isVisible() {
4992
5003
  return this._isVisible;
4993
5004
  }
4994
- get isHidden() {
4995
- return this._isHidden;
4996
- }
4997
5005
  get width() {
4998
5006
  return this._width;
4999
5007
  }
@@ -5006,7 +5014,6 @@ class PanelApiImpl extends CompositeDisposable {
5006
5014
  this._isFocused = false;
5007
5015
  this._isActive = false;
5008
5016
  this._isVisible = true;
5009
- this._isHidden = false;
5010
5017
  this._width = 0;
5011
5018
  this._height = 0;
5012
5019
  this.panelUpdatesDisposable = new MutableDisposable();
@@ -5020,8 +5027,8 @@ class PanelApiImpl extends CompositeDisposable {
5020
5027
  //
5021
5028
  this._onDidVisibilityChange = new Emitter();
5022
5029
  this.onDidVisibilityChange = this._onDidVisibilityChange.event;
5023
- this._onDidHiddenChange = new Emitter();
5024
- this.onDidHiddenChange = this._onDidHiddenChange.event;
5030
+ this._onWillVisibilityChange = new Emitter();
5031
+ this.onWillVisibilityChange = this._onWillVisibilityChange.event;
5025
5032
  this._onDidActiveChange = new Emitter();
5026
5033
  this.onDidActiveChange = this._onDidActiveChange.event;
5027
5034
  this._onActiveChange = new Emitter();
@@ -5034,12 +5041,10 @@ class PanelApiImpl extends CompositeDisposable {
5034
5041
  this._isActive = event.isActive;
5035
5042
  }), this.onDidVisibilityChange((event) => {
5036
5043
  this._isVisible = event.isVisible;
5037
- }), this.onDidHiddenChange((event) => {
5038
- this._isHidden = event.isHidden;
5039
5044
  }), this.onDidDimensionsChange((event) => {
5040
5045
  this._width = event.width;
5041
5046
  this._height = event.height;
5042
- }), this.panelUpdatesDisposable, this._onDidDimensionChange, this._onDidChangeFocus, this._onDidVisibilityChange, this._onDidActiveChange, this._onWillFocus, this._onActiveChange, this._onUpdateParameters, this._onWillFocus, this._onDidHiddenChange, this._onUpdateParameters);
5047
+ }), this.panelUpdatesDisposable, this._onDidDimensionChange, this._onDidChangeFocus, this._onDidVisibilityChange, this._onDidActiveChange, this._onWillFocus, this._onActiveChange, this._onUpdateParameters, this._onWillFocus, this._onWillVisibilityChange, this._onUpdateParameters);
5043
5048
  }
5044
5049
  initialize(panel) {
5045
5050
  this.panelUpdatesDisposable.value = this._onUpdateParameters.event((parameters) => {
@@ -5048,8 +5053,8 @@ class PanelApiImpl extends CompositeDisposable {
5048
5053
  });
5049
5054
  });
5050
5055
  }
5051
- setHidden(isHidden) {
5052
- this._onDidHiddenChange.fire({ isHidden });
5056
+ setVisible(isVisible) {
5057
+ this._onWillVisibilityChange.fire({ isVisible });
5053
5058
  }
5054
5059
  setActive() {
5055
5060
  this._onActiveChange.fire();
@@ -5267,7 +5272,11 @@ class PaneviewPanel extends BasePanelView {
5267
5272
  this._onDidChangeExpansionState.fire(this.isExpanded()); // initialize value
5268
5273
  this._orientation = orientation;
5269
5274
  this.element.classList.add('pane');
5270
- this.addDisposables(this.api.onDidSizeChange((event) => {
5275
+ this.addDisposables(this.api.onWillVisibilityChange((event) => {
5276
+ const { isVisible } = event;
5277
+ const { accessor } = this._params;
5278
+ accessor.setVisible(this, isVisible);
5279
+ }), this.api.onDidSizeChange((event) => {
5271
5280
  this._onDidChange.fire({ size: event.size });
5272
5281
  }), addDisposableListener(this.element, 'mouseenter', (ev) => {
5273
5282
  this.api._onMouseEnter.fire(ev);
@@ -5571,10 +5580,10 @@ class GridviewPanel extends BasePanelView {
5571
5580
  this._maximumHeight = options.maximumHeight;
5572
5581
  }
5573
5582
  this.api.initialize(this); // TODO: required to by-pass 'super before this' requirement
5574
- this.addDisposables(this.api.onDidHiddenChange((event) => {
5575
- const { isHidden } = event;
5583
+ this.addDisposables(this.api.onWillVisibilityChange((event) => {
5584
+ const { isVisible } = event;
5576
5585
  const { accessor } = this._params;
5577
- accessor.setVisible(this, !isHidden);
5586
+ accessor.setVisible(this, isVisible);
5578
5587
  }), this.api.onActiveChange(() => {
5579
5588
  const { accessor } = this._params;
5580
5589
  accessor.doSetGroupActive(this);
@@ -5815,32 +5824,11 @@ class DockviewPanelApiImpl extends GridviewPanelApiImpl {
5815
5824
  return this.panel.renderer;
5816
5825
  }
5817
5826
  set group(value) {
5818
- const isOldGroupActive = this.isGroupActive;
5827
+ const oldGroup = this._group;
5819
5828
  if (this._group !== value) {
5820
5829
  this._group = value;
5821
5830
  this._onDidGroupChange.fire({});
5822
- let _trackGroupActive = isOldGroupActive; // prevent duplicate events with same state
5823
- this.groupEventsDisposable.value = new CompositeDisposable(this.group.api.onDidLocationChange((event) => {
5824
- if (this.group !== this.panel.group) {
5825
- return;
5826
- }
5827
- this._onDidLocationChange.fire(event);
5828
- }), this.group.api.onDidActiveChange(() => {
5829
- if (this.group !== this.panel.group) {
5830
- return;
5831
- }
5832
- if (_trackGroupActive !== this.isGroupActive) {
5833
- _trackGroupActive = this.isGroupActive;
5834
- this._onDidActiveGroupChange.fire({
5835
- isActive: this.isGroupActive,
5836
- });
5837
- }
5838
- }));
5839
- // if (this.isGroupActive !== isOldGroupActive) {
5840
- // this._onDidActiveGroupChange.fire({
5841
- // isActive: this.isGroupActive,
5842
- // });
5843
- // }
5831
+ this.setupGroupEventListeners(oldGroup);
5844
5832
  this._onDidLocationChange.fire({
5845
5833
  location: this.group.api.location,
5846
5834
  });
@@ -5866,6 +5854,7 @@ class DockviewPanelApiImpl extends GridviewPanelApiImpl {
5866
5854
  this.groupEventsDisposable = new MutableDisposable();
5867
5855
  this.initialize(panel);
5868
5856
  this._group = group;
5857
+ this.setupGroupEventListeners();
5869
5858
  this.addDisposables(this.groupEventsDisposable, this._onDidRendererChange, this._onDidTitleChange, this._onDidGroupChange, this._onDidActiveGroupChange, this._onDidLocationChange);
5870
5859
  }
5871
5860
  getWindow() {
@@ -5900,6 +5889,35 @@ class DockviewPanelApiImpl extends GridviewPanelApiImpl {
5900
5889
  exitMaximized() {
5901
5890
  this.group.api.exitMaximized();
5902
5891
  }
5892
+ setupGroupEventListeners(previousGroup) {
5893
+ var _a;
5894
+ let _trackGroupActive = (_a = previousGroup === null || previousGroup === void 0 ? void 0 : previousGroup.isActive) !== null && _a !== void 0 ? _a : false; // prevent duplicate events with same state
5895
+ this.groupEventsDisposable.value = new CompositeDisposable(this.group.api.onDidVisibilityChange((event) => {
5896
+ if (!event.isVisible && this.isVisible) {
5897
+ this._onDidVisibilityChange.fire(event);
5898
+ }
5899
+ else if (event.isVisible &&
5900
+ !this.isVisible &&
5901
+ this.group.model.isPanelActive(this.panel)) {
5902
+ this._onDidVisibilityChange.fire(event);
5903
+ }
5904
+ }), this.group.api.onDidLocationChange((event) => {
5905
+ if (this.group !== this.panel.group) {
5906
+ return;
5907
+ }
5908
+ this._onDidLocationChange.fire(event);
5909
+ }), this.group.api.onDidActiveChange(() => {
5910
+ if (this.group !== this.panel.group) {
5911
+ return;
5912
+ }
5913
+ if (_trackGroupActive !== this.isGroupActive) {
5914
+ _trackGroupActive = this.isGroupActive;
5915
+ this._onDidActiveGroupChange.fire({
5916
+ isActive: this.isGroupActive,
5917
+ });
5918
+ }
5919
+ }));
5920
+ }
5903
5921
  }
5904
5922
 
5905
5923
  class DockviewPanel extends CompositeDisposable {
@@ -7057,7 +7075,15 @@ class DockviewComponent extends BaseGrid {
7057
7075
  acceptedTargetZones: ['top', 'bottom', 'left', 'right', 'center'],
7058
7076
  overlayModel: (_b = this.options.rootOverlayModel) !== null && _b !== void 0 ? _b : DEFAULT_ROOT_OVERLAY_MODEL,
7059
7077
  });
7060
- this.addDisposables(this._rootDropTarget.onDrop((event) => {
7078
+ this.addDisposables(this._rootDropTarget, this._rootDropTarget.onWillShowOverlay((event) => {
7079
+ if (this.gridview.length > 0 && event.position === 'center') {
7080
+ // option only available when no panels in primary grid
7081
+ return;
7082
+ }
7083
+ this._onWillShowOverlay.fire(new WillShowOverlayLocationEvent(event, {
7084
+ kind: 'edge',
7085
+ }));
7086
+ }), this._rootDropTarget.onDrop((event) => {
7061
7087
  var _a;
7062
7088
  const willDropEvent = new DockviewWillDropEvent({
7063
7089
  nativeEvent: event.nativeEvent,
@@ -7066,7 +7092,7 @@ class DockviewComponent extends BaseGrid {
7066
7092
  api: this._api,
7067
7093
  group: undefined,
7068
7094
  getData: getPanelData,
7069
- kind: 'content',
7095
+ kind: 'edge',
7070
7096
  });
7071
7097
  this._onWillDrop.fire(willDropEvent);
7072
7098
  if (willDropEvent.defaultPrevented) {
@@ -7122,7 +7148,7 @@ class DockviewComponent extends BaseGrid {
7122
7148
  const box = getBox();
7123
7149
  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;
7124
7150
  if (itemToPopout.api.location.type === 'grid') {
7125
- itemToPopout.api.setHidden(true);
7151
+ itemToPopout.api.setVisible(false);
7126
7152
  }
7127
7153
  const _window = new PopoutWindow(`${this.id}-${groupId}`, // unique id
7128
7154
  theme !== null && theme !== void 0 ? theme : '', {
@@ -7173,7 +7199,7 @@ class DockviewComponent extends BaseGrid {
7173
7199
  }));
7174
7200
  switch (referenceLocation) {
7175
7201
  case 'grid':
7176
- referenceGroup.api.setHidden(true);
7202
+ referenceGroup.api.setVisible(false);
7177
7203
  break;
7178
7204
  case 'floating':
7179
7205
  case 'popout':
@@ -7227,8 +7253,8 @@ class DockviewComponent extends BaseGrid {
7227
7253
  from: group,
7228
7254
  to: referenceGroup,
7229
7255
  }));
7230
- if (referenceGroup.api.isHidden) {
7231
- referenceGroup.api.setHidden(false);
7256
+ if (!referenceGroup.api.isVisible) {
7257
+ referenceGroup.api.setVisible(true);
7232
7258
  }
7233
7259
  if (this.getPanel(group.id)) {
7234
7260
  this.doRemoveGroup(group, {
@@ -7801,7 +7827,7 @@ class DockviewComponent extends BaseGrid {
7801
7827
  }
7802
7828
  updateWatermark() {
7803
7829
  var _a, _b;
7804
- if (this.groups.filter((x) => x.api.location.type === 'grid' && !x.api.isHidden).length === 0) {
7830
+ if (this.groups.filter((x) => x.api.location.type === 'grid' && x.api.isVisible).length === 0) {
7805
7831
  if (!this.watermark) {
7806
7832
  this.watermark = this.createWatermarkComponent();
7807
7833
  this.watermark.init({
@@ -8584,19 +8610,19 @@ class SplitviewComponent extends Resizable {
8584
8610
  const index = this.panels.indexOf(panel);
8585
8611
  this.splitview.setViewVisible(index, visible);
8586
8612
  }
8587
- setActive(view, skipFocus) {
8588
- this._activePanel = view;
8613
+ setActive(panel, skipFocus) {
8614
+ this._activePanel = panel;
8589
8615
  this.panels
8590
- .filter((v) => v !== view)
8616
+ .filter((v) => v !== panel)
8591
8617
  .forEach((v) => {
8592
8618
  v.api._onDidActiveChange.fire({ isActive: false });
8593
8619
  if (!skipFocus) {
8594
8620
  v.focus();
8595
8621
  }
8596
8622
  });
8597
- view.api._onDidActiveChange.fire({ isActive: true });
8623
+ panel.api._onDidActiveChange.fire({ isActive: true });
8598
8624
  if (!skipFocus) {
8599
- view.focus();
8625
+ panel.focus();
8600
8626
  }
8601
8627
  }
8602
8628
  removePanel(panel, sizing) {
@@ -8895,6 +8921,10 @@ class PaneviewComponent extends Resizable {
8895
8921
  });
8896
8922
  this.addDisposables(this._disposable);
8897
8923
  }
8924
+ setVisible(panel, visible) {
8925
+ const index = this.panels.indexOf(panel);
8926
+ this.paneview.setViewVisible(index, visible);
8927
+ }
8898
8928
  focus() {
8899
8929
  //noop
8900
8930
  }
@@ -8941,6 +8971,7 @@ class PaneviewComponent extends Resizable {
8941
8971
  isExpanded: options.isExpanded,
8942
8972
  title: options.title,
8943
8973
  containerApi: new PaneviewApi(this),
8974
+ accessor: this,
8944
8975
  });
8945
8976
  this.paneview.addPane(view, size, index);
8946
8977
  view.orientation = this.paneview.orientation;
@@ -9040,6 +9071,7 @@ class PaneviewComponent extends Resizable {
9040
9071
  title: data.title,
9041
9072
  isExpanded: !!view.expanded,
9042
9073
  containerApi: new PaneviewApi(this),
9074
+ accessor: this,
9043
9075
  });
9044
9076
  panel.orientation = this.paneview.orientation;
9045
9077
  });
@@ -9128,10 +9160,10 @@ class SplitviewPanel extends BasePanelView {
9128
9160
  this._onDidChange = new Emitter();
9129
9161
  this.onDidChange = this._onDidChange.event;
9130
9162
  this.api.initialize(this);
9131
- this.addDisposables(this._onDidChange, this.api.onDidHiddenChange((event) => {
9132
- const { isHidden } = event;
9163
+ this.addDisposables(this._onDidChange, this.api.onWillVisibilityChange((event) => {
9164
+ const { isVisible } = event;
9133
9165
  const { accessor } = this._params;
9134
- accessor.setVisible(this, !isHidden);
9166
+ accessor.setVisible(this, isVisible);
9135
9167
  }), this.api.onActiveChange(() => {
9136
9168
  const { accessor } = this._params;
9137
9169
  accessor.setActive(this);