dockview-core 1.8.1 → 1.8.3

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 (149) hide show
  1. package/dist/cjs/api/component.api.d.ts +8 -4
  2. package/dist/cjs/api/component.api.d.ts.map +1 -1
  3. package/dist/cjs/api/component.api.js +14 -0
  4. package/dist/cjs/api/component.api.js.map +1 -1
  5. package/dist/cjs/dnd/abstractDragHandler.d.ts +2 -2
  6. package/dist/cjs/dnd/abstractDragHandler.d.ts.map +1 -1
  7. package/dist/cjs/dnd/abstractDragHandler.js +16 -12
  8. package/dist/cjs/dnd/abstractDragHandler.js.map +1 -1
  9. package/dist/cjs/dnd/groupDragHandler.d.ts +4 -3
  10. package/dist/cjs/dnd/groupDragHandler.d.ts.map +1 -1
  11. package/dist/cjs/dnd/groupDragHandler.js +5 -4
  12. package/dist/cjs/dnd/groupDragHandler.js.map +1 -1
  13. package/dist/cjs/dnd/overlay.d.ts +6 -2
  14. package/dist/cjs/dnd/overlay.d.ts.map +1 -1
  15. package/dist/cjs/dnd/overlay.js +54 -23
  16. package/dist/cjs/dnd/overlay.js.map +1 -1
  17. package/dist/cjs/dockview/components/tab/tab.d.ts +7 -4
  18. package/dist/cjs/dockview/components/tab/tab.d.ts.map +1 -1
  19. package/dist/cjs/dockview/components/tab/tab.js +36 -28
  20. package/dist/cjs/dockview/components/tab/tab.js.map +1 -1
  21. package/dist/cjs/dockview/components/titlebar/tabsContainer.d.ts +15 -1
  22. package/dist/cjs/dockview/components/titlebar/tabsContainer.d.ts.map +1 -1
  23. package/dist/cjs/dockview/components/titlebar/tabsContainer.js +26 -15
  24. package/dist/cjs/dockview/components/titlebar/tabsContainer.js.map +1 -1
  25. package/dist/cjs/dockview/components/titlebar/voidContainer.d.ts +2 -0
  26. package/dist/cjs/dockview/components/titlebar/voidContainer.d.ts.map +1 -1
  27. package/dist/cjs/dockview/components/titlebar/voidContainer.js +7 -3
  28. package/dist/cjs/dockview/components/titlebar/voidContainer.js.map +1 -1
  29. package/dist/cjs/dockview/dockviewComponent.d.ts +11 -4
  30. package/dist/cjs/dockview/dockviewComponent.d.ts.map +1 -1
  31. package/dist/cjs/dockview/dockviewComponent.js +78 -36
  32. package/dist/cjs/dockview/dockviewComponent.js.map +1 -1
  33. package/dist/cjs/dockview/dockviewGroupPanel.d.ts +4 -4
  34. package/dist/cjs/dockview/dockviewGroupPanel.d.ts.map +1 -1
  35. package/dist/cjs/dockview/dockviewGroupPanel.js.map +1 -1
  36. package/dist/cjs/dockview/dockviewGroupPanelModel.d.ts +10 -4
  37. package/dist/cjs/dockview/dockviewGroupPanelModel.d.ts.map +1 -1
  38. package/dist/cjs/dockview/dockviewGroupPanelModel.js +18 -6
  39. package/dist/cjs/dockview/dockviewGroupPanelModel.js.map +1 -1
  40. package/dist/cjs/dockview/dockviewPanel.d.ts +1 -1
  41. package/dist/cjs/dockview/dockviewPanel.d.ts.map +1 -1
  42. package/dist/cjs/dockview/options.d.ts +8 -5
  43. package/dist/cjs/dockview/options.d.ts.map +1 -1
  44. package/dist/cjs/dockview/options.js.map +1 -1
  45. package/dist/cjs/gridview/basePanelView.d.ts +4 -4
  46. package/dist/cjs/gridview/basePanelView.d.ts.map +1 -1
  47. package/dist/cjs/gridview/basePanelView.js.map +1 -1
  48. package/dist/cjs/gridview/gridviewComponent.d.ts +4 -4
  49. package/dist/cjs/gridview/gridviewComponent.d.ts.map +1 -1
  50. package/dist/cjs/gridview/gridviewComponent.js.map +1 -1
  51. package/dist/cjs/lifecycle.d.ts +0 -1
  52. package/dist/cjs/lifecycle.d.ts.map +1 -1
  53. package/dist/cjs/lifecycle.js +0 -32
  54. package/dist/cjs/lifecycle.js.map +1 -1
  55. package/dist/cjs/panel/types.d.ts +2 -2
  56. package/dist/cjs/panel/types.d.ts.map +1 -1
  57. package/dist/cjs/paneview/paneviewComponent.d.ts +5 -6
  58. package/dist/cjs/paneview/paneviewComponent.d.ts.map +1 -1
  59. package/dist/cjs/paneview/paneviewComponent.js.map +1 -1
  60. package/dist/cjs/splitview/splitviewComponent.d.ts +4 -4
  61. package/dist/cjs/splitview/splitviewComponent.d.ts.map +1 -1
  62. package/dist/cjs/splitview/splitviewComponent.js.map +1 -1
  63. package/dist/cjs/splitview/splitviewPanel.d.ts +1 -1
  64. package/dist/dockview-core.amd.js +201 -104
  65. package/dist/dockview-core.amd.js.map +1 -1
  66. package/dist/dockview-core.amd.min.js +2 -2
  67. package/dist/dockview-core.amd.min.js.map +1 -1
  68. package/dist/dockview-core.amd.min.noStyle.js +2 -2
  69. package/dist/dockview-core.amd.min.noStyle.js.map +1 -1
  70. package/dist/dockview-core.amd.noStyle.js +201 -104
  71. package/dist/dockview-core.amd.noStyle.js.map +1 -1
  72. package/dist/dockview-core.cjs.js +201 -104
  73. package/dist/dockview-core.cjs.js.map +1 -1
  74. package/dist/dockview-core.esm.js +201 -104
  75. package/dist/dockview-core.esm.js.map +1 -1
  76. package/dist/dockview-core.esm.min.js +2 -2
  77. package/dist/dockview-core.esm.min.js.map +1 -1
  78. package/dist/dockview-core.js +201 -104
  79. package/dist/dockview-core.js.map +1 -1
  80. package/dist/dockview-core.min.js +2 -2
  81. package/dist/dockview-core.min.js.map +1 -1
  82. package/dist/dockview-core.min.noStyle.js +2 -2
  83. package/dist/dockview-core.min.noStyle.js.map +1 -1
  84. package/dist/dockview-core.noStyle.js +201 -104
  85. package/dist/dockview-core.noStyle.js.map +1 -1
  86. package/dist/esm/api/component.api.d.ts +8 -4
  87. package/dist/esm/api/component.api.d.ts.map +1 -1
  88. package/dist/esm/api/component.api.js +6 -0
  89. package/dist/esm/api/component.api.js.map +1 -1
  90. package/dist/esm/dnd/abstractDragHandler.d.ts +2 -2
  91. package/dist/esm/dnd/abstractDragHandler.d.ts.map +1 -1
  92. package/dist/esm/dnd/abstractDragHandler.js +16 -12
  93. package/dist/esm/dnd/abstractDragHandler.js.map +1 -1
  94. package/dist/esm/dnd/groupDragHandler.d.ts +4 -3
  95. package/dist/esm/dnd/groupDragHandler.d.ts.map +1 -1
  96. package/dist/esm/dnd/groupDragHandler.js +5 -4
  97. package/dist/esm/dnd/groupDragHandler.js.map +1 -1
  98. package/dist/esm/dnd/overlay.d.ts +6 -2
  99. package/dist/esm/dnd/overlay.d.ts.map +1 -1
  100. package/dist/esm/dnd/overlay.js +46 -23
  101. package/dist/esm/dnd/overlay.js.map +1 -1
  102. package/dist/esm/dockview/components/tab/tab.d.ts +7 -4
  103. package/dist/esm/dockview/components/tab/tab.d.ts.map +1 -1
  104. package/dist/esm/dockview/components/tab/tab.js +32 -24
  105. package/dist/esm/dockview/components/tab/tab.js.map +1 -1
  106. package/dist/esm/dockview/components/titlebar/tabsContainer.d.ts +15 -1
  107. package/dist/esm/dockview/components/titlebar/tabsContainer.d.ts.map +1 -1
  108. package/dist/esm/dockview/components/titlebar/tabsContainer.js +26 -15
  109. package/dist/esm/dockview/components/titlebar/tabsContainer.js.map +1 -1
  110. package/dist/esm/dockview/components/titlebar/voidContainer.d.ts +2 -0
  111. package/dist/esm/dockview/components/titlebar/voidContainer.d.ts.map +1 -1
  112. package/dist/esm/dockview/components/titlebar/voidContainer.js +7 -3
  113. package/dist/esm/dockview/components/titlebar/voidContainer.js.map +1 -1
  114. package/dist/esm/dockview/dockviewComponent.d.ts +11 -4
  115. package/dist/esm/dockview/dockviewComponent.d.ts.map +1 -1
  116. package/dist/esm/dockview/dockviewComponent.js +44 -13
  117. package/dist/esm/dockview/dockviewComponent.js.map +1 -1
  118. package/dist/esm/dockview/dockviewGroupPanel.d.ts +4 -4
  119. package/dist/esm/dockview/dockviewGroupPanel.d.ts.map +1 -1
  120. package/dist/esm/dockview/dockviewGroupPanel.js.map +1 -1
  121. package/dist/esm/dockview/dockviewGroupPanelModel.d.ts +10 -4
  122. package/dist/esm/dockview/dockviewGroupPanelModel.d.ts.map +1 -1
  123. package/dist/esm/dockview/dockviewGroupPanelModel.js +18 -6
  124. package/dist/esm/dockview/dockviewGroupPanelModel.js.map +1 -1
  125. package/dist/esm/dockview/dockviewPanel.d.ts +1 -1
  126. package/dist/esm/dockview/dockviewPanel.d.ts.map +1 -1
  127. package/dist/esm/dockview/options.d.ts +8 -5
  128. package/dist/esm/dockview/options.d.ts.map +1 -1
  129. package/dist/esm/dockview/options.js.map +1 -1
  130. package/dist/esm/gridview/basePanelView.d.ts +4 -4
  131. package/dist/esm/gridview/basePanelView.d.ts.map +1 -1
  132. package/dist/esm/gridview/basePanelView.js.map +1 -1
  133. package/dist/esm/gridview/gridviewComponent.d.ts +4 -4
  134. package/dist/esm/gridview/gridviewComponent.d.ts.map +1 -1
  135. package/dist/esm/gridview/gridviewComponent.js.map +1 -1
  136. package/dist/esm/lifecycle.d.ts +0 -1
  137. package/dist/esm/lifecycle.d.ts.map +1 -1
  138. package/dist/esm/lifecycle.js +0 -3
  139. package/dist/esm/lifecycle.js.map +1 -1
  140. package/dist/esm/panel/types.d.ts +2 -2
  141. package/dist/esm/panel/types.d.ts.map +1 -1
  142. package/dist/esm/paneview/paneviewComponent.d.ts +5 -6
  143. package/dist/esm/paneview/paneviewComponent.d.ts.map +1 -1
  144. package/dist/esm/paneview/paneviewComponent.js.map +1 -1
  145. package/dist/esm/splitview/splitviewComponent.d.ts +4 -4
  146. package/dist/esm/splitview/splitviewComponent.d.ts.map +1 -1
  147. package/dist/esm/splitview/splitviewComponent.js.map +1 -1
  148. package/dist/esm/splitview/splitviewPanel.d.ts +1 -1
  149. package/package.json +2 -2
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * dockview-core
3
- * @version 1.8.1
3
+ * @version 1.8.3
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -244,9 +244,6 @@
244
244
  get isDisposed() {
245
245
  return this._isDisposed;
246
246
  }
247
- static from(...args) {
248
- return new CompositeDisposable(...args);
249
- }
250
247
  constructor(...args) {
251
248
  this._isDisposed = false;
252
249
  this._disposables = args;
@@ -2450,6 +2447,12 @@
2450
2447
  get onDidDrop() {
2451
2448
  return this.component.onDidDrop;
2452
2449
  }
2450
+ get onWillDragGroup() {
2451
+ return this.component.onWillDragGroup;
2452
+ }
2453
+ get onWillDragPanel() {
2454
+ return this.component.onWillDragPanel;
2455
+ }
2453
2456
  get panels() {
2454
2457
  return this.component.panels;
2455
2458
  }
@@ -2912,7 +2915,7 @@
2912
2915
  }
2913
2916
  configure() {
2914
2917
  this.addDisposables(this._onDragStart, addDisposableListener(this.el, 'dragstart', (event) => {
2915
- if (this.isCancelled(event)) {
2918
+ if (event.defaultPrevented || this.isCancelled(event)) {
2916
2919
  event.preventDefault();
2917
2920
  return;
2918
2921
  }
@@ -2932,19 +2935,23 @@
2932
2935
  }
2933
2936
  this.el.classList.add('dv-dragged');
2934
2937
  setTimeout(() => this.el.classList.remove('dv-dragged'), 0);
2935
- this.dataDisposable.value = this.getData(event.dataTransfer);
2938
+ this.dataDisposable.value = this.getData(event);
2939
+ this._onDragStart.fire(event);
2936
2940
  if (event.dataTransfer) {
2937
2941
  event.dataTransfer.effectAllowed = 'move';
2938
- /**
2939
- * Although this is not used by dockview many third party dnd libraries will check
2940
- * dataTransfer.types to determine valid drag events.
2941
- *
2942
- * For example: in react-dnd if dataTransfer.types is not set then the dragStart event will be cancelled
2943
- * through .preventDefault(). Since this is applied globally to all drag events this would break dockviews
2944
- * dnd logic. You can see the code at
2945
- * https://github.com/react-dnd/react-dnd/blob/main/packages/backend-html5/src/HTML5BackendImpl.ts#L542
2946
- */
2947
- event.dataTransfer.setData('text/plain', '__dockview_internal_drag_event__');
2942
+ const hasData = event.dataTransfer.items.length > 0;
2943
+ if (!hasData) {
2944
+ /**
2945
+ * Although this is not used by dockview many third party dnd libraries will check
2946
+ * dataTransfer.types to determine valid drag events.
2947
+ *
2948
+ * For example: in react-dnd if dataTransfer.types is not set then the dragStart event will be cancelled
2949
+ * through .preventDefault(). Since this is applied globally to all drag events this would break dockviews
2950
+ * dnd logic. You can see the code at
2951
+ * https://github.com/react-dnd/react-dnd/blob/main/packages/backend-html5/src/HTML5BackendImpl.ts#L542
2952
+ */
2953
+ event.dataTransfer.setData('text/plain', '__dockview_internal_drag_event__');
2954
+ }
2948
2955
  }
2949
2956
  }), addDisposableListener(this.el, 'dragend', () => {
2950
2957
  this.pointerEventsDisposable.dispose();
@@ -2953,44 +2960,45 @@
2953
2960
  }
2954
2961
  }
2955
2962
 
2963
+ class TabDragHandler extends DragHandler {
2964
+ constructor(element, accessor, group, panel) {
2965
+ super(element);
2966
+ this.accessor = accessor;
2967
+ this.group = group;
2968
+ this.panel = panel;
2969
+ this.panelTransfer = LocalSelectionTransfer.getInstance();
2970
+ }
2971
+ getData(event) {
2972
+ this.panelTransfer.setData([new PanelTransfer(this.accessor.id, this.group.id, this.panel.id)], PanelTransfer.prototype);
2973
+ return {
2974
+ dispose: () => {
2975
+ this.panelTransfer.clearData(PanelTransfer.prototype);
2976
+ },
2977
+ };
2978
+ }
2979
+ }
2956
2980
  class Tab extends CompositeDisposable {
2957
2981
  get element() {
2958
2982
  return this._element;
2959
2983
  }
2960
- constructor(panelId, accessor, group) {
2984
+ constructor(panel, accessor, group) {
2961
2985
  super();
2962
- this.panelId = panelId;
2986
+ this.panel = panel;
2963
2987
  this.accessor = accessor;
2964
2988
  this.group = group;
2989
+ this.content = undefined;
2965
2990
  this._onChanged = new Emitter();
2966
2991
  this.onChanged = this._onChanged.event;
2967
2992
  this._onDropped = new Emitter();
2968
2993
  this.onDrop = this._onDropped.event;
2994
+ this._onDragStart = new Emitter();
2995
+ this.onDragStart = this._onDragStart.event;
2969
2996
  this._element = document.createElement('div');
2970
2997
  this._element.className = 'tab';
2971
2998
  this._element.tabIndex = 0;
2972
2999
  this._element.draggable = true;
2973
3000
  toggleClass(this.element, 'inactive-tab', true);
2974
- this.addDisposables(this._onChanged, this._onDropped, new (class Handler extends DragHandler {
2975
- constructor() {
2976
- super(...arguments);
2977
- this.panelTransfer = LocalSelectionTransfer.getInstance();
2978
- }
2979
- getData() {
2980
- this.panelTransfer.setData([new PanelTransfer(accessor.id, group.id, panelId)], PanelTransfer.prototype);
2981
- return {
2982
- dispose: () => {
2983
- this.panelTransfer.clearData(PanelTransfer.prototype);
2984
- },
2985
- };
2986
- }
2987
- })(this._element));
2988
- this.addDisposables(addDisposableListener(this._element, 'mousedown', (event) => {
2989
- if (event.defaultPrevented) {
2990
- return;
2991
- }
2992
- this._onChanged.fire(event);
2993
- }));
3001
+ const dragHandler = new TabDragHandler(this._element, this.accessor, this.group, this.panel);
2994
3002
  this.droptarget = new Droptarget(this._element, {
2995
3003
  acceptedTargetZones: ['center'],
2996
3004
  canDisplayOverlay: (event, position) => {
@@ -3004,12 +3012,19 @@
3004
3012
  // don't allow group move to drop on self
3005
3013
  return false;
3006
3014
  }
3007
- return this.panelId !== data.panelId;
3015
+ return this.panel.id !== data.panelId;
3008
3016
  }
3009
3017
  return this.group.model.canDisplayOverlay(event, position, exports.DockviewDropTargets.Tab);
3010
3018
  },
3011
3019
  });
3012
- this.addDisposables(this.droptarget.onDrop((event) => {
3020
+ this.addDisposables(this._onChanged, this._onDropped, this._onDragStart, dragHandler.onDragStart((event) => {
3021
+ this._onDragStart.fire(event);
3022
+ }), dragHandler, addDisposableListener(this._element, 'mousedown', (event) => {
3023
+ if (event.defaultPrevented) {
3024
+ return;
3025
+ }
3026
+ this._onChanged.fire(event);
3027
+ }), this.droptarget.onDrop((event) => {
3013
3028
  this._onDropped.fire(event);
3014
3029
  }), this.droptarget);
3015
3030
  }
@@ -3041,9 +3056,9 @@
3041
3056
  }
3042
3057
 
3043
3058
  class GroupDragHandler extends DragHandler {
3044
- constructor(element, accessorId, group) {
3059
+ constructor(element, accessor, group) {
3045
3060
  super(element);
3046
- this.accessorId = accessorId;
3061
+ this.accessor = accessor;
3047
3062
  this.group = group;
3048
3063
  this.panelTransfer = LocalSelectionTransfer.getInstance();
3049
3064
  this.addDisposables(addDisposableListener(element, 'mousedown', (e) => {
@@ -3063,8 +3078,9 @@
3063
3078
  }
3064
3079
  return false;
3065
3080
  }
3066
- getData(dataTransfer) {
3067
- this.panelTransfer.setData([new PanelTransfer(this.accessorId, this.group.id, null)], PanelTransfer.prototype);
3081
+ getData(dragEvent) {
3082
+ const dataTransfer = dragEvent.dataTransfer;
3083
+ this.panelTransfer.setData([new PanelTransfer(this.accessor.id, this.group.id, null)], PanelTransfer.prototype);
3068
3084
  const style = window.getComputedStyle(this.el);
3069
3085
  const bgColor = style.getPropertyValue('--dv-activegroup-visiblepanel-tab-background-color');
3070
3086
  const color = style.getPropertyValue('--dv-activegroup-visiblepanel-tab-color');
@@ -3099,14 +3115,16 @@
3099
3115
  this.group = group;
3100
3116
  this._onDrop = new Emitter();
3101
3117
  this.onDrop = this._onDrop.event;
3118
+ this._onDragStart = new Emitter();
3119
+ this.onDragStart = this._onDragStart.event;
3102
3120
  this._element = document.createElement('div');
3103
3121
  this._element.className = 'void-container';
3104
3122
  this._element.tabIndex = 0;
3105
3123
  this._element.draggable = true;
3106
- this.addDisposables(this._onDrop, addDisposableListener(this._element, 'click', () => {
3124
+ this.addDisposables(this._onDrop, this._onDragStart, addDisposableListener(this._element, 'click', () => {
3107
3125
  this.accessor.doSetGroupActive(this.group);
3108
3126
  }));
3109
- const handler = new GroupDragHandler(this._element, accessor.id, group);
3127
+ const handler = new GroupDragHandler(this._element, accessor, group);
3110
3128
  this.voidDropTarget = new Droptarget(this._element, {
3111
3129
  acceptedTargetZones: ['center'],
3112
3130
  canDisplayOverlay: (event, position) => {
@@ -3124,7 +3142,9 @@
3124
3142
  return group.model.canDisplayOverlay(event, position, exports.DockviewDropTargets.Panel);
3125
3143
  },
3126
3144
  });
3127
- this.addDisposables(handler, this.voidDropTarget.onDrop((event) => {
3145
+ this.addDisposables(handler, handler.onDragStart((event) => {
3146
+ this._onDragStart.fire(event);
3147
+ }), this.voidDropTarget.onDrop((event) => {
3128
3148
  this._onDrop.fire(event);
3129
3149
  }), this.voidDropTarget);
3130
3150
  }
@@ -3132,7 +3152,7 @@
3132
3152
 
3133
3153
  class TabsContainer extends CompositeDisposable {
3134
3154
  get panels() {
3135
- return this.tabs.map((_) => _.value.panelId);
3155
+ return this.tabs.map((_) => _.value.panel.id);
3136
3156
  }
3137
3157
  get size() {
3138
3158
  return this.tabs.length;
@@ -3186,7 +3206,7 @@
3186
3206
  this.tabs[this.selectedIndex].value === tab);
3187
3207
  }
3188
3208
  indexOf(id) {
3189
- return this.tabs.findIndex((tab) => tab.value.panelId === id);
3209
+ return this.tabs.findIndex((tab) => tab.value.panel.id === id);
3190
3210
  }
3191
3211
  constructor(accessor, group) {
3192
3212
  super();
@@ -3197,7 +3217,11 @@
3197
3217
  this._hidden = false;
3198
3218
  this._onDrop = new Emitter();
3199
3219
  this.onDrop = this._onDrop.event;
3200
- this.addDisposables(this._onDrop);
3220
+ this._onTabDragStart = new Emitter();
3221
+ this.onTabDragStart = this._onTabDragStart.event;
3222
+ this._onGroupDragStart = new Emitter();
3223
+ this.onGroupDragStart = this._onGroupDragStart.event;
3224
+ this.addDisposables(this._onDrop, this._onTabDragStart, this._onGroupDragStart);
3201
3225
  this._element = document.createElement('div');
3202
3226
  this._element.className = 'tabs-and-actions-container';
3203
3227
  toggleClass(this._element, 'dv-full-width-single-tab', this.accessor.options.singleTabMode === 'fullwidth');
@@ -3221,7 +3245,12 @@
3221
3245
  this._element.appendChild(this.leftActionsContainer);
3222
3246
  this._element.appendChild(this.voidContainer.element);
3223
3247
  this._element.appendChild(this.rightActionsContainer);
3224
- this.addDisposables(this.voidContainer, this.voidContainer.onDrop((event) => {
3248
+ this.addDisposables(this.voidContainer, this.voidContainer.onDragStart((event) => {
3249
+ this._onGroupDragStart.fire({
3250
+ nativeEvent: event,
3251
+ group: this.group,
3252
+ });
3253
+ }), this.voidContainer.onDrop((event) => {
3225
3254
  this._onDrop.fire({
3226
3255
  event: event.nativeEvent,
3227
3256
  index: this.tabs.length,
@@ -3267,7 +3296,7 @@
3267
3296
  }
3268
3297
  }
3269
3298
  delete(id) {
3270
- const index = this.tabs.findIndex((tab) => tab.value.panelId === id);
3299
+ const index = this.tabs.findIndex((tab) => tab.value.panel.id === id);
3271
3300
  const tabToRemove = this.tabs.splice(index, 1)[0];
3272
3301
  const { value, disposable } = tabToRemove;
3273
3302
  disposable.dispose();
@@ -3276,21 +3305,23 @@
3276
3305
  }
3277
3306
  setActivePanel(panel) {
3278
3307
  this.tabs.forEach((tab) => {
3279
- const isActivePanel = panel.id === tab.value.panelId;
3308
+ const isActivePanel = panel.id === tab.value.panel.id;
3280
3309
  tab.value.setActive(isActivePanel);
3281
3310
  });
3282
3311
  }
3283
3312
  openPanel(panel, index = this.tabs.length) {
3284
3313
  var _a;
3285
- if (this.tabs.find((tab) => tab.value.panelId === panel.id)) {
3314
+ if (this.tabs.find((tab) => tab.value.panel.id === panel.id)) {
3286
3315
  return;
3287
3316
  }
3288
- const tabToAdd = new Tab(panel.id, this.accessor, this.group);
3317
+ const tab = new Tab(panel, this.accessor, this.group);
3289
3318
  if (!((_a = panel.view) === null || _a === void 0 ? void 0 : _a.tab)) {
3290
3319
  throw new Error('invalid header component');
3291
3320
  }
3292
- tabToAdd.setContent(panel.view.tab);
3293
- const disposable = CompositeDisposable.from(tabToAdd.onChanged((event) => {
3321
+ tab.setContent(panel.view.tab);
3322
+ const disposable = new CompositeDisposable(tab.onDragStart((event) => {
3323
+ this._onTabDragStart.fire({ nativeEvent: event, panel });
3324
+ }), tab.onChanged((event) => {
3294
3325
  var _a;
3295
3326
  const isFloatingGroupsEnabled = !this.accessor.options.disableFloatingGroups;
3296
3327
  const isFloatingWithOnePanel = this.group.api.isFloating && this.size === 1;
@@ -3298,8 +3329,8 @@
3298
3329
  !isFloatingWithOnePanel &&
3299
3330
  event.shiftKey) {
3300
3331
  event.preventDefault();
3301
- const panel = this.accessor.getGroupPanel(tabToAdd.panelId);
3302
- const { top, left } = tabToAdd.element.getBoundingClientRect();
3332
+ const panel = this.accessor.getGroupPanel(tab.panel.id);
3333
+ const { top, left } = tab.element.getBoundingClientRect();
3303
3334
  const { top: rootTop, left: rootLeft } = this.accessor.element.getBoundingClientRect();
3304
3335
  this.accessor.addFloatingGroup(panel, {
3305
3336
  x: left - rootLeft,
@@ -3316,13 +3347,13 @@
3316
3347
  this.group.model.openPanel(panel, {
3317
3348
  skipFocus: alreadyFocused,
3318
3349
  });
3319
- }), tabToAdd.onDrop((event) => {
3350
+ }), tab.onDrop((event) => {
3320
3351
  this._onDrop.fire({
3321
3352
  event: event.nativeEvent,
3322
- index: this.tabs.findIndex((x) => x.value === tabToAdd),
3353
+ index: this.tabs.findIndex((x) => x.value === tab),
3323
3354
  });
3324
3355
  }));
3325
- const value = { value: tabToAdd, disposable };
3356
+ const value = { value: tab, disposable };
3326
3357
  this.addTab(value, index);
3327
3358
  }
3328
3359
  closePanel(panel) {
@@ -3350,7 +3381,7 @@
3350
3381
  }
3351
3382
  set locked(value) {
3352
3383
  this._locked = value;
3353
- toggleClass(this.container, 'locked-groupview', value);
3384
+ toggleClass(this.container, 'locked-groupview', value === 'no-drop-target' || value);
3354
3385
  }
3355
3386
  get isActive() {
3356
3387
  return this._isGroupActive;
@@ -3407,6 +3438,10 @@
3407
3438
  this.onMove = this._onMove.event;
3408
3439
  this._onDidDrop = new Emitter();
3409
3440
  this.onDidDrop = this._onDidDrop.event;
3441
+ this._onTabDragStart = new Emitter();
3442
+ this.onTabDragStart = this._onTabDragStart.event;
3443
+ this._onGroupDragStart = new Emitter();
3444
+ this.onGroupDragStart = this._onGroupDragStart.event;
3410
3445
  this._onDidAddPanel = new Emitter();
3411
3446
  this.onDidAddPanel = this._onDidAddPanel.event;
3412
3447
  this._onDidRemovePanel = new Emitter();
@@ -3419,7 +3454,8 @@
3419
3454
  this.dropTarget = new Droptarget(this.contentContainer.element, {
3420
3455
  acceptedTargetZones: ['top', 'bottom', 'left', 'right', 'center'],
3421
3456
  canDisplayOverlay: (event, position) => {
3422
- if (this.locked && position === 'center') {
3457
+ if (this.locked === 'no-drop-target' ||
3458
+ (this.locked && position === 'center')) {
3423
3459
  return false;
3424
3460
  }
3425
3461
  const data = getPanelData();
@@ -3445,8 +3481,12 @@
3445
3481
  });
3446
3482
  container.append(this.tabsContainer.element, this.contentContainer.element);
3447
3483
  this.header.hidden = !!options.hideHeader;
3448
- this.locked = !!options.locked;
3449
- this.addDisposables(this.tabsContainer.onDrop((event) => {
3484
+ this.locked = options.locked || false;
3485
+ this.addDisposables(this._onTabDragStart, this._onGroupDragStart, this.tabsContainer.onTabDragStart((event) => {
3486
+ this._onTabDragStart.fire(event);
3487
+ }), this.tabsContainer.onGroupDragStart((event) => {
3488
+ this._onGroupDragStart.fire(event);
3489
+ }), this.tabsContainer.onDrop((event) => {
3450
3490
  this.handleDropEvent(event.event, 'center', event.index);
3451
3491
  }), this.contentContainer.onDidFocus(() => {
3452
3492
  this.accessor.doSetGroupActive(this.groupPanel, true);
@@ -3501,8 +3541,8 @@
3501
3541
  activeView: (_a = this._activePanel) === null || _a === void 0 ? void 0 : _a.id,
3502
3542
  id: this.id,
3503
3543
  };
3504
- if (this.locked) {
3505
- result.locked = true;
3544
+ if (this.locked !== false) {
3545
+ result.locked = this.locked;
3506
3546
  }
3507
3547
  if (this.header.hidden) {
3508
3548
  result.hideHeader = true;
@@ -3752,6 +3792,9 @@
3752
3792
  return false;
3753
3793
  }
3754
3794
  handleDropEvent(event, position, index) {
3795
+ if (this.locked === 'no-drop-target') {
3796
+ return;
3797
+ }
3755
3798
  const data = getPanelData();
3756
3799
  if (data && data.viewId === this.accessor.id) {
3757
3800
  if (data.panelId === null) {
@@ -5209,6 +5252,12 @@
5209
5252
  return pushToTop;
5210
5253
  })();
5211
5254
  class Overlay extends CompositeDisposable {
5255
+ set minimumInViewportWidth(value) {
5256
+ this.options.minimumInViewportWidth = value;
5257
+ }
5258
+ set minimumInViewportHeight(value) {
5259
+ this.options.minimumInViewportHeight = value;
5260
+ }
5212
5261
  constructor(options) {
5213
5262
  super();
5214
5263
  this.options = options;
@@ -5254,9 +5303,11 @@
5254
5303
  const overlayRect = this._element.getBoundingClientRect();
5255
5304
  // region: ensure bounds within allowable limits
5256
5305
  // a minimum width of minimumViewportWidth must be inside the viewport
5257
- const xOffset = Math.max(0, overlayRect.width - this.options.minimumInViewportWidth);
5306
+ const xOffset = Math.max(0, this.getMinimumWidth(overlayRect.width));
5258
5307
  // a minimum height of minimumViewportHeight must be inside the viewport
5259
- const yOffset = Math.max(0, overlayRect.height - this.options.minimumInViewportHeight);
5308
+ const yOffset = typeof this.options.minimumInViewportHeight === 'number'
5309
+ ? Math.max(0, this.getMinimumHeight(overlayRect.height))
5310
+ : 0;
5260
5311
  const left = clamp(overlayRect.left - containerRect.left, -xOffset, Math.max(0, containerRect.width - overlayRect.width + xOffset));
5261
5312
  const top = clamp(overlayRect.top - containerRect.top, -yOffset, Math.max(0, containerRect.height - overlayRect.height + yOffset));
5262
5313
  this._element.style.left = `${left}px`;
@@ -5302,9 +5353,10 @@
5302
5353
  y: e.clientY - overlayRect.top,
5303
5354
  };
5304
5355
  }
5305
- const xOffset = Math.max(0, overlayRect.width - this.options.minimumInViewportWidth);
5306
- const yOffset = Math.max(0, overlayRect.height -
5307
- this.options.minimumInViewportHeight);
5356
+ const xOffset = Math.max(0, this.getMinimumWidth(overlayRect.width));
5357
+ const yOffset = Math.max(0, this.options.minimumInViewportHeight
5358
+ ? this.getMinimumHeight(overlayRect.height)
5359
+ : 0);
5308
5360
  const left = clamp(x - offset.x, -xOffset, Math.max(0, containerRect.width - overlayRect.width + xOffset));
5309
5361
  const top = clamp(y - offset.y, -yOffset, Math.max(0, containerRect.height - overlayRect.height + yOffset));
5310
5362
  this.setBounds({ top, left });
@@ -5378,14 +5430,11 @@
5378
5430
  let height = undefined;
5379
5431
  let left = undefined;
5380
5432
  let width = undefined;
5381
- const minimumInViewportHeight = this.options.minimumInViewportHeight;
5382
- const minimumInViewportWidth = this.options.minimumInViewportWidth;
5383
- function moveTop() {
5433
+ const moveTop = () => {
5384
5434
  top = clamp(y, -Number.MAX_VALUE, startPosition.originalY +
5385
5435
  startPosition.originalHeight >
5386
5436
  containerRect.height
5387
- ? containerRect.height -
5388
- minimumInViewportHeight
5437
+ ? this.getMinimumHeight(containerRect.height)
5389
5438
  : Math.max(0, startPosition.originalY +
5390
5439
  startPosition.originalHeight -
5391
5440
  Overlay.MINIMUM_HEIGHT));
@@ -5393,21 +5442,23 @@
5393
5442
  startPosition.originalY +
5394
5443
  startPosition.originalHeight -
5395
5444
  top;
5396
- }
5397
- function moveBottom() {
5445
+ };
5446
+ const moveBottom = () => {
5398
5447
  top =
5399
5448
  startPosition.originalY -
5400
5449
  startPosition.originalHeight;
5401
- height = clamp(y - top, top < 0
5402
- ? -top + minimumInViewportHeight
5450
+ height = clamp(y - top, top < 0 &&
5451
+ typeof this.options
5452
+ .minimumInViewportHeight === 'number'
5453
+ ? -top +
5454
+ this.options.minimumInViewportHeight
5403
5455
  : Overlay.MINIMUM_HEIGHT, Number.MAX_VALUE);
5404
- }
5405
- function moveLeft() {
5456
+ };
5457
+ const moveLeft = () => {
5406
5458
  left = clamp(x, -Number.MAX_VALUE, startPosition.originalX +
5407
5459
  startPosition.originalWidth >
5408
5460
  containerRect.width
5409
- ? containerRect.width -
5410
- minimumInViewportWidth
5461
+ ? this.getMinimumWidth(containerRect.width)
5411
5462
  : Math.max(0, startPosition.originalX +
5412
5463
  startPosition.originalWidth -
5413
5464
  Overlay.MINIMUM_WIDTH));
@@ -5415,15 +5466,18 @@
5415
5466
  startPosition.originalX +
5416
5467
  startPosition.originalWidth -
5417
5468
  left;
5418
- }
5419
- function moveRight() {
5469
+ };
5470
+ const moveRight = () => {
5420
5471
  left =
5421
5472
  startPosition.originalX -
5422
5473
  startPosition.originalWidth;
5423
- width = clamp(x - left, left < 0
5424
- ? -left + minimumInViewportWidth
5474
+ width = clamp(x - left, left < 0 &&
5475
+ typeof this.options
5476
+ .minimumInViewportWidth === 'number'
5477
+ ? -left +
5478
+ this.options.minimumInViewportWidth
5425
5479
  : Overlay.MINIMUM_WIDTH, Number.MAX_VALUE);
5426
- }
5480
+ };
5427
5481
  switch (direction) {
5428
5482
  case 'top':
5429
5483
  moveTop();
@@ -5467,6 +5521,18 @@
5467
5521
  }));
5468
5522
  }));
5469
5523
  }
5524
+ getMinimumWidth(width) {
5525
+ if (typeof this.options.minimumInViewportWidth === 'number') {
5526
+ return width - this.options.minimumInViewportWidth;
5527
+ }
5528
+ return 0;
5529
+ }
5530
+ getMinimumHeight(height) {
5531
+ if (typeof this.options.minimumInViewportHeight === 'number') {
5532
+ return height - this.options.minimumInViewportHeight;
5533
+ }
5534
+ return height;
5535
+ }
5470
5536
  dispose() {
5471
5537
  this._element.remove();
5472
5538
  super.dispose();
@@ -5487,6 +5553,7 @@
5487
5553
  }
5488
5554
  }
5489
5555
 
5556
+ const DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE = 100;
5490
5557
  class DockviewComponent extends BaseGrid {
5491
5558
  get orientation() {
5492
5559
  return this.gridview.orientation;
@@ -5517,6 +5584,10 @@
5517
5584
  this.nextGroupId = sequentialNumberGenerator();
5518
5585
  this._deserializer = new DefaultDockviewDeserialzier(this);
5519
5586
  this.watermark = null;
5587
+ this._onWillDragPanel = new Emitter();
5588
+ this.onWillDragPanel = this._onWillDragPanel.event;
5589
+ this._onWillDragGroup = new Emitter();
5590
+ this.onWillDragGroup = this._onWillDragGroup.event;
5520
5591
  this._onDidDrop = new Emitter();
5521
5592
  this.onDidDrop = this._onDidDrop.event;
5522
5593
  this._onDidRemovePanel = new Emitter();
@@ -5529,7 +5600,7 @@
5529
5600
  this.onDidActivePanelChange = this._onDidActivePanelChange.event;
5530
5601
  this.floatingGroups = [];
5531
5602
  toggleClass(this.gridview.element, 'dv-dockview', true);
5532
- this.addDisposables(this._onDidDrop, exports.DockviewEvent.any(this.onDidAddGroup, this.onDidRemoveGroup)(() => {
5603
+ this.addDisposables(this._onWillDragPanel, this._onWillDragGroup, this._onDidActivePanelChange, this._onDidAddPanel, this._onDidRemovePanel, this._onDidLayoutFromJSON, this._onDidDrop, exports.DockviewEvent.any(this.onDidAddGroup, this.onDidRemoveGroup)(() => {
5533
5604
  this.updateWatermark();
5534
5605
  }), exports.DockviewEvent.any(this.onDidAddPanel, this.onDidRemovePanel, this.onDidActivePanelChange)(() => {
5535
5606
  this._bufferOnDidLayoutChange.fire();
@@ -5566,7 +5637,7 @@
5566
5637
  return true;
5567
5638
  }
5568
5639
  if (this.options.showDndOverlay) {
5569
- if (position === 'center') {
5640
+ if (position === 'center' && this.gridview.length !== 0) {
5570
5641
  /**
5571
5642
  * for external events only show the four-corner drag overlays, disable
5572
5643
  * the center position so that external drag events can fall through to the group
@@ -5602,7 +5673,7 @@
5602
5673
  this.updateWatermark();
5603
5674
  }
5604
5675
  addFloatingGroup(item, coord, options) {
5605
- var _a, _b;
5676
+ var _a, _b, _c, _d, _e, _f;
5606
5677
  let group;
5607
5678
  if (item instanceof DockviewPanel) {
5608
5679
  group = this.createGroup();
@@ -5630,8 +5701,12 @@
5630
5701
  width: (_b = coord === null || coord === void 0 ? void 0 : coord.width) !== null && _b !== void 0 ? _b : 300,
5631
5702
  left: overlayLeft,
5632
5703
  top: overlayTop,
5633
- minimumInViewportWidth: 100,
5634
- minimumInViewportHeight: 100,
5704
+ minimumInViewportWidth: this.options.floatingGroupBounds === 'boundedWithinViewport'
5705
+ ? undefined
5706
+ : (_d = (_c = this.options.floatingGroupBounds) === null || _c === void 0 ? void 0 : _c.minimumWidthWithinViewport) !== null && _d !== void 0 ? _d : DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE,
5707
+ minimumInViewportHeight: this.options.floatingGroupBounds === 'boundedWithinViewport'
5708
+ ? undefined
5709
+ : (_f = (_e = this.options.floatingGroupBounds) === null || _e === void 0 ? void 0 : _e.minimumHeightWithinViewport) !== null && _f !== void 0 ? _f : DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE,
5635
5710
  });
5636
5711
  const el = group.element.querySelector('.void-container');
5637
5712
  if (!el) {
@@ -5702,12 +5777,37 @@
5702
5777
  }
5703
5778
  }
5704
5779
  updateOptions(options) {
5780
+ var _a, _b;
5705
5781
  const hasOrientationChanged = typeof options.orientation === 'string' &&
5706
5782
  this.gridview.orientation !== options.orientation;
5783
+ const hasFloatingGroupOptionsChanged = options.floatingGroupBounds !== undefined &&
5784
+ options.floatingGroupBounds !== this.options.floatingGroupBounds;
5707
5785
  this._options = Object.assign(Object.assign({}, this.options), options);
5708
5786
  if (hasOrientationChanged) {
5709
5787
  this.gridview.orientation = options.orientation;
5710
5788
  }
5789
+ if (hasFloatingGroupOptionsChanged) {
5790
+ for (const group of this.floatingGroups) {
5791
+ switch (this.options.floatingGroupBounds) {
5792
+ case 'boundedWithinViewport':
5793
+ group.overlay.minimumInViewportHeight = undefined;
5794
+ group.overlay.minimumInViewportWidth = undefined;
5795
+ break;
5796
+ case undefined:
5797
+ group.overlay.minimumInViewportHeight =
5798
+ DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE;
5799
+ group.overlay.minimumInViewportWidth =
5800
+ DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE;
5801
+ break;
5802
+ default:
5803
+ group.overlay.minimumInViewportHeight =
5804
+ (_a = this.options.floatingGroupBounds) === null || _a === void 0 ? void 0 : _a.minimumHeightWithinViewport;
5805
+ group.overlay.minimumInViewportWidth =
5806
+ (_b = this.options.floatingGroupBounds) === null || _b === void 0 ? void 0 : _b.minimumWidthWithinViewport;
5807
+ }
5808
+ group.overlay.setBounds({});
5809
+ }
5810
+ }
5711
5811
  this.layout(this.gridview.width, this.gridview.height, true);
5712
5812
  }
5713
5813
  layout(width, height, forceResize) {
@@ -6190,7 +6290,11 @@
6190
6290
  const view = new DockviewGroupPanel(this, id, options);
6191
6291
  view.init({ params: {}, accessor: null }); // required to initialized .part and allow for correct disposal of group
6192
6292
  if (!this._groups.has(view.id)) {
6193
- const disposable = new CompositeDisposable(view.model.onMove((event) => {
6293
+ const disposable = new CompositeDisposable(view.model.onTabDragStart((event) => {
6294
+ this._onWillDragPanel.fire(event);
6295
+ }), view.model.onGroupDragStart((event) => {
6296
+ this._onWillDragGroup.fire(event);
6297
+ }), view.model.onMove((event) => {
6194
6298
  const { groupId, itemId, target, index } = event;
6195
6299
  this.moveGroupOrPanel(view, groupId, itemId, target, index);
6196
6300
  }), view.model.onDidDrop((event) => {
@@ -6229,13 +6333,6 @@
6229
6333
  var _a;
6230
6334
  return (_a = Array.from(this._groups.values()).find((group) => group.value.model.containsPanel(panel))) === null || _a === void 0 ? void 0 : _a.value;
6231
6335
  }
6232
- dispose() {
6233
- this._onDidActivePanelChange.dispose();
6234
- this._onDidAddPanel.dispose();
6235
- this._onDidRemovePanel.dispose();
6236
- this._onDidLayoutFromJSON.dispose();
6237
- super.dispose();
6238
- }
6239
6336
  }
6240
6337
 
6241
6338
  class GridviewComponent extends BaseGrid {