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
  */
@@ -274,9 +274,6 @@
274
274
  get isDisposed() {
275
275
  return this._isDisposed;
276
276
  }
277
- static from(...args) {
278
- return new CompositeDisposable(...args);
279
- }
280
277
  constructor(...args) {
281
278
  this._isDisposed = false;
282
279
  this._disposables = args;
@@ -2480,6 +2477,12 @@
2480
2477
  get onDidDrop() {
2481
2478
  return this.component.onDidDrop;
2482
2479
  }
2480
+ get onWillDragGroup() {
2481
+ return this.component.onWillDragGroup;
2482
+ }
2483
+ get onWillDragPanel() {
2484
+ return this.component.onWillDragPanel;
2485
+ }
2483
2486
  get panels() {
2484
2487
  return this.component.panels;
2485
2488
  }
@@ -2942,7 +2945,7 @@
2942
2945
  }
2943
2946
  configure() {
2944
2947
  this.addDisposables(this._onDragStart, addDisposableListener(this.el, 'dragstart', (event) => {
2945
- if (this.isCancelled(event)) {
2948
+ if (event.defaultPrevented || this.isCancelled(event)) {
2946
2949
  event.preventDefault();
2947
2950
  return;
2948
2951
  }
@@ -2962,19 +2965,23 @@
2962
2965
  }
2963
2966
  this.el.classList.add('dv-dragged');
2964
2967
  setTimeout(() => this.el.classList.remove('dv-dragged'), 0);
2965
- this.dataDisposable.value = this.getData(event.dataTransfer);
2968
+ this.dataDisposable.value = this.getData(event);
2969
+ this._onDragStart.fire(event);
2966
2970
  if (event.dataTransfer) {
2967
2971
  event.dataTransfer.effectAllowed = 'move';
2968
- /**
2969
- * Although this is not used by dockview many third party dnd libraries will check
2970
- * dataTransfer.types to determine valid drag events.
2971
- *
2972
- * For example: in react-dnd if dataTransfer.types is not set then the dragStart event will be cancelled
2973
- * through .preventDefault(). Since this is applied globally to all drag events this would break dockviews
2974
- * dnd logic. You can see the code at
2975
- * https://github.com/react-dnd/react-dnd/blob/main/packages/backend-html5/src/HTML5BackendImpl.ts#L542
2976
- */
2977
- event.dataTransfer.setData('text/plain', '__dockview_internal_drag_event__');
2972
+ const hasData = event.dataTransfer.items.length > 0;
2973
+ if (!hasData) {
2974
+ /**
2975
+ * Although this is not used by dockview many third party dnd libraries will check
2976
+ * dataTransfer.types to determine valid drag events.
2977
+ *
2978
+ * For example: in react-dnd if dataTransfer.types is not set then the dragStart event will be cancelled
2979
+ * through .preventDefault(). Since this is applied globally to all drag events this would break dockviews
2980
+ * dnd logic. You can see the code at
2981
+ * https://github.com/react-dnd/react-dnd/blob/main/packages/backend-html5/src/HTML5BackendImpl.ts#L542
2982
+ */
2983
+ event.dataTransfer.setData('text/plain', '__dockview_internal_drag_event__');
2984
+ }
2978
2985
  }
2979
2986
  }), addDisposableListener(this.el, 'dragend', () => {
2980
2987
  this.pointerEventsDisposable.dispose();
@@ -2983,44 +2990,45 @@
2983
2990
  }
2984
2991
  }
2985
2992
 
2993
+ class TabDragHandler extends DragHandler {
2994
+ constructor(element, accessor, group, panel) {
2995
+ super(element);
2996
+ this.accessor = accessor;
2997
+ this.group = group;
2998
+ this.panel = panel;
2999
+ this.panelTransfer = LocalSelectionTransfer.getInstance();
3000
+ }
3001
+ getData(event) {
3002
+ this.panelTransfer.setData([new PanelTransfer(this.accessor.id, this.group.id, this.panel.id)], PanelTransfer.prototype);
3003
+ return {
3004
+ dispose: () => {
3005
+ this.panelTransfer.clearData(PanelTransfer.prototype);
3006
+ },
3007
+ };
3008
+ }
3009
+ }
2986
3010
  class Tab extends CompositeDisposable {
2987
3011
  get element() {
2988
3012
  return this._element;
2989
3013
  }
2990
- constructor(panelId, accessor, group) {
3014
+ constructor(panel, accessor, group) {
2991
3015
  super();
2992
- this.panelId = panelId;
3016
+ this.panel = panel;
2993
3017
  this.accessor = accessor;
2994
3018
  this.group = group;
3019
+ this.content = undefined;
2995
3020
  this._onChanged = new Emitter();
2996
3021
  this.onChanged = this._onChanged.event;
2997
3022
  this._onDropped = new Emitter();
2998
3023
  this.onDrop = this._onDropped.event;
3024
+ this._onDragStart = new Emitter();
3025
+ this.onDragStart = this._onDragStart.event;
2999
3026
  this._element = document.createElement('div');
3000
3027
  this._element.className = 'tab';
3001
3028
  this._element.tabIndex = 0;
3002
3029
  this._element.draggable = true;
3003
3030
  toggleClass(this.element, 'inactive-tab', true);
3004
- this.addDisposables(this._onChanged, this._onDropped, new (class Handler extends DragHandler {
3005
- constructor() {
3006
- super(...arguments);
3007
- this.panelTransfer = LocalSelectionTransfer.getInstance();
3008
- }
3009
- getData() {
3010
- this.panelTransfer.setData([new PanelTransfer(accessor.id, group.id, panelId)], PanelTransfer.prototype);
3011
- return {
3012
- dispose: () => {
3013
- this.panelTransfer.clearData(PanelTransfer.prototype);
3014
- },
3015
- };
3016
- }
3017
- })(this._element));
3018
- this.addDisposables(addDisposableListener(this._element, 'mousedown', (event) => {
3019
- if (event.defaultPrevented) {
3020
- return;
3021
- }
3022
- this._onChanged.fire(event);
3023
- }));
3031
+ const dragHandler = new TabDragHandler(this._element, this.accessor, this.group, this.panel);
3024
3032
  this.droptarget = new Droptarget(this._element, {
3025
3033
  acceptedTargetZones: ['center'],
3026
3034
  canDisplayOverlay: (event, position) => {
@@ -3034,12 +3042,19 @@
3034
3042
  // don't allow group move to drop on self
3035
3043
  return false;
3036
3044
  }
3037
- return this.panelId !== data.panelId;
3045
+ return this.panel.id !== data.panelId;
3038
3046
  }
3039
3047
  return this.group.model.canDisplayOverlay(event, position, exports.DockviewDropTargets.Tab);
3040
3048
  },
3041
3049
  });
3042
- this.addDisposables(this.droptarget.onDrop((event) => {
3050
+ this.addDisposables(this._onChanged, this._onDropped, this._onDragStart, dragHandler.onDragStart((event) => {
3051
+ this._onDragStart.fire(event);
3052
+ }), dragHandler, addDisposableListener(this._element, 'mousedown', (event) => {
3053
+ if (event.defaultPrevented) {
3054
+ return;
3055
+ }
3056
+ this._onChanged.fire(event);
3057
+ }), this.droptarget.onDrop((event) => {
3043
3058
  this._onDropped.fire(event);
3044
3059
  }), this.droptarget);
3045
3060
  }
@@ -3071,9 +3086,9 @@
3071
3086
  }
3072
3087
 
3073
3088
  class GroupDragHandler extends DragHandler {
3074
- constructor(element, accessorId, group) {
3089
+ constructor(element, accessor, group) {
3075
3090
  super(element);
3076
- this.accessorId = accessorId;
3091
+ this.accessor = accessor;
3077
3092
  this.group = group;
3078
3093
  this.panelTransfer = LocalSelectionTransfer.getInstance();
3079
3094
  this.addDisposables(addDisposableListener(element, 'mousedown', (e) => {
@@ -3093,8 +3108,9 @@
3093
3108
  }
3094
3109
  return false;
3095
3110
  }
3096
- getData(dataTransfer) {
3097
- this.panelTransfer.setData([new PanelTransfer(this.accessorId, this.group.id, null)], PanelTransfer.prototype);
3111
+ getData(dragEvent) {
3112
+ const dataTransfer = dragEvent.dataTransfer;
3113
+ this.panelTransfer.setData([new PanelTransfer(this.accessor.id, this.group.id, null)], PanelTransfer.prototype);
3098
3114
  const style = window.getComputedStyle(this.el);
3099
3115
  const bgColor = style.getPropertyValue('--dv-activegroup-visiblepanel-tab-background-color');
3100
3116
  const color = style.getPropertyValue('--dv-activegroup-visiblepanel-tab-color');
@@ -3129,14 +3145,16 @@
3129
3145
  this.group = group;
3130
3146
  this._onDrop = new Emitter();
3131
3147
  this.onDrop = this._onDrop.event;
3148
+ this._onDragStart = new Emitter();
3149
+ this.onDragStart = this._onDragStart.event;
3132
3150
  this._element = document.createElement('div');
3133
3151
  this._element.className = 'void-container';
3134
3152
  this._element.tabIndex = 0;
3135
3153
  this._element.draggable = true;
3136
- this.addDisposables(this._onDrop, addDisposableListener(this._element, 'click', () => {
3154
+ this.addDisposables(this._onDrop, this._onDragStart, addDisposableListener(this._element, 'click', () => {
3137
3155
  this.accessor.doSetGroupActive(this.group);
3138
3156
  }));
3139
- const handler = new GroupDragHandler(this._element, accessor.id, group);
3157
+ const handler = new GroupDragHandler(this._element, accessor, group);
3140
3158
  this.voidDropTarget = new Droptarget(this._element, {
3141
3159
  acceptedTargetZones: ['center'],
3142
3160
  canDisplayOverlay: (event, position) => {
@@ -3154,7 +3172,9 @@
3154
3172
  return group.model.canDisplayOverlay(event, position, exports.DockviewDropTargets.Panel);
3155
3173
  },
3156
3174
  });
3157
- this.addDisposables(handler, this.voidDropTarget.onDrop((event) => {
3175
+ this.addDisposables(handler, handler.onDragStart((event) => {
3176
+ this._onDragStart.fire(event);
3177
+ }), this.voidDropTarget.onDrop((event) => {
3158
3178
  this._onDrop.fire(event);
3159
3179
  }), this.voidDropTarget);
3160
3180
  }
@@ -3162,7 +3182,7 @@
3162
3182
 
3163
3183
  class TabsContainer extends CompositeDisposable {
3164
3184
  get panels() {
3165
- return this.tabs.map((_) => _.value.panelId);
3185
+ return this.tabs.map((_) => _.value.panel.id);
3166
3186
  }
3167
3187
  get size() {
3168
3188
  return this.tabs.length;
@@ -3216,7 +3236,7 @@
3216
3236
  this.tabs[this.selectedIndex].value === tab);
3217
3237
  }
3218
3238
  indexOf(id) {
3219
- return this.tabs.findIndex((tab) => tab.value.panelId === id);
3239
+ return this.tabs.findIndex((tab) => tab.value.panel.id === id);
3220
3240
  }
3221
3241
  constructor(accessor, group) {
3222
3242
  super();
@@ -3227,7 +3247,11 @@
3227
3247
  this._hidden = false;
3228
3248
  this._onDrop = new Emitter();
3229
3249
  this.onDrop = this._onDrop.event;
3230
- this.addDisposables(this._onDrop);
3250
+ this._onTabDragStart = new Emitter();
3251
+ this.onTabDragStart = this._onTabDragStart.event;
3252
+ this._onGroupDragStart = new Emitter();
3253
+ this.onGroupDragStart = this._onGroupDragStart.event;
3254
+ this.addDisposables(this._onDrop, this._onTabDragStart, this._onGroupDragStart);
3231
3255
  this._element = document.createElement('div');
3232
3256
  this._element.className = 'tabs-and-actions-container';
3233
3257
  toggleClass(this._element, 'dv-full-width-single-tab', this.accessor.options.singleTabMode === 'fullwidth');
@@ -3251,7 +3275,12 @@
3251
3275
  this._element.appendChild(this.leftActionsContainer);
3252
3276
  this._element.appendChild(this.voidContainer.element);
3253
3277
  this._element.appendChild(this.rightActionsContainer);
3254
- this.addDisposables(this.voidContainer, this.voidContainer.onDrop((event) => {
3278
+ this.addDisposables(this.voidContainer, this.voidContainer.onDragStart((event) => {
3279
+ this._onGroupDragStart.fire({
3280
+ nativeEvent: event,
3281
+ group: this.group,
3282
+ });
3283
+ }), this.voidContainer.onDrop((event) => {
3255
3284
  this._onDrop.fire({
3256
3285
  event: event.nativeEvent,
3257
3286
  index: this.tabs.length,
@@ -3297,7 +3326,7 @@
3297
3326
  }
3298
3327
  }
3299
3328
  delete(id) {
3300
- const index = this.tabs.findIndex((tab) => tab.value.panelId === id);
3329
+ const index = this.tabs.findIndex((tab) => tab.value.panel.id === id);
3301
3330
  const tabToRemove = this.tabs.splice(index, 1)[0];
3302
3331
  const { value, disposable } = tabToRemove;
3303
3332
  disposable.dispose();
@@ -3306,21 +3335,23 @@
3306
3335
  }
3307
3336
  setActivePanel(panel) {
3308
3337
  this.tabs.forEach((tab) => {
3309
- const isActivePanel = panel.id === tab.value.panelId;
3338
+ const isActivePanel = panel.id === tab.value.panel.id;
3310
3339
  tab.value.setActive(isActivePanel);
3311
3340
  });
3312
3341
  }
3313
3342
  openPanel(panel, index = this.tabs.length) {
3314
3343
  var _a;
3315
- if (this.tabs.find((tab) => tab.value.panelId === panel.id)) {
3344
+ if (this.tabs.find((tab) => tab.value.panel.id === panel.id)) {
3316
3345
  return;
3317
3346
  }
3318
- const tabToAdd = new Tab(panel.id, this.accessor, this.group);
3347
+ const tab = new Tab(panel, this.accessor, this.group);
3319
3348
  if (!((_a = panel.view) === null || _a === void 0 ? void 0 : _a.tab)) {
3320
3349
  throw new Error('invalid header component');
3321
3350
  }
3322
- tabToAdd.setContent(panel.view.tab);
3323
- const disposable = CompositeDisposable.from(tabToAdd.onChanged((event) => {
3351
+ tab.setContent(panel.view.tab);
3352
+ const disposable = new CompositeDisposable(tab.onDragStart((event) => {
3353
+ this._onTabDragStart.fire({ nativeEvent: event, panel });
3354
+ }), tab.onChanged((event) => {
3324
3355
  var _a;
3325
3356
  const isFloatingGroupsEnabled = !this.accessor.options.disableFloatingGroups;
3326
3357
  const isFloatingWithOnePanel = this.group.api.isFloating && this.size === 1;
@@ -3328,8 +3359,8 @@
3328
3359
  !isFloatingWithOnePanel &&
3329
3360
  event.shiftKey) {
3330
3361
  event.preventDefault();
3331
- const panel = this.accessor.getGroupPanel(tabToAdd.panelId);
3332
- const { top, left } = tabToAdd.element.getBoundingClientRect();
3362
+ const panel = this.accessor.getGroupPanel(tab.panel.id);
3363
+ const { top, left } = tab.element.getBoundingClientRect();
3333
3364
  const { top: rootTop, left: rootLeft } = this.accessor.element.getBoundingClientRect();
3334
3365
  this.accessor.addFloatingGroup(panel, {
3335
3366
  x: left - rootLeft,
@@ -3346,13 +3377,13 @@
3346
3377
  this.group.model.openPanel(panel, {
3347
3378
  skipFocus: alreadyFocused,
3348
3379
  });
3349
- }), tabToAdd.onDrop((event) => {
3380
+ }), tab.onDrop((event) => {
3350
3381
  this._onDrop.fire({
3351
3382
  event: event.nativeEvent,
3352
- index: this.tabs.findIndex((x) => x.value === tabToAdd),
3383
+ index: this.tabs.findIndex((x) => x.value === tab),
3353
3384
  });
3354
3385
  }));
3355
- const value = { value: tabToAdd, disposable };
3386
+ const value = { value: tab, disposable };
3356
3387
  this.addTab(value, index);
3357
3388
  }
3358
3389
  closePanel(panel) {
@@ -3380,7 +3411,7 @@
3380
3411
  }
3381
3412
  set locked(value) {
3382
3413
  this._locked = value;
3383
- toggleClass(this.container, 'locked-groupview', value);
3414
+ toggleClass(this.container, 'locked-groupview', value === 'no-drop-target' || value);
3384
3415
  }
3385
3416
  get isActive() {
3386
3417
  return this._isGroupActive;
@@ -3437,6 +3468,10 @@
3437
3468
  this.onMove = this._onMove.event;
3438
3469
  this._onDidDrop = new Emitter();
3439
3470
  this.onDidDrop = this._onDidDrop.event;
3471
+ this._onTabDragStart = new Emitter();
3472
+ this.onTabDragStart = this._onTabDragStart.event;
3473
+ this._onGroupDragStart = new Emitter();
3474
+ this.onGroupDragStart = this._onGroupDragStart.event;
3440
3475
  this._onDidAddPanel = new Emitter();
3441
3476
  this.onDidAddPanel = this._onDidAddPanel.event;
3442
3477
  this._onDidRemovePanel = new Emitter();
@@ -3449,7 +3484,8 @@
3449
3484
  this.dropTarget = new Droptarget(this.contentContainer.element, {
3450
3485
  acceptedTargetZones: ['top', 'bottom', 'left', 'right', 'center'],
3451
3486
  canDisplayOverlay: (event, position) => {
3452
- if (this.locked && position === 'center') {
3487
+ if (this.locked === 'no-drop-target' ||
3488
+ (this.locked && position === 'center')) {
3453
3489
  return false;
3454
3490
  }
3455
3491
  const data = getPanelData();
@@ -3475,8 +3511,12 @@
3475
3511
  });
3476
3512
  container.append(this.tabsContainer.element, this.contentContainer.element);
3477
3513
  this.header.hidden = !!options.hideHeader;
3478
- this.locked = !!options.locked;
3479
- this.addDisposables(this.tabsContainer.onDrop((event) => {
3514
+ this.locked = options.locked || false;
3515
+ this.addDisposables(this._onTabDragStart, this._onGroupDragStart, this.tabsContainer.onTabDragStart((event) => {
3516
+ this._onTabDragStart.fire(event);
3517
+ }), this.tabsContainer.onGroupDragStart((event) => {
3518
+ this._onGroupDragStart.fire(event);
3519
+ }), this.tabsContainer.onDrop((event) => {
3480
3520
  this.handleDropEvent(event.event, 'center', event.index);
3481
3521
  }), this.contentContainer.onDidFocus(() => {
3482
3522
  this.accessor.doSetGroupActive(this.groupPanel, true);
@@ -3531,8 +3571,8 @@
3531
3571
  activeView: (_a = this._activePanel) === null || _a === void 0 ? void 0 : _a.id,
3532
3572
  id: this.id,
3533
3573
  };
3534
- if (this.locked) {
3535
- result.locked = true;
3574
+ if (this.locked !== false) {
3575
+ result.locked = this.locked;
3536
3576
  }
3537
3577
  if (this.header.hidden) {
3538
3578
  result.hideHeader = true;
@@ -3782,6 +3822,9 @@
3782
3822
  return false;
3783
3823
  }
3784
3824
  handleDropEvent(event, position, index) {
3825
+ if (this.locked === 'no-drop-target') {
3826
+ return;
3827
+ }
3785
3828
  const data = getPanelData();
3786
3829
  if (data && data.viewId === this.accessor.id) {
3787
3830
  if (data.panelId === null) {
@@ -5239,6 +5282,12 @@
5239
5282
  return pushToTop;
5240
5283
  })();
5241
5284
  class Overlay extends CompositeDisposable {
5285
+ set minimumInViewportWidth(value) {
5286
+ this.options.minimumInViewportWidth = value;
5287
+ }
5288
+ set minimumInViewportHeight(value) {
5289
+ this.options.minimumInViewportHeight = value;
5290
+ }
5242
5291
  constructor(options) {
5243
5292
  super();
5244
5293
  this.options = options;
@@ -5284,9 +5333,11 @@
5284
5333
  const overlayRect = this._element.getBoundingClientRect();
5285
5334
  // region: ensure bounds within allowable limits
5286
5335
  // a minimum width of minimumViewportWidth must be inside the viewport
5287
- const xOffset = Math.max(0, overlayRect.width - this.options.minimumInViewportWidth);
5336
+ const xOffset = Math.max(0, this.getMinimumWidth(overlayRect.width));
5288
5337
  // a minimum height of minimumViewportHeight must be inside the viewport
5289
- const yOffset = Math.max(0, overlayRect.height - this.options.minimumInViewportHeight);
5338
+ const yOffset = typeof this.options.minimumInViewportHeight === 'number'
5339
+ ? Math.max(0, this.getMinimumHeight(overlayRect.height))
5340
+ : 0;
5290
5341
  const left = clamp(overlayRect.left - containerRect.left, -xOffset, Math.max(0, containerRect.width - overlayRect.width + xOffset));
5291
5342
  const top = clamp(overlayRect.top - containerRect.top, -yOffset, Math.max(0, containerRect.height - overlayRect.height + yOffset));
5292
5343
  this._element.style.left = `${left}px`;
@@ -5332,9 +5383,10 @@
5332
5383
  y: e.clientY - overlayRect.top,
5333
5384
  };
5334
5385
  }
5335
- const xOffset = Math.max(0, overlayRect.width - this.options.minimumInViewportWidth);
5336
- const yOffset = Math.max(0, overlayRect.height -
5337
- this.options.minimumInViewportHeight);
5386
+ const xOffset = Math.max(0, this.getMinimumWidth(overlayRect.width));
5387
+ const yOffset = Math.max(0, this.options.minimumInViewportHeight
5388
+ ? this.getMinimumHeight(overlayRect.height)
5389
+ : 0);
5338
5390
  const left = clamp(x - offset.x, -xOffset, Math.max(0, containerRect.width - overlayRect.width + xOffset));
5339
5391
  const top = clamp(y - offset.y, -yOffset, Math.max(0, containerRect.height - overlayRect.height + yOffset));
5340
5392
  this.setBounds({ top, left });
@@ -5408,14 +5460,11 @@
5408
5460
  let height = undefined;
5409
5461
  let left = undefined;
5410
5462
  let width = undefined;
5411
- const minimumInViewportHeight = this.options.minimumInViewportHeight;
5412
- const minimumInViewportWidth = this.options.minimumInViewportWidth;
5413
- function moveTop() {
5463
+ const moveTop = () => {
5414
5464
  top = clamp(y, -Number.MAX_VALUE, startPosition.originalY +
5415
5465
  startPosition.originalHeight >
5416
5466
  containerRect.height
5417
- ? containerRect.height -
5418
- minimumInViewportHeight
5467
+ ? this.getMinimumHeight(containerRect.height)
5419
5468
  : Math.max(0, startPosition.originalY +
5420
5469
  startPosition.originalHeight -
5421
5470
  Overlay.MINIMUM_HEIGHT));
@@ -5423,21 +5472,23 @@
5423
5472
  startPosition.originalY +
5424
5473
  startPosition.originalHeight -
5425
5474
  top;
5426
- }
5427
- function moveBottom() {
5475
+ };
5476
+ const moveBottom = () => {
5428
5477
  top =
5429
5478
  startPosition.originalY -
5430
5479
  startPosition.originalHeight;
5431
- height = clamp(y - top, top < 0
5432
- ? -top + minimumInViewportHeight
5480
+ height = clamp(y - top, top < 0 &&
5481
+ typeof this.options
5482
+ .minimumInViewportHeight === 'number'
5483
+ ? -top +
5484
+ this.options.minimumInViewportHeight
5433
5485
  : Overlay.MINIMUM_HEIGHT, Number.MAX_VALUE);
5434
- }
5435
- function moveLeft() {
5486
+ };
5487
+ const moveLeft = () => {
5436
5488
  left = clamp(x, -Number.MAX_VALUE, startPosition.originalX +
5437
5489
  startPosition.originalWidth >
5438
5490
  containerRect.width
5439
- ? containerRect.width -
5440
- minimumInViewportWidth
5491
+ ? this.getMinimumWidth(containerRect.width)
5441
5492
  : Math.max(0, startPosition.originalX +
5442
5493
  startPosition.originalWidth -
5443
5494
  Overlay.MINIMUM_WIDTH));
@@ -5445,15 +5496,18 @@
5445
5496
  startPosition.originalX +
5446
5497
  startPosition.originalWidth -
5447
5498
  left;
5448
- }
5449
- function moveRight() {
5499
+ };
5500
+ const moveRight = () => {
5450
5501
  left =
5451
5502
  startPosition.originalX -
5452
5503
  startPosition.originalWidth;
5453
- width = clamp(x - left, left < 0
5454
- ? -left + minimumInViewportWidth
5504
+ width = clamp(x - left, left < 0 &&
5505
+ typeof this.options
5506
+ .minimumInViewportWidth === 'number'
5507
+ ? -left +
5508
+ this.options.minimumInViewportWidth
5455
5509
  : Overlay.MINIMUM_WIDTH, Number.MAX_VALUE);
5456
- }
5510
+ };
5457
5511
  switch (direction) {
5458
5512
  case 'top':
5459
5513
  moveTop();
@@ -5497,6 +5551,18 @@
5497
5551
  }));
5498
5552
  }));
5499
5553
  }
5554
+ getMinimumWidth(width) {
5555
+ if (typeof this.options.minimumInViewportWidth === 'number') {
5556
+ return width - this.options.minimumInViewportWidth;
5557
+ }
5558
+ return 0;
5559
+ }
5560
+ getMinimumHeight(height) {
5561
+ if (typeof this.options.minimumInViewportHeight === 'number') {
5562
+ return height - this.options.minimumInViewportHeight;
5563
+ }
5564
+ return height;
5565
+ }
5500
5566
  dispose() {
5501
5567
  this._element.remove();
5502
5568
  super.dispose();
@@ -5517,6 +5583,7 @@
5517
5583
  }
5518
5584
  }
5519
5585
 
5586
+ const DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE = 100;
5520
5587
  class DockviewComponent extends BaseGrid {
5521
5588
  get orientation() {
5522
5589
  return this.gridview.orientation;
@@ -5547,6 +5614,10 @@
5547
5614
  this.nextGroupId = sequentialNumberGenerator();
5548
5615
  this._deserializer = new DefaultDockviewDeserialzier(this);
5549
5616
  this.watermark = null;
5617
+ this._onWillDragPanel = new Emitter();
5618
+ this.onWillDragPanel = this._onWillDragPanel.event;
5619
+ this._onWillDragGroup = new Emitter();
5620
+ this.onWillDragGroup = this._onWillDragGroup.event;
5550
5621
  this._onDidDrop = new Emitter();
5551
5622
  this.onDidDrop = this._onDidDrop.event;
5552
5623
  this._onDidRemovePanel = new Emitter();
@@ -5559,7 +5630,7 @@
5559
5630
  this.onDidActivePanelChange = this._onDidActivePanelChange.event;
5560
5631
  this.floatingGroups = [];
5561
5632
  toggleClass(this.gridview.element, 'dv-dockview', true);
5562
- this.addDisposables(this._onDidDrop, exports.DockviewEvent.any(this.onDidAddGroup, this.onDidRemoveGroup)(() => {
5633
+ this.addDisposables(this._onWillDragPanel, this._onWillDragGroup, this._onDidActivePanelChange, this._onDidAddPanel, this._onDidRemovePanel, this._onDidLayoutFromJSON, this._onDidDrop, exports.DockviewEvent.any(this.onDidAddGroup, this.onDidRemoveGroup)(() => {
5563
5634
  this.updateWatermark();
5564
5635
  }), exports.DockviewEvent.any(this.onDidAddPanel, this.onDidRemovePanel, this.onDidActivePanelChange)(() => {
5565
5636
  this._bufferOnDidLayoutChange.fire();
@@ -5596,7 +5667,7 @@
5596
5667
  return true;
5597
5668
  }
5598
5669
  if (this.options.showDndOverlay) {
5599
- if (position === 'center') {
5670
+ if (position === 'center' && this.gridview.length !== 0) {
5600
5671
  /**
5601
5672
  * for external events only show the four-corner drag overlays, disable
5602
5673
  * the center position so that external drag events can fall through to the group
@@ -5632,7 +5703,7 @@
5632
5703
  this.updateWatermark();
5633
5704
  }
5634
5705
  addFloatingGroup(item, coord, options) {
5635
- var _a, _b;
5706
+ var _a, _b, _c, _d, _e, _f;
5636
5707
  let group;
5637
5708
  if (item instanceof DockviewPanel) {
5638
5709
  group = this.createGroup();
@@ -5660,8 +5731,12 @@
5660
5731
  width: (_b = coord === null || coord === void 0 ? void 0 : coord.width) !== null && _b !== void 0 ? _b : 300,
5661
5732
  left: overlayLeft,
5662
5733
  top: overlayTop,
5663
- minimumInViewportWidth: 100,
5664
- minimumInViewportHeight: 100,
5734
+ minimumInViewportWidth: this.options.floatingGroupBounds === 'boundedWithinViewport'
5735
+ ? undefined
5736
+ : (_d = (_c = this.options.floatingGroupBounds) === null || _c === void 0 ? void 0 : _c.minimumWidthWithinViewport) !== null && _d !== void 0 ? _d : DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE,
5737
+ minimumInViewportHeight: this.options.floatingGroupBounds === 'boundedWithinViewport'
5738
+ ? undefined
5739
+ : (_f = (_e = this.options.floatingGroupBounds) === null || _e === void 0 ? void 0 : _e.minimumHeightWithinViewport) !== null && _f !== void 0 ? _f : DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE,
5665
5740
  });
5666
5741
  const el = group.element.querySelector('.void-container');
5667
5742
  if (!el) {
@@ -5732,12 +5807,37 @@
5732
5807
  }
5733
5808
  }
5734
5809
  updateOptions(options) {
5810
+ var _a, _b;
5735
5811
  const hasOrientationChanged = typeof options.orientation === 'string' &&
5736
5812
  this.gridview.orientation !== options.orientation;
5813
+ const hasFloatingGroupOptionsChanged = options.floatingGroupBounds !== undefined &&
5814
+ options.floatingGroupBounds !== this.options.floatingGroupBounds;
5737
5815
  this._options = Object.assign(Object.assign({}, this.options), options);
5738
5816
  if (hasOrientationChanged) {
5739
5817
  this.gridview.orientation = options.orientation;
5740
5818
  }
5819
+ if (hasFloatingGroupOptionsChanged) {
5820
+ for (const group of this.floatingGroups) {
5821
+ switch (this.options.floatingGroupBounds) {
5822
+ case 'boundedWithinViewport':
5823
+ group.overlay.minimumInViewportHeight = undefined;
5824
+ group.overlay.minimumInViewportWidth = undefined;
5825
+ break;
5826
+ case undefined:
5827
+ group.overlay.minimumInViewportHeight =
5828
+ DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE;
5829
+ group.overlay.minimumInViewportWidth =
5830
+ DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE;
5831
+ break;
5832
+ default:
5833
+ group.overlay.minimumInViewportHeight =
5834
+ (_a = this.options.floatingGroupBounds) === null || _a === void 0 ? void 0 : _a.minimumHeightWithinViewport;
5835
+ group.overlay.minimumInViewportWidth =
5836
+ (_b = this.options.floatingGroupBounds) === null || _b === void 0 ? void 0 : _b.minimumWidthWithinViewport;
5837
+ }
5838
+ group.overlay.setBounds({});
5839
+ }
5840
+ }
5741
5841
  this.layout(this.gridview.width, this.gridview.height, true);
5742
5842
  }
5743
5843
  layout(width, height, forceResize) {
@@ -6220,7 +6320,11 @@
6220
6320
  const view = new DockviewGroupPanel(this, id, options);
6221
6321
  view.init({ params: {}, accessor: null }); // required to initialized .part and allow for correct disposal of group
6222
6322
  if (!this._groups.has(view.id)) {
6223
- const disposable = new CompositeDisposable(view.model.onMove((event) => {
6323
+ const disposable = new CompositeDisposable(view.model.onTabDragStart((event) => {
6324
+ this._onWillDragPanel.fire(event);
6325
+ }), view.model.onGroupDragStart((event) => {
6326
+ this._onWillDragGroup.fire(event);
6327
+ }), view.model.onMove((event) => {
6224
6328
  const { groupId, itemId, target, index } = event;
6225
6329
  this.moveGroupOrPanel(view, groupId, itemId, target, index);
6226
6330
  }), view.model.onDidDrop((event) => {
@@ -6259,13 +6363,6 @@
6259
6363
  var _a;
6260
6364
  return (_a = Array.from(this._groups.values()).find((group) => group.value.model.containsPanel(panel))) === null || _a === void 0 ? void 0 : _a.value;
6261
6365
  }
6262
- dispose() {
6263
- this._onDidActivePanelChange.dispose();
6264
- this._onDidAddPanel.dispose();
6265
- this._onDidRemovePanel.dispose();
6266
- this._onDidLayoutFromJSON.dispose();
6267
- super.dispose();
6268
- }
6269
6366
  }
6270
6367
 
6271
6368
  class GridviewComponent extends BaseGrid {