dockview-core 1.12.0 → 1.13.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.
Files changed (65) hide show
  1. package/dist/cjs/api/component.api.d.ts +2 -1
  2. package/dist/cjs/api/component.api.js +7 -0
  3. package/dist/cjs/api/dockviewGroupPanelApi.d.ts +5 -1
  4. package/dist/cjs/api/dockviewGroupPanelApi.js +19 -1
  5. package/dist/cjs/dnd/droptarget.d.ts +1 -1
  6. package/dist/cjs/dnd/droptarget.js +4 -10
  7. package/dist/cjs/dockview/components/panel/content.js +0 -8
  8. package/dist/cjs/dockview/dockviewComponent.d.ts +6 -4
  9. package/dist/cjs/dockview/dockviewComponent.js +71 -67
  10. package/dist/cjs/dockview/dockviewGroupPanelModel.d.ts +3 -0
  11. package/dist/cjs/dockview/dockviewGroupPanelModel.js +18 -19
  12. package/dist/cjs/dockview/dockviewPanelModel.js +21 -24
  13. package/dist/cjs/dockview/framework.d.ts +38 -0
  14. package/dist/cjs/dockview/framework.js +2 -0
  15. package/dist/cjs/dockview/options.d.ts +68 -46
  16. package/dist/cjs/dockview/options.js +43 -1
  17. package/dist/cjs/dockview/types.d.ts +4 -10
  18. package/dist/cjs/framwork.d.ts +4 -0
  19. package/dist/cjs/framwork.js +2 -0
  20. package/dist/cjs/index.d.ts +2 -1
  21. package/dist/cjs/index.js +1 -1
  22. package/dist/dockview-core.amd.js +1973 -1920
  23. package/dist/dockview-core.amd.js.map +1 -1
  24. package/dist/dockview-core.amd.min.js +2 -2
  25. package/dist/dockview-core.amd.min.js.map +1 -1
  26. package/dist/dockview-core.amd.min.noStyle.js +2 -2
  27. package/dist/dockview-core.amd.min.noStyle.js.map +1 -1
  28. package/dist/dockview-core.amd.noStyle.js +1973 -1920
  29. package/dist/dockview-core.amd.noStyle.js.map +1 -1
  30. package/dist/dockview-core.cjs.js +1973 -1920
  31. package/dist/dockview-core.cjs.js.map +1 -1
  32. package/dist/dockview-core.esm.js +1972 -1921
  33. package/dist/dockview-core.esm.js.map +1 -1
  34. package/dist/dockview-core.esm.min.js +2 -2
  35. package/dist/dockview-core.esm.min.js.map +1 -1
  36. package/dist/dockview-core.js +1973 -1920
  37. package/dist/dockview-core.js.map +1 -1
  38. package/dist/dockview-core.min.js +2 -2
  39. package/dist/dockview-core.min.js.map +1 -1
  40. package/dist/dockview-core.min.noStyle.js +2 -2
  41. package/dist/dockview-core.min.noStyle.js.map +1 -1
  42. package/dist/dockview-core.noStyle.js +1973 -1920
  43. package/dist/dockview-core.noStyle.js.map +1 -1
  44. package/dist/esm/api/component.api.d.ts +2 -1
  45. package/dist/esm/api/component.api.js +3 -0
  46. package/dist/esm/api/dockviewGroupPanelApi.d.ts +5 -1
  47. package/dist/esm/api/dockviewGroupPanelApi.js +18 -1
  48. package/dist/esm/dnd/droptarget.d.ts +1 -1
  49. package/dist/esm/dnd/droptarget.js +4 -10
  50. package/dist/esm/dockview/components/panel/content.js +0 -8
  51. package/dist/esm/dockview/dockviewComponent.d.ts +6 -4
  52. package/dist/esm/dockview/dockviewComponent.js +70 -68
  53. package/dist/esm/dockview/dockviewGroupPanelModel.d.ts +3 -0
  54. package/dist/esm/dockview/dockviewGroupPanelModel.js +18 -19
  55. package/dist/esm/dockview/dockviewPanelModel.js +21 -13
  56. package/dist/esm/dockview/framework.d.ts +38 -0
  57. package/dist/esm/dockview/framework.js +1 -0
  58. package/dist/esm/dockview/options.d.ts +68 -46
  59. package/dist/esm/dockview/options.js +36 -0
  60. package/dist/esm/dockview/types.d.ts +4 -10
  61. package/dist/esm/framwork.d.ts +4 -0
  62. package/dist/esm/framwork.js +1 -0
  63. package/dist/esm/index.d.ts +2 -1
  64. package/dist/esm/index.js +1 -1
  65. package/package.json +2 -2
@@ -1,5 +1,5 @@
1
1
  import { IDockviewComponent, SerializedDockview } from '../dockview/dockviewComponent';
2
- import { AddGroupOptions, AddPanelOptions, MovementOptions } from '../dockview/options';
2
+ import { AddGroupOptions, AddPanelOptions, DockviewDndOverlayEvent, MovementOptions } from '../dockview/options';
3
3
  import { Parameters } from '../panel/types';
4
4
  import { Direction } from '../gridview/baseComponentGridview';
5
5
  import { AddComponentOptions, IGridviewComponent, SerializedGridviewComponent } from '../gridview/gridviewComponent';
@@ -393,6 +393,7 @@ export declare class DockviewApi implements CommonApi<SerializedDockview> {
393
393
  * Calling `event.nativeEvent.preventDefault()` will prevent the panel drag starting.
394
394
  */
395
395
  get onWillDragPanel(): Event<TabDragEvent>;
396
+ get onUnhandledDragOverEvent(): Event<DockviewDndOverlayEvent>;
396
397
  /**
397
398
  * All panel objects.
398
399
  */
@@ -541,6 +541,9 @@ export class DockviewApi {
541
541
  get onWillDragPanel() {
542
542
  return this.component.onWillDragPanel;
543
543
  }
544
+ get onUnhandledDragOverEvent() {
545
+ return this.component.onUnhandledDragOverEvent;
546
+ }
544
547
  /**
545
548
  * All panel objects.
546
549
  */
@@ -1,11 +1,12 @@
1
1
  import { Position } from '../dnd/droptarget';
2
2
  import { DockviewComponent } from '../dockview/dockviewComponent';
3
3
  import { DockviewGroupPanel } from '../dockview/dockviewGroupPanel';
4
- import { DockviewGroupLocation } from '../dockview/dockviewGroupPanelModel';
4
+ import { DockviewGroupChangeEvent, DockviewGroupLocation } from '../dockview/dockviewGroupPanelModel';
5
5
  import { Emitter, Event } from '../events';
6
6
  import { GridviewPanelApi, GridviewPanelApiImpl } from './gridviewPanelApi';
7
7
  export interface DockviewGroupPanelApi extends GridviewPanelApi {
8
8
  readonly onDidLocationChange: Event<DockviewGroupPanelFloatingChangeEvent>;
9
+ readonly onDidActivePanelChange: Event<DockviewGroupChangeEvent>;
9
10
  readonly location: DockviewGroupLocation;
10
11
  /**
11
12
  * If you require the Window object
@@ -25,9 +26,12 @@ export interface DockviewGroupPanelFloatingChangeEvent {
25
26
  }
26
27
  export declare class DockviewGroupPanelApiImpl extends GridviewPanelApiImpl {
27
28
  private readonly accessor;
29
+ private readonly _mutableDisposable;
28
30
  private _group;
29
31
  readonly _onDidLocationChange: Emitter<DockviewGroupPanelFloatingChangeEvent>;
30
32
  readonly onDidLocationChange: Event<DockviewGroupPanelFloatingChangeEvent>;
33
+ private readonly _onDidActivePanelChange;
34
+ readonly onDidActivePanelChange: Event<DockviewGroupChangeEvent>;
31
35
  get location(): DockviewGroupLocation;
32
36
  constructor(id: string, accessor: DockviewComponent);
33
37
  close(): void;
@@ -1,5 +1,6 @@
1
1
  import { positionToDirection } from '../dnd/droptarget';
2
2
  import { Emitter } from '../events';
3
+ import { MutableDisposable } from '../lifecycle';
3
4
  import { GridviewPanelApiImpl } from './gridviewPanelApi';
4
5
  // TODO find a better way to initialize and avoid needing null checks
5
6
  const NOT_INITIALIZED_MESSAGE = 'DockviewGroupPanelApiImpl not initialized';
@@ -13,9 +14,12 @@ export class DockviewGroupPanelApiImpl extends GridviewPanelApiImpl {
13
14
  constructor(id, accessor) {
14
15
  super(id, '__dockviewgroup__');
15
16
  this.accessor = accessor;
17
+ this._mutableDisposable = new MutableDisposable();
16
18
  this._onDidLocationChange = new Emitter();
17
19
  this.onDidLocationChange = this._onDidLocationChange.event;
18
- this.addDisposables(this._onDidLocationChange);
20
+ this._onDidActivePanelChange = new Emitter();
21
+ this.onDidActivePanelChange = this._onDidActivePanelChange.event;
22
+ this.addDisposables(this._onDidLocationChange, this._onDidActivePanelChange, this._mutableDisposable);
19
23
  }
20
24
  close() {
21
25
  if (!this._group) {
@@ -73,5 +77,18 @@ export class DockviewGroupPanelApiImpl extends GridviewPanelApiImpl {
73
77
  }
74
78
  initialize(group) {
75
79
  this._group = group;
80
+ /**
81
+ * TODO: Annoying initialization order caveat
82
+ *
83
+ * Due to the order on initialization we know that the model isn't defined until later in the same stack-frame of setup.
84
+ * By queuing a microtask we can ensure the setup is completed within the same stack-frame, but after everything else has
85
+ * finished ensuring the `model` is defined.
86
+ */
87
+ queueMicrotask(() => {
88
+ this._mutableDisposable.value =
89
+ this._group.model.onDidActivePanelChange((event) => {
90
+ this._onDidActivePanelChange.fire(event);
91
+ });
92
+ });
76
93
  }
77
94
  }
@@ -18,7 +18,7 @@ export declare class WillShowOverlayEvent extends DockviewEvent implements Dropt
18
18
  export declare function directionToPosition(direction: Direction): Position;
19
19
  export declare function positionToDirection(position: Position): Direction;
20
20
  export type Position = 'top' | 'bottom' | 'left' | 'right' | 'center';
21
- export type CanDisplayOverlay = boolean | ((dragEvent: DragEvent, state: Position) => boolean);
21
+ export type CanDisplayOverlay = (dragEvent: DragEvent, state: Position) => boolean;
22
22
  export type MeasuredValue = {
23
23
  value: number;
24
24
  type: 'pixels' | 'percentage';
@@ -97,6 +97,10 @@ export class Droptarget extends CompositeDisposable {
97
97
  this.removeDropTarget();
98
98
  return;
99
99
  }
100
+ if (!this.options.canDisplayOverlay(e, quadrant)) {
101
+ this.removeDropTarget();
102
+ return;
103
+ }
100
104
  const willShowOverlayEvent = new WillShowOverlayEvent({
101
105
  nativeEvent: e,
102
106
  position: quadrant,
@@ -110,16 +114,6 @@ export class Droptarget extends CompositeDisposable {
110
114
  this.removeDropTarget();
111
115
  return;
112
116
  }
113
- if (typeof this.options.canDisplayOverlay === 'boolean') {
114
- if (!this.options.canDisplayOverlay) {
115
- this.removeDropTarget();
116
- return;
117
- }
118
- }
119
- else if (!this.options.canDisplayOverlay(e, quadrant)) {
120
- this.removeDropTarget();
121
- return;
122
- }
123
117
  this.markAsUsed(e);
124
118
  if (!this.targetElement) {
125
119
  this.targetElement = document.createElement('div');
@@ -92,17 +92,9 @@ export class ContentContainer extends CompositeDisposable {
92
92
  break;
93
93
  }
94
94
  if (doRender) {
95
- const _onDidFocus = panel.view.content.onDidFocus;
96
- const _onDidBlur = panel.view.content.onDidBlur;
97
95
  const focusTracker = trackFocus(container);
98
96
  const disposable = new CompositeDisposable();
99
97
  disposable.addDisposables(focusTracker, focusTracker.onDidFocus(() => this._onDidFocus.fire()), focusTracker.onDidBlur(() => this._onDidBlur.fire()));
100
- if (_onDidFocus) {
101
- disposable.addDisposables(_onDidFocus(() => this._onDidFocus.fire()));
102
- }
103
- if (_onDidBlur) {
104
- disposable.addDisposables(_onDidBlur(() => this._onDidBlur.fire()));
105
- }
106
98
  this.disposable.value = disposable;
107
99
  }
108
100
  }
@@ -3,7 +3,7 @@ import { Position } from '../dnd/droptarget';
3
3
  import { DockviewPanel, IDockviewPanel } from './dockviewPanel';
4
4
  import { Event, Emitter } from '../events';
5
5
  import { IWatermarkRenderer, GroupviewPanelState } from './types';
6
- import { AddGroupOptions, AddPanelOptions, DockviewComponentOptions, MovementOptions } from './options';
6
+ import { AddGroupOptions, AddPanelOptions, DockviewComponentOptions, DockviewDndOverlayEvent, DockviewOptions, MovementOptions } from './options';
7
7
  import { BaseGrid, IBaseGrid } from '../gridview/baseComponentGridview';
8
8
  import { DockviewApi } from '../api/component.api';
9
9
  import { Orientation } from '../splitview/splitview';
@@ -42,7 +42,6 @@ export interface SerializedDockview {
42
42
  floatingGroups?: SerializedFloatingGroup[];
43
43
  popoutGroups?: SerializedPopoutGroup[];
44
44
  }
45
- export type DockviewComponentUpdateOptions = Pick<DockviewComponentOptions, 'orientation' | 'components' | 'frameworkComponents' | 'tabComponents' | 'frameworkTabComponents' | 'showDndOverlay' | 'watermarkFrameworkComponent' | 'defaultTabComponent' | 'createLeftHeaderActionsElement' | 'createRightHeaderActionsElement' | 'createPrefixHeaderActionsElement' | 'disableFloatingGroups' | 'floatingGroupBounds' | 'rootOverlayModel' | 'disableDnd'>;
46
45
  type MoveGroupOptions = {
47
46
  from: {
48
47
  group: DockviewGroupPanel;
@@ -80,8 +79,9 @@ export interface IDockviewComponent extends IBaseGrid<DockviewGroupPanel> {
80
79
  readonly onDidRemoveGroup: Event<DockviewGroupPanel>;
81
80
  readonly onDidAddGroup: Event<DockviewGroupPanel>;
82
81
  readonly onDidActiveGroupChange: Event<DockviewGroupPanel | undefined>;
82
+ readonly onUnhandledDragOverEvent: Event<DockviewDndOverlayEvent>;
83
83
  readonly options: DockviewComponentOptions;
84
- updateOptions(options: DockviewComponentUpdateOptions): void;
84
+ updateOptions(options: DockviewOptions): void;
85
85
  moveGroupOrPanel(options: MoveGroupOrPanelOptions): void;
86
86
  moveGroup(options: MoveGroupOptions): void;
87
87
  doSetGroupActive: (group: DockviewGroupPanel, skipFocus?: boolean) => void;
@@ -132,6 +132,8 @@ export declare class DockviewComponent extends BaseGrid<DockviewGroupPanel> impl
132
132
  readonly onWillDrop: Event<DockviewWillDropEvent>;
133
133
  private readonly _onWillShowOverlay;
134
134
  readonly onWillShowOverlay: Event<WillShowOverlayLocationEvent>;
135
+ private readonly _onUnhandledDragOverEvent;
136
+ readonly onUnhandledDragOverEvent: Event<DockviewDndOverlayEvent>;
135
137
  private readonly _onDidRemovePanel;
136
138
  readonly onDidRemovePanel: Event<IDockviewPanel>;
137
139
  private readonly _onDidAddPanel;
@@ -184,7 +186,7 @@ export declare class DockviewComponent extends BaseGrid<DockviewGroupPanel> impl
184
186
  skipActiveGroup?: boolean;
185
187
  }): void;
186
188
  private orthogonalize;
187
- updateOptions(options: DockviewComponentUpdateOptions): void;
189
+ updateOptions(options: Partial<DockviewComponentOptions>): void;
188
190
  layout(width: number, height: number, forceResize?: boolean | undefined): void;
189
191
  focus(): void;
190
192
  getGroupPanel(id: string): IDockviewPanel | undefined;
@@ -7,8 +7,7 @@ import { Event, Emitter, addDisposableWindowListener } from '../events';
7
7
  import { Watermark } from './components/watermark/watermark';
8
8
  import { sequentialNumberGenerator } from '../math';
9
9
  import { DefaultDockviewDeserialzier } from './deserializer';
10
- import { createComponent } from '../panel/componentFactory';
11
- import { isGroupOptionsWithGroup, isGroupOptionsWithPanel, isPanelOptionsWithGroup, isPanelOptionsWithPanel, } from './options';
10
+ import { DockviewUnhandledDragOverEvent, isGroupOptionsWithGroup, isGroupOptionsWithPanel, isPanelOptionsWithGroup, isPanelOptionsWithPanel, } from './options';
12
11
  import { BaseGrid, toTarget, } from '../gridview/baseComponentGridview';
13
12
  import { DockviewApi } from '../api/component.api';
14
13
  import { Orientation, Sizing } from '../splitview/splitview';
@@ -147,11 +146,13 @@ export class DockviewComponent extends BaseGrid {
147
146
  return this._api;
148
147
  }
149
148
  constructor(options) {
150
- var _a, _b;
149
+ var _a;
151
150
  super({
152
151
  proportionalLayout: true,
153
- orientation: (_a = options.orientation) !== null && _a !== void 0 ? _a : Orientation.HORIZONTAL,
154
- styles: options.styles,
152
+ orientation: Orientation.HORIZONTAL,
153
+ styles: options.hideBorders
154
+ ? { separatorBorder: 'transparent' }
155
+ : undefined,
155
156
  parentElement: options.parentElement,
156
157
  disableAutoResizing: options.disableAutoResizing,
157
158
  locked: options.locked,
@@ -169,6 +170,8 @@ export class DockviewComponent extends BaseGrid {
169
170
  this.onWillDrop = this._onWillDrop.event;
170
171
  this._onWillShowOverlay = new Emitter();
171
172
  this.onWillShowOverlay = this._onWillShowOverlay.event;
173
+ this._onUnhandledDragOverEvent = new Emitter();
174
+ this.onUnhandledDragOverEvent = this._onUnhandledDragOverEvent.event;
172
175
  this._onDidRemovePanel = new Emitter();
173
176
  this.onDidRemovePanel = this._onDidRemovePanel.event;
174
177
  this._onDidAddPanel = new Emitter();
@@ -194,7 +197,7 @@ export class DockviewComponent extends BaseGrid {
194
197
  this.overlayRenderContainer = new OverlayRenderContainer(gready);
195
198
  toggleClass(this.gridview.element, 'dv-dockview', true);
196
199
  toggleClass(this.element, 'dv-debug', !!options.debug);
197
- this.addDisposables(this.overlayRenderContainer, this._onWillDragPanel, this._onWillDragGroup, this._onWillShowOverlay, this._onDidActivePanelChange, this._onDidAddPanel, this._onDidRemovePanel, this._onDidLayoutFromJSON, this._onDidDrop, this._onWillDrop, this._onDidMovePanel, this._onDidAddGroup, this._onDidRemoveGroup, this._onDidActiveGroupChange, this.onDidAdd((event) => {
200
+ this.addDisposables(this.overlayRenderContainer, this._onWillDragPanel, this._onWillDragGroup, this._onWillShowOverlay, this._onDidActivePanelChange, this._onDidAddPanel, this._onDidRemovePanel, this._onDidLayoutFromJSON, this._onDidDrop, this._onWillDrop, this._onDidMovePanel, this._onDidAddGroup, this._onDidRemoveGroup, this._onDidActiveGroupChange, this._onUnhandledDragOverEvent, this.onDidAdd((event) => {
198
201
  if (!this._moving) {
199
202
  this._onDidAddGroup.fire(event);
200
203
  }
@@ -221,22 +224,6 @@ export class DockviewComponent extends BaseGrid {
221
224
  }
222
225
  }));
223
226
  this._options = options;
224
- if (!this.options.components) {
225
- this.options.components = {};
226
- }
227
- if (!this.options.frameworkComponents) {
228
- this.options.frameworkComponents = {};
229
- }
230
- if (!this.options.frameworkTabComponents) {
231
- this.options.frameworkTabComponents = {};
232
- }
233
- if (!this.options.tabComponents) {
234
- this.options.tabComponents = {};
235
- }
236
- if (!this.options.watermarkComponent &&
237
- !this.options.watermarkFrameworkComponent) {
238
- this.options.watermarkComponent = Watermark;
239
- }
240
227
  this._rootDropTarget = new Droptarget(this.element, {
241
228
  canDisplayOverlay: (event, position) => {
242
229
  const data = getPanelData();
@@ -251,26 +238,20 @@ export class DockviewComponent extends BaseGrid {
251
238
  }
252
239
  return true;
253
240
  }
254
- if (this.options.showDndOverlay) {
255
- if (position === 'center' && this.gridview.length !== 0) {
256
- /**
257
- * for external events only show the four-corner drag overlays, disable
258
- * the center position so that external drag events can fall through to the group
259
- * and panel drop target handlers
260
- */
261
- return false;
262
- }
263
- return this.options.showDndOverlay({
264
- nativeEvent: event,
265
- position: position,
266
- target: 'edge',
267
- getData: getPanelData,
268
- });
241
+ if (position === 'center' && this.gridview.length !== 0) {
242
+ /**
243
+ * for external events only show the four-corner drag overlays, disable
244
+ * the center position so that external drag events can fall through to the group
245
+ * and panel drop target handlers
246
+ */
247
+ return false;
269
248
  }
270
- return false;
249
+ const firedEvent = new DockviewUnhandledDragOverEvent(event, 'edge', position, getPanelData);
250
+ this._onUnhandledDragOverEvent.fire(firedEvent);
251
+ return firedEvent.isAccepted;
271
252
  },
272
253
  acceptedTargetZones: ['top', 'bottom', 'left', 'right', 'center'],
273
- overlayModel: (_b = this.options.rootOverlayModel) !== null && _b !== void 0 ? _b : DEFAULT_ROOT_OVERLAY_MODEL,
254
+ overlayModel: (_a = this.options.rootOverlayModel) !== null && _a !== void 0 ? _a : DEFAULT_ROOT_OVERLAY_MODEL,
274
255
  });
275
256
  this.addDisposables(this._rootDropTarget, this._rootDropTarget.onWillShowOverlay((event) => {
276
257
  if (this.gridview.length > 0 && event.position === 'center') {
@@ -494,7 +475,7 @@ export class DockviewComponent extends BaseGrid {
494
475
  skipDispose: true,
495
476
  skipSetActiveGroup: true,
496
477
  }));
497
- group.model.openPanel(item, { skipSetGroupActive: true });
478
+ this.movingLock(() => group.model.openPanel(item, { skipSetGroupActive: true }));
498
479
  }
499
480
  else {
500
481
  group = item;
@@ -567,7 +548,7 @@ export class DockviewComponent extends BaseGrid {
567
548
  // this is either a resize or a move
568
549
  // to inform the panels .layout(...) the group with it's current size
569
550
  // don't care about resize since the above watcher handles that
570
- group.layout(group.height, group.width);
551
+ group.layout(group.width, group.height);
571
552
  }), overlay.onDidChangeEnd(() => {
572
553
  this._bufferOnDidLayoutChange.fire();
573
554
  }), group.onDidChange((event) => {
@@ -624,16 +605,11 @@ export class DockviewComponent extends BaseGrid {
624
605
  }
625
606
  updateOptions(options) {
626
607
  var _a, _b;
627
- const changed_orientation = typeof options.orientation === 'string' &&
628
- this.gridview.orientation !== options.orientation;
629
- const changed_floatingGroupBounds = options.floatingGroupBounds !== undefined &&
608
+ const changed_floatingGroupBounds = 'floatingGroupBounds' in options &&
630
609
  options.floatingGroupBounds !== this.options.floatingGroupBounds;
631
- const changed_rootOverlayOptions = options.rootOverlayModel !== undefined &&
610
+ const changed_rootOverlayOptions = 'rootOverlayModel' in options &&
632
611
  options.rootOverlayModel !== this.options.rootOverlayModel;
633
612
  this._options = Object.assign(Object.assign({}, this.options), options);
634
- if (changed_orientation) {
635
- this.gridview.orientation = options.orientation;
636
- }
637
613
  if (changed_floatingGroupBounds) {
638
614
  for (const group of this._floatingGroups) {
639
615
  switch (this.options.floatingGroupBounds) {
@@ -921,7 +897,7 @@ export class DockviewComponent extends BaseGrid {
921
897
  ? this.getGroupPanel(options.position.referencePanel)
922
898
  : options.position.referencePanel;
923
899
  if (!referencePanel) {
924
- throw new Error(`referencePanel ${options.position.referencePanel} does not exist`);
900
+ throw new Error(`referencePanel '${options.position.referencePanel}' does not exist`);
925
901
  }
926
902
  referenceGroup = this.findGroup(referencePanel);
927
903
  }
@@ -931,14 +907,19 @@ export class DockviewComponent extends BaseGrid {
931
907
  ? (_a = this._groups.get(options.position.referenceGroup)) === null || _a === void 0 ? void 0 : _a.value
932
908
  : options.position.referenceGroup;
933
909
  if (!referenceGroup) {
934
- throw new Error(`referencePanel ${options.position.referenceGroup} does not exist`);
910
+ throw new Error(`referenceGroup '${options.position.referenceGroup}' does not exist`);
935
911
  }
936
912
  }
937
913
  else {
938
914
  const group = this.orthogonalize(directionToPosition(options.position.direction));
939
915
  const panel = this.createPanel(options, group);
940
- group.model.openPanel(panel);
941
- this.doSetGroupAndPanelActive(group);
916
+ group.model.openPanel(panel, {
917
+ skipSetActive: options.inactive,
918
+ skipSetGroupActive: options.inactive,
919
+ });
920
+ if (!options.inactive) {
921
+ this.doSetGroupAndPanelActive(group);
922
+ }
942
923
  return panel;
943
924
  }
944
925
  }
@@ -961,43 +942,64 @@ export class DockviewComponent extends BaseGrid {
961
942
  skipActiveGroup: true,
962
943
  });
963
944
  panel = this.createPanel(options, group);
964
- group.model.openPanel(panel);
945
+ group.model.openPanel(panel, {
946
+ skipSetActive: options.inactive,
947
+ skipSetGroupActive: options.inactive,
948
+ });
965
949
  }
966
950
  else if (referenceGroup.api.location.type === 'floating' ||
967
951
  target === 'center') {
968
952
  panel = this.createPanel(options, referenceGroup);
969
- referenceGroup.model.openPanel(panel);
970
- this.doSetGroupAndPanelActive(referenceGroup);
953
+ referenceGroup.model.openPanel(panel, {
954
+ skipSetActive: options.inactive,
955
+ skipSetGroupActive: options.inactive,
956
+ });
957
+ if (!options.inactive) {
958
+ this.doSetGroupAndPanelActive(referenceGroup);
959
+ }
971
960
  }
972
961
  else {
973
962
  const location = getGridLocation(referenceGroup.element);
974
963
  const relativeLocation = getRelativeLocation(this.gridview.orientation, location, target);
975
964
  const group = this.createGroupAtLocation(relativeLocation);
976
965
  panel = this.createPanel(options, group);
977
- group.model.openPanel(panel);
978
- this.doSetGroupAndPanelActive(group);
966
+ group.model.openPanel(panel, {
967
+ skipSetActive: options.inactive,
968
+ skipSetGroupActive: options.inactive,
969
+ });
970
+ if (!options.inactive) {
971
+ this.doSetGroupAndPanelActive(group);
972
+ }
979
973
  }
980
974
  }
981
975
  else if (options.floating) {
982
976
  const group = this.createGroup();
983
977
  this._onDidAddGroup.fire(group);
984
- const o = typeof options.floating === 'object' &&
978
+ const coordinates = typeof options.floating === 'object' &&
985
979
  options.floating !== null
986
980
  ? options.floating
987
981
  : {};
988
- this.addFloatingGroup(group, o, {
982
+ this.addFloatingGroup(group, coordinates, {
989
983
  inDragMode: false,
990
984
  skipRemoveGroup: true,
991
985
  skipActiveGroup: true,
992
986
  });
993
987
  panel = this.createPanel(options, group);
994
- group.model.openPanel(panel);
988
+ group.model.openPanel(panel, {
989
+ skipSetActive: options.inactive,
990
+ skipSetGroupActive: options.inactive,
991
+ });
995
992
  }
996
993
  else {
997
994
  const group = this.createGroupAtLocation();
998
995
  panel = this.createPanel(options, group);
999
- group.model.openPanel(panel);
1000
- this.doSetGroupAndPanelActive(group);
996
+ group.model.openPanel(panel, {
997
+ skipSetActive: options.inactive,
998
+ skipSetGroupActive: options.inactive,
999
+ });
1000
+ if (!options.inactive) {
1001
+ this.doSetGroupAndPanelActive(group);
1002
+ }
1001
1003
  }
1002
1004
  return panel;
1003
1005
  }
@@ -1021,12 +1023,10 @@ export class DockviewComponent extends BaseGrid {
1021
1023
  }
1022
1024
  }
1023
1025
  createWatermarkComponent() {
1024
- var _a;
1025
- return createComponent('watermark-id', 'watermark-name', this.options.watermarkComponent
1026
- ? { 'watermark-name': this.options.watermarkComponent }
1027
- : {}, this.options.watermarkFrameworkComponent
1028
- ? { 'watermark-name': this.options.watermarkFrameworkComponent }
1029
- : {}, (_a = this.options.frameworkComponentFactory) === null || _a === void 0 ? void 0 : _a.watermark);
1026
+ if (this.options.createWatermarkComponent) {
1027
+ return this.options.createWatermarkComponent();
1028
+ }
1029
+ return new Watermark();
1030
1030
  }
1031
1031
  updateWatermark() {
1032
1032
  var _a, _b;
@@ -1407,6 +1407,8 @@ export class DockviewComponent extends BaseGrid {
1407
1407
  return;
1408
1408
  }
1409
1409
  this._onWillShowOverlay.fire(event);
1410
+ }), view.model.onUnhandledDragOverEvent((event) => {
1411
+ this._onUnhandledDragOverEvent.fire(event);
1410
1412
  }), view.model.onDidAddPanel((event) => {
1411
1413
  if (this._moving) {
1412
1414
  return;
@@ -9,6 +9,7 @@ import { IPanel, PanelInitParameters, PanelUpdateEvent, Parameters } from '../pa
9
9
  import { GroupDragEvent, TabDragEvent } from './components/titlebar/tabsContainer';
10
10
  import { DockviewGroupPanel } from './dockviewGroupPanel';
11
11
  import { IDockviewPanel } from './dockviewPanel';
12
+ import { DockviewDndOverlayEvent } from './options';
12
13
  import { OverlayRenderContainer } from '../overlayRenderContainer';
13
14
  import { TitleEvent } from '../api/dockviewPanelApi';
14
15
  interface GroupMoveEvent {
@@ -181,6 +182,8 @@ export declare class DockviewGroupPanelModel extends CompositeDisposable impleme
181
182
  readonly onDidRemovePanel: Event<DockviewGroupChangeEvent>;
182
183
  private readonly _onDidActivePanelChange;
183
184
  readonly onDidActivePanelChange: Event<DockviewGroupChangeEvent>;
185
+ private readonly _onUnhandledDragOverEvent;
186
+ readonly onUnhandledDragOverEvent: Event<DockviewDndOverlayEvent>;
184
187
  private readonly _api;
185
188
  get element(): HTMLElement;
186
189
  get activePanel(): IDockviewPanel | undefined;
@@ -5,6 +5,7 @@ import { addDisposableListener, DockviewEvent, Emitter, } from '../events';
5
5
  import { CompositeDisposable } from '../lifecycle';
6
6
  import { ContentContainer, } from './components/panel/content';
7
7
  import { TabsContainer, } from './components/titlebar/tabsContainer';
8
+ import { DockviewUnhandledDragOverEvent, } from './options';
8
9
  export class DockviewDidDropEvent extends DockviewEvent {
9
10
  get nativeEvent() {
10
11
  return this.options.nativeEvent;
@@ -182,6 +183,8 @@ export class DockviewGroupPanelModel extends CompositeDisposable {
182
183
  this.onDidRemovePanel = this._onDidRemovePanel.event;
183
184
  this._onDidActivePanelChange = new Emitter();
184
185
  this.onDidActivePanelChange = this._onDidActivePanelChange.event;
186
+ this._onUnhandledDragOverEvent = new Emitter();
187
+ this.onUnhandledDragOverEvent = this._onUnhandledDragOverEvent.event;
185
188
  this._overwriteRenderContainer = null;
186
189
  toggleClass(this.container, 'groupview', true);
187
190
  this._api = new DockviewApi(this.accessor);
@@ -212,7 +215,7 @@ export class DockviewGroupPanelModel extends CompositeDisposable {
212
215
  group: this.groupPanel,
213
216
  getData: getPanelData,
214
217
  }));
215
- }), this._onMove, this._onDidChange, this._onDidDrop, this._onWillDrop, this._onDidAddPanel, this._onDidRemovePanel, this._onDidActivePanelChange);
218
+ }), this._onMove, this._onDidChange, this._onDidDrop, this._onWillDrop, this._onDidAddPanel, this._onDidRemovePanel, this._onDidActivePanelChange, this._onUnhandledDragOverEvent);
216
219
  }
217
220
  focusContent() {
218
221
  this.contentContainer.element.focus();
@@ -243,33 +246,36 @@ export class DockviewGroupPanelModel extends CompositeDisposable {
243
246
  // correctly initialized
244
247
  this.setActive(this.isActive, true);
245
248
  this.updateContainer();
246
- if (this.accessor.options.createRightHeaderActionsElement) {
249
+ if (this.accessor.options.createRightHeaderActionComponent) {
247
250
  this._rightHeaderActions =
248
- this.accessor.options.createRightHeaderActionsElement(this.groupPanel);
251
+ this.accessor.options.createRightHeaderActionComponent(this.groupPanel);
249
252
  this.addDisposables(this._rightHeaderActions);
250
253
  this._rightHeaderActions.init({
251
254
  containerApi: this._api,
252
255
  api: this.groupPanel.api,
256
+ group: this.groupPanel,
253
257
  });
254
258
  this.tabsContainer.setRightActionsElement(this._rightHeaderActions.element);
255
259
  }
256
- if (this.accessor.options.createLeftHeaderActionsElement) {
260
+ if (this.accessor.options.createLeftHeaderActionComponent) {
257
261
  this._leftHeaderActions =
258
- this.accessor.options.createLeftHeaderActionsElement(this.groupPanel);
262
+ this.accessor.options.createLeftHeaderActionComponent(this.groupPanel);
259
263
  this.addDisposables(this._leftHeaderActions);
260
264
  this._leftHeaderActions.init({
261
265
  containerApi: this._api,
262
266
  api: this.groupPanel.api,
267
+ group: this.groupPanel,
263
268
  });
264
269
  this.tabsContainer.setLeftActionsElement(this._leftHeaderActions.element);
265
270
  }
266
- if (this.accessor.options.createPrefixHeaderActionsElement) {
271
+ if (this.accessor.options.createPrefixHeaderActionComponent) {
267
272
  this._prefixHeaderActions =
268
- this.accessor.options.createPrefixHeaderActionsElement(this.groupPanel);
273
+ this.accessor.options.createPrefixHeaderActionComponent(this.groupPanel);
269
274
  this.addDisposables(this._prefixHeaderActions);
270
275
  this._prefixHeaderActions.init({
271
276
  containerApi: this._api,
272
277
  api: this.groupPanel.api,
278
+ group: this.groupPanel,
273
279
  });
274
280
  this.tabsContainer.setPrefixActionsElement(this._prefixHeaderActions.element);
275
281
  }
@@ -468,7 +474,8 @@ export class DockviewGroupPanelModel extends CompositeDisposable {
468
474
  this.tabsContainer.delete(panel.id);
469
475
  this._panels.splice(index, 1);
470
476
  if (this.mostRecentlyUsed.includes(panel)) {
471
- this.mostRecentlyUsed.splice(this.mostRecentlyUsed.indexOf(panel), 1);
477
+ const index = this.mostRecentlyUsed.indexOf(panel);
478
+ this.mostRecentlyUsed.splice(index, 1);
472
479
  }
473
480
  const disposable = this._panelDisposables.get(panel.id);
474
481
  if (disposable) {
@@ -543,17 +550,9 @@ export class DockviewGroupPanelModel extends CompositeDisposable {
543
550
  }
544
551
  }
545
552
  canDisplayOverlay(event, position, target) {
546
- // custom overlay handler
547
- if (this.accessor.options.showDndOverlay) {
548
- return this.accessor.options.showDndOverlay({
549
- nativeEvent: event,
550
- target,
551
- group: this.accessor.getPanel(this.id),
552
- position,
553
- getData: getPanelData,
554
- });
555
- }
556
- return false;
553
+ const firedEvent = new DockviewUnhandledDragOverEvent(event, target, position, getPanelData, this.accessor.getPanel(this.id));
554
+ this._onUnhandledDragOverEvent.fire(firedEvent);
555
+ return firedEvent.isAccepted;
557
556
  }
558
557
  handleDropEvent(type, event, position, index) {
559
558
  if (this.locked === 'no-drop-target') {
@@ -1,5 +1,4 @@
1
1
  import { DefaultTab } from './components/tab/defaultTab';
2
- import { createComponent } from '../panel/componentFactory';
3
2
  export class DockviewPanelModel {
4
3
  get content() {
5
4
  return this._content;
@@ -16,7 +15,7 @@ export class DockviewPanelModel {
16
15
  this._tab = this.createTabComponent(this.id, tabComponent);
17
16
  }
18
17
  init(params) {
19
- this.content.init(Object.assign(Object.assign({}, params), { tab: this.tab }));
18
+ this.content.init(params);
20
19
  this.tab.init(params);
21
20
  }
22
21
  updateParentGroup(_group, _isPanelVisible) {
@@ -37,19 +36,28 @@ export class DockviewPanelModel {
37
36
  (_d = (_c = this.tab).dispose) === null || _d === void 0 ? void 0 : _d.call(_c);
38
37
  }
39
38
  createContentComponent(id, componentName) {
40
- var _a, _b;
41
- return createComponent(id, componentName, (_a = this.accessor.options.components) !== null && _a !== void 0 ? _a : {}, this.accessor.options.frameworkComponents, (_b = this.accessor.options.frameworkComponentFactory) === null || _b === void 0 ? void 0 : _b.content);
39
+ return this.accessor.options.createComponent({
40
+ id,
41
+ name: componentName,
42
+ });
42
43
  }
43
44
  createTabComponent(id, componentName) {
44
- var _a, _b;
45
- if (componentName) {
46
- return createComponent(id, componentName, this.accessor.options.tabComponents, this.accessor.options.frameworkTabComponents, (_a = this.accessor.options.frameworkComponentFactory) === null || _a === void 0 ? void 0 : _a.tab, () => new DefaultTab());
47
- }
48
- else if (this.accessor.options.defaultTabComponent) {
49
- return createComponent(id, this.accessor.options.defaultTabComponent, this.accessor.options.tabComponents, this.accessor.options.frameworkTabComponents, (_b = this.accessor.options.frameworkComponentFactory) === null || _b === void 0 ? void 0 : _b.tab, () => new DefaultTab());
50
- }
51
- else {
52
- return new DefaultTab();
45
+ const name = componentName !== null && componentName !== void 0 ? componentName : this.accessor.options.defaultTabComponent;
46
+ if (name) {
47
+ if (this.accessor.options.createTabComponent) {
48
+ const component = this.accessor.options.createTabComponent({
49
+ id,
50
+ name,
51
+ });
52
+ if (component) {
53
+ return component;
54
+ }
55
+ else {
56
+ return new DefaultTab();
57
+ }
58
+ }
59
+ console.warn(`dockview: tabComponent '${componentName}' was not found. falling back to the default tab.`);
53
60
  }
61
+ return new DefaultTab();
54
62
  }
55
63
  }