dockview 1.0.3 → 1.1.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 (209) hide show
  1. package/README.md +243 -186
  2. package/dist/cjs/api/component.api.d.ts +28 -19
  3. package/dist/cjs/api/component.api.js +104 -33
  4. package/dist/cjs/api/component.api.js.map +1 -1
  5. package/dist/cjs/api/gridviewPanelApi.js +1 -0
  6. package/dist/cjs/api/gridviewPanelApi.js.map +1 -1
  7. package/dist/cjs/api/groupPanelApi.d.ts +11 -14
  8. package/dist/cjs/api/groupPanelApi.js +19 -17
  9. package/dist/cjs/api/groupPanelApi.js.map +1 -1
  10. package/dist/cjs/api/panelApi.d.ts +0 -25
  11. package/dist/cjs/api/panelApi.js +1 -20
  12. package/dist/cjs/api/panelApi.js.map +1 -1
  13. package/dist/cjs/api/paneviewPanelApi.js +1 -0
  14. package/dist/cjs/api/paneviewPanelApi.js.map +1 -1
  15. package/dist/cjs/api/splitviewPanelApi.d.ts +0 -1
  16. package/dist/cjs/api/splitviewPanelApi.js +1 -5
  17. package/dist/cjs/api/splitviewPanelApi.js.map +1 -1
  18. package/dist/cjs/dnd/abstractDragHandler.d.ts +3 -3
  19. package/dist/cjs/dnd/abstractDragHandler.js +15 -14
  20. package/dist/cjs/dnd/abstractDragHandler.js.map +1 -1
  21. package/dist/cjs/dnd/dataTransfer.d.ts +0 -25
  22. package/dist/cjs/dnd/dataTransfer.js +1 -45
  23. package/dist/cjs/dnd/dataTransfer.js.map +1 -1
  24. package/dist/cjs/dnd/dnd.d.ts +1 -14
  25. package/dist/cjs/dnd/dnd.js +1 -79
  26. package/dist/cjs/dnd/dnd.js.map +1 -1
  27. package/dist/cjs/dnd/droptarget.d.ts +3 -0
  28. package/dist/cjs/dnd/droptarget.js +69 -45
  29. package/dist/cjs/dnd/droptarget.js.map +1 -1
  30. package/dist/cjs/dockview/components/tab/defaultTab.d.ts +0 -1
  31. package/dist/cjs/dockview/components/tab/defaultTab.js +0 -8
  32. package/dist/cjs/dockview/components/tab/defaultTab.js.map +1 -1
  33. package/dist/cjs/dockview/dockviewComponent.d.ts +27 -19
  34. package/dist/cjs/dockview/dockviewComponent.js +67 -178
  35. package/dist/cjs/dockview/dockviewComponent.js.map +1 -1
  36. package/dist/cjs/dockview/dockviewGroupPanel.d.ts +2 -5
  37. package/dist/cjs/dockview/dockviewGroupPanel.js +2 -31
  38. package/dist/cjs/dockview/dockviewGroupPanel.js.map +1 -1
  39. package/dist/cjs/dockview/options.d.ts +2 -1
  40. package/dist/cjs/events.js +25 -4
  41. package/dist/cjs/events.js.map +1 -1
  42. package/dist/cjs/gridview/baseComponentGridview.d.ts +9 -0
  43. package/dist/cjs/gridview/baseComponentGridview.js +14 -2
  44. package/dist/cjs/gridview/baseComponentGridview.js.map +1 -1
  45. package/dist/cjs/gridview/basePanelView.d.ts +5 -8
  46. package/dist/cjs/gridview/basePanelView.js +14 -8
  47. package/dist/cjs/gridview/basePanelView.js.map +1 -1
  48. package/dist/cjs/gridview/branchNode.js +1 -1
  49. package/dist/cjs/gridview/branchNode.js.map +1 -1
  50. package/dist/cjs/gridview/gridview.js +19 -17
  51. package/dist/cjs/gridview/gridview.js.map +1 -1
  52. package/dist/cjs/gridview/gridviewComponent.d.ts +4 -0
  53. package/dist/cjs/gridview/gridviewComponent.js +5 -0
  54. package/dist/cjs/gridview/gridviewComponent.js.map +1 -1
  55. package/dist/cjs/gridview/gridviewPanel.d.ts +0 -1
  56. package/dist/cjs/gridview/gridviewPanel.js +3 -6
  57. package/dist/cjs/gridview/gridviewPanel.js.map +1 -1
  58. package/dist/cjs/gridview/leafNode.js +1 -0
  59. package/dist/cjs/gridview/leafNode.js.map +1 -1
  60. package/dist/cjs/groupview/groupPanel.d.ts +0 -7
  61. package/dist/cjs/groupview/groupview.d.ts +15 -8
  62. package/dist/cjs/groupview/groupview.js +36 -123
  63. package/dist/cjs/groupview/groupview.js.map +1 -1
  64. package/dist/cjs/groupview/groupviewPanel.d.ts +5 -2
  65. package/dist/cjs/groupview/groupviewPanel.js.map +1 -1
  66. package/dist/cjs/groupview/panel/content.js +1 -0
  67. package/dist/cjs/groupview/panel/content.js.map +1 -1
  68. package/dist/cjs/groupview/tab.d.ts +10 -13
  69. package/dist/cjs/groupview/tab.js +22 -80
  70. package/dist/cjs/groupview/tab.js.map +1 -1
  71. package/dist/cjs/groupview/titlebar/tabsContainer.js +4 -6
  72. package/dist/cjs/groupview/titlebar/tabsContainer.js.map +1 -1
  73. package/dist/cjs/index.d.ts +1 -1
  74. package/dist/cjs/lifecycle.js +2 -1
  75. package/dist/cjs/lifecycle.js.map +1 -1
  76. package/dist/cjs/panel/types.d.ts +0 -2
  77. package/dist/cjs/paneview/draggablePaneviewPanel.d.ts +2 -2
  78. package/dist/cjs/paneview/draggablePaneviewPanel.js +31 -28
  79. package/dist/cjs/paneview/draggablePaneviewPanel.js.map +1 -1
  80. package/dist/cjs/paneview/paneview.js +1 -1
  81. package/dist/cjs/paneview/paneview.js.map +1 -1
  82. package/dist/cjs/paneview/paneviewComponent.d.ts +0 -3
  83. package/dist/cjs/paneview/paneviewComponent.js +1 -0
  84. package/dist/cjs/paneview/paneviewComponent.js.map +1 -1
  85. package/dist/cjs/paneview/paneviewPanel.js +1 -1
  86. package/dist/cjs/paneview/paneviewPanel.js.map +1 -1
  87. package/dist/cjs/react/deserializer.js +1 -3
  88. package/dist/cjs/react/deserializer.js.map +1 -1
  89. package/dist/cjs/react/dockview/dockview.d.ts +9 -9
  90. package/dist/cjs/react/dockview/dockview.js +14 -1
  91. package/dist/cjs/react/dockview/dockview.js.map +1 -1
  92. package/dist/cjs/react/dockview/reactContentPart.js +4 -4
  93. package/dist/cjs/react/dockview/reactContentPart.js.map +1 -1
  94. package/dist/cjs/react/dockview/reactHeaderPart.js +1 -0
  95. package/dist/cjs/react/dockview/reactHeaderPart.js.map +1 -1
  96. package/dist/cjs/react/dockview/reactWatermarkPart.d.ts +1 -2
  97. package/dist/cjs/react/dockview/reactWatermarkPart.js +1 -2
  98. package/dist/cjs/react/dockview/reactWatermarkPart.js.map +1 -1
  99. package/dist/cjs/react/gridview/view.js +2 -2
  100. package/dist/cjs/react/gridview/view.js.map +1 -1
  101. package/dist/cjs/react/index.d.ts +1 -0
  102. package/dist/cjs/react/index.js.map +1 -1
  103. package/dist/cjs/react/react.js +1 -2
  104. package/dist/cjs/react/react.js.map +1 -1
  105. package/dist/cjs/react/splitview/view.js +2 -2
  106. package/dist/cjs/react/splitview/view.js.map +1 -1
  107. package/dist/cjs/splitview/splitviewComponent.d.ts +0 -3
  108. package/dist/cjs/splitview/splitviewComponent.js +1 -1
  109. package/dist/cjs/splitview/splitviewComponent.js.map +1 -1
  110. package/dist/cjs/splitview/splitviewPanel.d.ts +1 -6
  111. package/dist/cjs/splitview/splitviewPanel.js +5 -3
  112. package/dist/cjs/splitview/splitviewPanel.js.map +1 -1
  113. package/dist/dockview.amd.js +394 -532
  114. package/dist/dockview.amd.min.js +2 -16
  115. package/dist/dockview.amd.min.noStyle.js +2 -16
  116. package/dist/dockview.amd.noStyle.js +393 -531
  117. package/dist/dockview.cjs.js +394 -532
  118. package/dist/dockview.esm.js +395 -528
  119. package/dist/dockview.esm.min.js +2 -16
  120. package/dist/dockview.js +394 -532
  121. package/dist/dockview.min.js +2 -16
  122. package/dist/dockview.min.noStyle.js +2 -16
  123. package/dist/dockview.noStyle.js +393 -531
  124. package/dist/esm/api/component.api.d.ts +28 -19
  125. package/dist/esm/api/component.api.js +48 -21
  126. package/dist/esm/api/gridviewPanelApi.js +1 -0
  127. package/dist/esm/api/groupPanelApi.d.ts +11 -14
  128. package/dist/esm/api/groupPanelApi.js +18 -13
  129. package/dist/esm/api/panelApi.d.ts +0 -25
  130. package/dist/esm/api/panelApi.js +1 -20
  131. package/dist/esm/api/paneviewPanelApi.js +1 -0
  132. package/dist/esm/api/splitviewPanelApi.d.ts +0 -1
  133. package/dist/esm/api/splitviewPanelApi.js +1 -5
  134. package/dist/esm/dnd/abstractDragHandler.d.ts +3 -3
  135. package/dist/esm/dnd/abstractDragHandler.js +9 -8
  136. package/dist/esm/dnd/dataTransfer.d.ts +0 -25
  137. package/dist/esm/dnd/dataTransfer.js +0 -40
  138. package/dist/esm/dnd/dnd.d.ts +1 -14
  139. package/dist/esm/dnd/dnd.js +1 -69
  140. package/dist/esm/dnd/droptarget.d.ts +3 -0
  141. package/dist/esm/dnd/droptarget.js +69 -45
  142. package/dist/esm/dockview/components/tab/defaultTab.d.ts +0 -1
  143. package/dist/esm/dockview/components/tab/defaultTab.js +1 -9
  144. package/dist/esm/dockview/dockviewComponent.d.ts +27 -19
  145. package/dist/esm/dockview/dockviewComponent.js +54 -118
  146. package/dist/esm/dockview/dockviewGroupPanel.d.ts +2 -5
  147. package/dist/esm/dockview/dockviewGroupPanel.js +2 -30
  148. package/dist/esm/dockview/options.d.ts +2 -1
  149. package/dist/esm/events.js +2 -3
  150. package/dist/esm/gridview/baseComponentGridview.d.ts +9 -0
  151. package/dist/esm/gridview/baseComponentGridview.js +14 -2
  152. package/dist/esm/gridview/basePanelView.d.ts +5 -8
  153. package/dist/esm/gridview/basePanelView.js +10 -8
  154. package/dist/esm/gridview/branchNode.js +1 -1
  155. package/dist/esm/gridview/gridview.js +16 -15
  156. package/dist/esm/gridview/gridviewComponent.d.ts +4 -0
  157. package/dist/esm/gridview/gridviewComponent.js +5 -0
  158. package/dist/esm/gridview/gridviewPanel.d.ts +0 -1
  159. package/dist/esm/gridview/gridviewPanel.js +3 -6
  160. package/dist/esm/gridview/leafNode.js +1 -0
  161. package/dist/esm/groupview/groupPanel.d.ts +0 -7
  162. package/dist/esm/groupview/groupview.d.ts +15 -8
  163. package/dist/esm/groupview/groupview.js +22 -56
  164. package/dist/esm/groupview/groupviewPanel.d.ts +5 -2
  165. package/dist/esm/groupview/panel/content.js +1 -0
  166. package/dist/esm/groupview/tab.d.ts +10 -13
  167. package/dist/esm/groupview/tab.js +17 -24
  168. package/dist/esm/groupview/titlebar/tabsContainer.js +4 -6
  169. package/dist/esm/index.d.ts +1 -1
  170. package/dist/esm/lifecycle.js +2 -1
  171. package/dist/esm/panel/types.d.ts +0 -2
  172. package/dist/esm/paneview/draggablePaneviewPanel.d.ts +2 -2
  173. package/dist/esm/paneview/draggablePaneviewPanel.js +31 -28
  174. package/dist/esm/paneview/paneview.js +1 -1
  175. package/dist/esm/paneview/paneviewComponent.d.ts +0 -3
  176. package/dist/esm/paneview/paneviewComponent.js +1 -0
  177. package/dist/esm/paneview/paneviewPanel.js +1 -1
  178. package/dist/esm/react/deserializer.js +1 -3
  179. package/dist/esm/react/dockview/dockview.d.ts +9 -9
  180. package/dist/esm/react/dockview/dockview.js +15 -2
  181. package/dist/esm/react/dockview/reactContentPart.js +4 -4
  182. package/dist/esm/react/dockview/reactHeaderPart.js +1 -0
  183. package/dist/esm/react/dockview/reactWatermarkPart.d.ts +1 -2
  184. package/dist/esm/react/dockview/reactWatermarkPart.js +1 -2
  185. package/dist/esm/react/gridview/view.js +2 -2
  186. package/dist/esm/react/index.d.ts +1 -0
  187. package/dist/esm/react/react.js +1 -2
  188. package/dist/esm/react/splitview/view.js +2 -2
  189. package/dist/esm/splitview/splitviewComponent.d.ts +0 -3
  190. package/dist/esm/splitview/splitviewComponent.js +1 -1
  191. package/dist/esm/splitview/splitviewPanel.d.ts +1 -6
  192. package/dist/esm/splitview/splitviewPanel.js +5 -3
  193. package/dist/styles/dockview.css +5 -9
  194. package/package.json +2 -2
  195. package/dist/cjs/functions.d.ts +0 -1
  196. package/dist/cjs/functions.js +0 -42
  197. package/dist/cjs/functions.js.map +0 -1
  198. package/dist/cjs/groupview/panel/hostedPanel.d.ts +0 -22
  199. package/dist/cjs/groupview/panel/hostedPanel.js +0 -57
  200. package/dist/cjs/groupview/panel/hostedPanel.js.map +0 -1
  201. package/dist/cjs/json.d.ts +0 -1
  202. package/dist/cjs/json.js +0 -14
  203. package/dist/cjs/json.js.map +0 -1
  204. package/dist/esm/functions.d.ts +0 -1
  205. package/dist/esm/functions.js +0 -8
  206. package/dist/esm/groupview/panel/hostedPanel.d.ts +0 -22
  207. package/dist/esm/groupview/panel/hostedPanel.js +0 -43
  208. package/dist/esm/json.d.ts +0 -1
  209. package/dist/esm/json.js +0 -9
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * dockview
3
- * @version 1.0.3
3
+ * @version 1.1.0
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -61,7 +61,6 @@
61
61
  if (((_a = this.options) === null || _a === void 0 ? void 0 : _a.replay) && this._last !== undefined) {
62
62
  listener(this._last);
63
63
  }
64
- this._listeners.length === 0;
65
64
  this._listeners.push(listener);
66
65
  return {
67
66
  dispose: () => {
@@ -77,9 +76,9 @@
77
76
  }
78
77
  fire(e) {
79
78
  this._last = e;
80
- this._listeners.forEach((listener) => {
79
+ for (const listener of this._listeners) {
81
80
  listener(e);
82
- });
81
+ }
83
82
  }
84
83
  dispose() {
85
84
  this._listeners = [];
@@ -137,7 +136,7 @@
137
136
  return new CompositeDisposable(...args);
138
137
  }
139
138
  addDisposables(...args) {
140
- args === null || args === void 0 ? void 0 : args.forEach((arg) => this.disposables.push(arg));
139
+ args.forEach((arg) => this.disposables.push(arg));
141
140
  }
142
141
  dispose() {
143
142
  this.disposables.forEach((arg) => arg.dispose());
@@ -156,20 +155,11 @@
156
155
  dispose() {
157
156
  if (this._disposable) {
158
157
  this._disposable.dispose();
158
+ this._disposable = exports.Disposable.NONE;
159
159
  }
160
160
  }
161
161
  }
162
162
 
163
- function tryParseJSON(text, reviver) {
164
- try {
165
- return JSON.parse(text, reviver);
166
- }
167
- catch (err) {
168
- console.warn('failed to parse JSON');
169
- return undefined;
170
- }
171
- }
172
-
173
163
  class TransferObject {
174
164
  constructor() {
175
165
  //
@@ -190,45 +180,6 @@
190
180
  this.paneId = paneId;
191
181
  }
192
182
  }
193
- const DATA_KEY = 'splitview/transfer';
194
- const isPanelTransferEvent = (event) => {
195
- if (!event.dataTransfer) {
196
- return false;
197
- }
198
- return event.dataTransfer.types.includes(DATA_KEY);
199
- };
200
- exports.DragType = void 0;
201
- (function (DragType) {
202
- DragType["DOCKVIEW_TAB"] = "dockview_tab";
203
- DragType["EXTERNAL"] = "external_group_drag";
204
- })(exports.DragType || (exports.DragType = {}));
205
- /**
206
- * Determine whether this data belong to that of an event that was started by
207
- * dragging a tab component
208
- */
209
- const isTabDragEvent = (data) => {
210
- return data.type === exports.DragType.DOCKVIEW_TAB;
211
- };
212
- /**
213
- * Determine whether this data belong to that of an event that was started by
214
- * a custom drag-enable component
215
- */
216
- const isCustomDragEvent = (data) => {
217
- return data.type === exports.DragType.EXTERNAL;
218
- };
219
- const extractData = (event) => {
220
- if (!event.dataTransfer) {
221
- return null;
222
- }
223
- const data = tryParseJSON(event.dataTransfer.getData(DATA_KEY));
224
- if (!data) {
225
- console.warn(`[dragEvent] ${DATA_KEY} data is missing`);
226
- }
227
- if (typeof data.type !== 'string') {
228
- console.warn(`[dragEvent] invalid type ${data.type}`);
229
- }
230
- return data;
231
- };
232
183
  /**
233
184
  * A singleton to store transfer data during drag & drop operations that are only valid within the application.
234
185
  */
@@ -298,6 +249,9 @@
298
249
  get length() {
299
250
  return this.component.length;
300
251
  }
252
+ get orientation() {
253
+ return this.component.orientation;
254
+ }
301
255
  get onDidLayoutChange() {
302
256
  return this.component.onDidLayoutChange;
303
257
  }
@@ -307,9 +261,6 @@
307
261
  get onDidRemoveView() {
308
262
  return this.component.onDidRemoveView;
309
263
  }
310
- get orientation() {
311
- return this.component.orientation;
312
- }
313
264
  updateOptions(options) {
314
265
  this.component.updateOptions(options);
315
266
  }
@@ -354,18 +305,18 @@
354
305
  constructor(component) {
355
306
  this.component = component;
356
307
  }
357
- get width() {
358
- return this.component.width;
359
- }
360
- get height() {
361
- return this.component.height;
362
- }
363
308
  get minimumSize() {
364
309
  return this.component.minimumSize;
365
310
  }
366
311
  get maximumSize() {
367
312
  return this.component.maximumSize;
368
313
  }
314
+ get height() {
315
+ return this.component.height;
316
+ }
317
+ get width() {
318
+ return this.component.width;
319
+ }
369
320
  get onDidLayoutChange() {
370
321
  return this.component.onDidLayoutChange;
371
322
  }
@@ -421,12 +372,6 @@
421
372
  constructor(component) {
422
373
  this.component = component;
423
374
  }
424
- get width() {
425
- return this.component.width;
426
- }
427
- get height() {
428
- return this.component.height;
429
- }
430
375
  get minimumHeight() {
431
376
  return this.component.minimumHeight;
432
377
  }
@@ -439,12 +384,30 @@
439
384
  get maximumWidth() {
440
385
  return this.component.maximumWidth;
441
386
  }
387
+ get width() {
388
+ return this.component.width;
389
+ }
390
+ get height() {
391
+ return this.component.height;
392
+ }
442
393
  get onGridEvent() {
443
394
  return this.component.onGridEvent;
444
395
  }
445
396
  get onDidLayoutChange() {
446
397
  return this.component.onDidLayoutChange;
447
398
  }
399
+ get onDidAddGroup() {
400
+ return this.component.onDidAddGroup;
401
+ }
402
+ get onDidRemoveGroup() {
403
+ return this.component.onDidRemoveGroup;
404
+ }
405
+ get onDidActiveGroupChange() {
406
+ return this.component.onDidActiveGroupChange;
407
+ }
408
+ get onDidLayoutFromJSON() {
409
+ return this.component.onDidLayoutFromJSON;
410
+ }
448
411
  get panels() {
449
412
  return this.component.groups;
450
413
  }
@@ -522,6 +485,27 @@
522
485
  get onGridEvent() {
523
486
  return this.component.onGridEvent;
524
487
  }
488
+ get onDidActiveGroupChange() {
489
+ return this.component.onDidActiveGroupChange;
490
+ }
491
+ get onDidAddGroup() {
492
+ return this.component.onDidAddGroup;
493
+ }
494
+ get onDidRemoveGroup() {
495
+ return this.component.onDidRemoveGroup;
496
+ }
497
+ get onDidActivePanelChange() {
498
+ return this.component.onDidActivePanelChange;
499
+ }
500
+ get onDidAddPanel() {
501
+ return this.component.onDidAddPanel;
502
+ }
503
+ get onDidRemovePanel() {
504
+ return this.component.onDidRemovePanel;
505
+ }
506
+ get onDidLayoutfromJSON() {
507
+ return this.component.onDidLayoutfromJSON;
508
+ }
525
509
  get onDidLayoutChange() {
526
510
  return this.component.onDidLayoutChange;
527
511
  }
@@ -549,18 +533,12 @@
549
533
  getPanel(id) {
550
534
  return this.component.getGroupPanel(id);
551
535
  }
552
- setActivePanel(panel) {
553
- this.component.setActivePanel(panel);
554
- }
555
536
  layout(width, height, force = false) {
556
537
  this.component.layout(width, height, force);
557
538
  }
558
539
  addPanel(options) {
559
540
  return this.component.addPanel(options);
560
541
  }
561
- removePanel(panel) {
562
- this.component.removePanel(panel);
563
- }
564
542
  addEmptyGroup(options) {
565
543
  this.component.addEmptyGroup(options);
566
544
  }
@@ -1580,7 +1558,7 @@
1580
1558
  this.paneItems.push(paneItem);
1581
1559
  pane.orthogonalSize = this.splitview.orthogonalSize;
1582
1560
  });
1583
- this.addDisposables(this.splitview.onDidSashEnd(() => {
1561
+ this.addDisposables(this._onDidChange, this.splitview.onDidSashEnd(() => {
1584
1562
  this._onDidChange.fire(undefined);
1585
1563
  }), this.splitview.onDidAddView(() => {
1586
1564
  this._onDidChange.fire();
@@ -1741,7 +1719,7 @@
1741
1719
  this.options = options;
1742
1720
  this._onDrop = new Emitter();
1743
1721
  this.onDrop = this._onDrop.event;
1744
- this.addDisposables(new DragAndDropObserver(this.element, {
1722
+ this.addDisposables(this._onDrop, new DragAndDropObserver(this.element, {
1745
1723
  onDragEnter: (e) => undefined,
1746
1724
  onDragOver: (e) => {
1747
1725
  if (isBooleanValue(this.options.canDisplayOverlay)) {
@@ -1777,51 +1755,11 @@
1777
1755
  const y = e.offsetY;
1778
1756
  const xp = (100 * x) / width;
1779
1757
  const yp = (100 * y) / height;
1780
- let isRight = false;
1781
- let isLeft = false;
1782
- let isTop = false;
1783
- let isBottom = false;
1784
- switch (this.options.validOverlays) {
1785
- case 'all':
1786
- isRight = xp > 80;
1787
- isLeft = xp < 20;
1788
- isTop = !isRight && !isLeft && yp < 20;
1789
- isBottom = !isRight && !isLeft && yp > 80;
1790
- break;
1791
- case 'vertical':
1792
- isTop = yp < 50;
1793
- isBottom = yp >= 50;
1794
- break;
1795
- case 'horizontal':
1796
- isLeft = xp < 50;
1797
- isRight = xp >= 50;
1798
- break;
1799
- }
1758
+ const quadrant = this.calculateQuadrant(this.options.validOverlays, xp, yp);
1800
1759
  const isSmallX = width < 100;
1801
1760
  const isSmallY = height < 100;
1802
- toggleClass(this.overlay, 'right', !isSmallX && isRight);
1803
- toggleClass(this.overlay, 'left', !isSmallX && isLeft);
1804
- toggleClass(this.overlay, 'top', !isSmallY && isTop);
1805
- toggleClass(this.overlay, 'bottom', !isSmallY && isBottom);
1806
- toggleClass(this.overlay, 'small-right', isSmallX && isRight);
1807
- toggleClass(this.overlay, 'small-left', isSmallX && isLeft);
1808
- toggleClass(this.overlay, 'small-top', isSmallY && isTop);
1809
- toggleClass(this.overlay, 'small-bottom', isSmallY && isBottom);
1810
- if (isRight) {
1811
- this._state = exports.Position.Right;
1812
- }
1813
- else if (isLeft) {
1814
- this._state = exports.Position.Left;
1815
- }
1816
- else if (isTop) {
1817
- this._state = exports.Position.Top;
1818
- }
1819
- else if (isBottom) {
1820
- this._state = exports.Position.Bottom;
1821
- }
1822
- else {
1823
- this._state = exports.Position.Center;
1824
- }
1761
+ this.toggleClasses(quadrant, isSmallX, isSmallY);
1762
+ this.setState(quadrant);
1825
1763
  },
1826
1764
  onDragLeave: (e) => {
1827
1765
  this.removeDropTarget();
@@ -1850,9 +1788,73 @@
1850
1788
  this.options.canDisplayOverlay = value;
1851
1789
  }
1852
1790
  dispose() {
1853
- this._onDrop.dispose();
1854
1791
  this.removeDropTarget();
1855
1792
  }
1793
+ toggleClasses(quadrant, isSmallX, isSmallY) {
1794
+ if (!this.overlay) {
1795
+ return;
1796
+ }
1797
+ const isLeft = quadrant === 'left';
1798
+ const isRight = quadrant === 'right';
1799
+ const isTop = quadrant === 'top';
1800
+ const isBottom = quadrant === 'bottom';
1801
+ toggleClass(this.overlay, 'right', !isSmallX && isRight);
1802
+ toggleClass(this.overlay, 'left', !isSmallX && isLeft);
1803
+ toggleClass(this.overlay, 'top', !isSmallY && isTop);
1804
+ toggleClass(this.overlay, 'bottom', !isSmallY && isBottom);
1805
+ toggleClass(this.overlay, 'small-right', isSmallX && isRight);
1806
+ toggleClass(this.overlay, 'small-left', isSmallX && isLeft);
1807
+ toggleClass(this.overlay, 'small-top', isSmallY && isTop);
1808
+ toggleClass(this.overlay, 'small-bottom', isSmallY && isBottom);
1809
+ }
1810
+ setState(quadrant) {
1811
+ switch (quadrant) {
1812
+ case 'top':
1813
+ this._state = exports.Position.Top;
1814
+ break;
1815
+ case 'left':
1816
+ this._state = exports.Position.Left;
1817
+ break;
1818
+ case 'bottom':
1819
+ this._state = exports.Position.Bottom;
1820
+ break;
1821
+ case 'right':
1822
+ this._state = exports.Position.Right;
1823
+ break;
1824
+ default:
1825
+ this._state = exports.Position.Center;
1826
+ break;
1827
+ }
1828
+ }
1829
+ calculateQuadrant(overlayType, xp, yp) {
1830
+ switch (overlayType) {
1831
+ case 'all':
1832
+ if (xp < 20) {
1833
+ return 'left';
1834
+ }
1835
+ if (xp > 80) {
1836
+ return 'right';
1837
+ }
1838
+ if (yp < 20) {
1839
+ return 'top';
1840
+ }
1841
+ if (yp > 80) {
1842
+ return 'bottom';
1843
+ }
1844
+ break;
1845
+ case 'vertical':
1846
+ if (yp < 50) {
1847
+ return 'top';
1848
+ }
1849
+ return 'bottom';
1850
+ case 'horizontal':
1851
+ if (xp < 50) {
1852
+ return 'left';
1853
+ }
1854
+ return 'right';
1855
+ }
1856
+ return null;
1857
+ }
1856
1858
  removeDropTarget() {
1857
1859
  if (this.target) {
1858
1860
  this._state = undefined;
@@ -1955,6 +1957,7 @@
1955
1957
  this.view.layout(this.width, this.height);
1956
1958
  }
1957
1959
  dispose() {
1960
+ this._onDidChange.dispose();
1958
1961
  this._disposable.dispose();
1959
1962
  }
1960
1963
  }
@@ -2006,7 +2009,7 @@
2006
2009
  proportionalLayout,
2007
2010
  });
2008
2011
  }
2009
- this.addDisposables(this.splitview.onDidSashEnd(() => {
2012
+ this.addDisposables(this._onDidChange, this.splitview.onDidSashEnd(() => {
2010
2013
  this._onDidChange.fire(undefined);
2011
2014
  }));
2012
2015
  this.setupChildrenEvents();
@@ -2178,6 +2181,15 @@
2178
2181
  * Accreditation: This file is largly based upon the MIT licenced VSCode sourcecode found at:
2179
2182
  * https://github.com/microsoft/vscode/tree/main/src/vs/base/browser/ui/grid
2180
2183
  *--------------------------------------------------------------------------------------------*/
2184
+ function findLeaf(candiateNode, last) {
2185
+ if (candiateNode instanceof LeafNode) {
2186
+ return candiateNode;
2187
+ }
2188
+ if (candiateNode instanceof BranchNode) {
2189
+ return findLeaf(candiateNode.children[last ? candiateNode.children.length - 1 : 0], last);
2190
+ }
2191
+ throw new Error('invalid node');
2192
+ }
2181
2193
  function flipNode(node, size, orthogonalSize) {
2182
2194
  if (node instanceof BranchNode) {
2183
2195
  const result = new BranchNode(orthogonal(node.orientation), node.proportionalLayout, node.styles, size, orthogonalSize);
@@ -2316,13 +2328,13 @@
2316
2328
  }
2317
2329
  deserialize(json, deserializer) {
2318
2330
  const orientation = json.orientation;
2319
- const height = json.height;
2331
+ const height = orientation === exports.Orientation.VERTICAL ? json.height : json.width;
2320
2332
  this._deserialize(json.root, orientation, deserializer, height);
2321
2333
  }
2322
2334
  _deserialize(root, orientation, deserializer, orthogonalSize) {
2323
- this.root = this._deserializeNode(root, orientation, deserializer, orthogonalSize);
2335
+ this.root = this._deserializeNode(root, orientation, deserializer, orthogonalSize, true);
2324
2336
  }
2325
- _deserializeNode(node, orientation, deserializer, orthogonalSize) {
2337
+ _deserializeNode(node, orientation, deserializer, orthogonalSize, isRoot = false) {
2326
2338
  let result;
2327
2339
  if (node.type === 'branch') {
2328
2340
  const serializedChildren = node.data;
@@ -2332,7 +2344,9 @@
2332
2344
  visible: serializedChild.visible,
2333
2345
  };
2334
2346
  });
2335
- result = new BranchNode(orientation, this.proportionalLayout, this.styles, node.size, orthogonalSize, children);
2347
+ // HORIZONTAL => height=orthogonalsize width=size
2348
+ // VERTICAL => height=size width=orthogonalsize
2349
+ result = new BranchNode(orientation, this.proportionalLayout, this.styles, isRoot ? orthogonalSize : node.size, isRoot ? node.size : orthogonalSize, children);
2336
2350
  }
2337
2351
  else {
2338
2352
  result = new LeafNode(deserializer.fromJSON(node), orientation, orthogonalSize, node.size);
@@ -2393,15 +2407,6 @@
2393
2407
  if (!(node instanceof LeafNode)) {
2394
2408
  throw new Error('invalid location');
2395
2409
  }
2396
- const findLeaf = (candiateNode, last) => {
2397
- if (candiateNode instanceof LeafNode) {
2398
- return candiateNode;
2399
- }
2400
- if (candiateNode instanceof BranchNode) {
2401
- return findLeaf(candiateNode.children[last ? candiateNode.children.length - 1 : 0], last);
2402
- }
2403
- throw new Error('invalid node');
2404
- };
2405
2410
  for (let i = path.length - 1; i > -1; i--) {
2406
2411
  const n = path[i];
2407
2412
  const l = location[i] || 0;
@@ -2503,9 +2508,9 @@
2503
2508
  if (parent.children.length > 1) {
2504
2509
  return node.view;
2505
2510
  }
2511
+ const sibling = parent.children[0];
2506
2512
  if (pathToParent.length === 0) {
2507
2513
  // parent is root
2508
- const sibling = parent.children[0];
2509
2514
  if (sibling instanceof LeafNode) {
2510
2515
  return node.view;
2511
2516
  }
@@ -2516,7 +2521,6 @@
2516
2521
  }
2517
2522
  const [grandParent, ..._] = [...pathToParent].reverse();
2518
2523
  const [parentIndex, ...__] = [...rest].reverse();
2519
- const sibling = parent.children[0];
2520
2524
  const isSiblingVisible = parent.isChildVisible(0);
2521
2525
  parent.removeChild(0, sizing);
2522
2526
  const sizes = grandParent.children.map((size, i) => grandParent.getChildSize(i));
@@ -2563,31 +2567,6 @@
2563
2567
  }
2564
2568
  }
2565
2569
 
2566
- /*! *****************************************************************************
2567
- Copyright (c) Microsoft Corporation.
2568
-
2569
- Permission to use, copy, modify, and/or distribute this software for any
2570
- purpose with or without fee is hereby granted.
2571
-
2572
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
2573
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
2574
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
2575
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
2576
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
2577
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
2578
- PERFORMANCE OF THIS SOFTWARE.
2579
- ***************************************************************************** */
2580
-
2581
- function __awaiter(thisArg, _arguments, P, generator) {
2582
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
2583
- return new (P || (P = Promise))(function (resolve, reject) {
2584
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
2585
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
2586
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
2587
- step((generator = generator.apply(thisArg, _arguments || [])).next());
2588
- });
2589
- }
2590
-
2591
2570
  class ContentContainer extends CompositeDisposable {
2592
2571
  constructor() {
2593
2572
  super();
@@ -2599,6 +2578,7 @@
2599
2578
  this._element = document.createElement('div');
2600
2579
  this._element.className = 'content-container';
2601
2580
  this._element.tabIndex = -1;
2581
+ this.addDisposables(this._onDidFocus, this._onDidBlur);
2602
2582
  // for hosted containers
2603
2583
  // 1) register a drop target on the host
2604
2584
  // 2) register window dragStart events to disable pointer events
@@ -2665,6 +2645,41 @@
2665
2645
  DockviewDropTargets[DockviewDropTargets["TabContainer"] = 2] = "TabContainer";
2666
2646
  })(DockviewDropTargets || (DockviewDropTargets = {}));
2667
2647
 
2648
+ class DragHandler extends CompositeDisposable {
2649
+ constructor(el) {
2650
+ super();
2651
+ this.el = el;
2652
+ this.disposable = new MutableDisposable();
2653
+ this._onDragStart = new Emitter();
2654
+ this.onDragStart = this._onDragStart.event;
2655
+ this.iframes = [];
2656
+ this.configure();
2657
+ }
2658
+ configure() {
2659
+ this.addDisposables(this._onDragStart, addDisposableListener(this.el, 'dragstart', (event) => {
2660
+ this.iframes = [
2661
+ ...getElementsByTagName('iframe'),
2662
+ ...getElementsByTagName('webview'),
2663
+ ];
2664
+ for (const iframe of this.iframes) {
2665
+ iframe.style.pointerEvents = 'none';
2666
+ }
2667
+ this.el.classList.add('dragged');
2668
+ setTimeout(() => this.el.classList.remove('dragged'), 0);
2669
+ this.disposable.value = this.getData();
2670
+ if (event.dataTransfer) {
2671
+ event.dataTransfer.effectAllowed = 'move';
2672
+ }
2673
+ }), addDisposableListener(this.el, 'dragend', (ev) => {
2674
+ for (const iframe of this.iframes) {
2675
+ iframe.style.pointerEvents = 'auto';
2676
+ }
2677
+ this.iframes = [];
2678
+ this.disposable.dispose();
2679
+ }));
2680
+ }
2681
+ }
2682
+
2668
2683
  exports.MouseEventKind = void 0;
2669
2684
  (function (MouseEventKind) {
2670
2685
  MouseEventKind["CLICK"] = "CLICK";
@@ -2674,42 +2689,34 @@
2674
2689
  constructor(panelId, accessor, group) {
2675
2690
  super();
2676
2691
  this.panelId = panelId;
2677
- this.accessor = accessor;
2678
2692
  this.group = group;
2679
2693
  this._onChanged = new Emitter();
2680
2694
  this.onChanged = this._onChanged.event;
2681
2695
  this._onDropped = new Emitter();
2682
2696
  this.onDrop = this._onDropped.event;
2683
- this.panelTransfer = LocalSelectionTransfer.getInstance();
2684
- this.iframes = [];
2685
2697
  this.addDisposables(this._onChanged, this._onDropped);
2686
2698
  this._element = document.createElement('div');
2687
2699
  this._element.className = 'tab';
2688
2700
  this._element.tabIndex = 0;
2689
2701
  this._element.draggable = true;
2690
- this.addDisposables(addDisposableListener(this._element, 'dragstart', (event) => {
2691
- this.iframes = [
2692
- ...getElementsByTagName('iframe'),
2693
- ...getElementsByTagName('webview'),
2694
- ];
2695
- for (const iframe of this.iframes) {
2696
- iframe.style.pointerEvents = 'none';
2702
+ this.addDisposables(new (class Handler extends DragHandler {
2703
+ constructor() {
2704
+ super(...arguments);
2705
+ this.panelTransfer = LocalSelectionTransfer.getInstance();
2697
2706
  }
2698
- this.element.classList.add('dragged');
2699
- setTimeout(() => this.element.classList.remove('dragged'), 0);
2700
- this.panelTransfer.setData([
2701
- new PanelTransfer(this.accessor.id, this.group.id, this.panelId),
2702
- ], PanelTransfer.prototype);
2703
- if (event.dataTransfer) {
2704
- event.dataTransfer.effectAllowed = 'move';
2707
+ getData() {
2708
+ this.panelTransfer.setData([new PanelTransfer(accessor.id, group.id, panelId)], PanelTransfer.prototype);
2709
+ return {
2710
+ dispose: () => {
2711
+ this.panelTransfer.clearData(PanelTransfer.prototype);
2712
+ },
2713
+ };
2705
2714
  }
2706
- }), addDisposableListener(this._element, 'dragend', (ev) => {
2707
- for (const iframe of this.iframes) {
2708
- iframe.style.pointerEvents = 'auto';
2715
+ dispose() {
2716
+ //
2709
2717
  }
2710
- this.iframes = [];
2711
- this.panelTransfer.clearData(PanelTransfer.prototype);
2712
- }), addDisposableListener(this._element, 'mousedown', (event) => {
2718
+ })(this._element));
2719
+ this.addDisposables(addDisposableListener(this._element, 'mousedown', (event) => {
2713
2720
  if (event.defaultPrevented) {
2714
2721
  return;
2715
2722
  }
@@ -2911,12 +2918,10 @@
2911
2918
  if (!isLeftClick || event.event.defaultPrevented) {
2912
2919
  return;
2913
2920
  }
2914
- switch (event.kind) {
2915
- case exports.MouseEventKind.CLICK:
2916
- this.group.model.openPanel(panel, {
2917
- skipFocus: alreadyFocused,
2918
- });
2919
- break;
2921
+ if (event.kind === exports.MouseEventKind.CLICK) {
2922
+ this.group.model.openPanel(panel, {
2923
+ skipFocus: alreadyFocused,
2924
+ });
2920
2925
  }
2921
2926
  }), tabToAdd.onDrop((event) => {
2922
2927
  this._onDrop.fire({
@@ -2945,7 +2950,6 @@
2945
2950
  GroupChangeKind2["ADD_PANEL"] = "ADD_PANEL";
2946
2951
  GroupChangeKind2["REMOVE_PANEL"] = "REMOVE_PANEL";
2947
2952
  GroupChangeKind2["PANEL_ACTIVE"] = "PANEL_ACTIVE";
2948
- GroupChangeKind2["GROUP_ACTIVE"] = "GROUP_ACTIVE";
2949
2953
  })(exports.GroupChangeKind2 || (exports.GroupChangeKind2 = {}));
2950
2954
  class Groupview extends CompositeDisposable {
2951
2955
  constructor(container, accessor, id, options, parent) {
@@ -2966,15 +2970,10 @@
2966
2970
  this.onMove = this._onMove.event;
2967
2971
  this._onDidGroupChange = new Emitter();
2968
2972
  this.onDidGroupChange = this._onDidGroupChange.event;
2969
- this.closePanel = (panel) => __awaiter(this, void 0, void 0, function* () {
2970
- if (panel.close && !(yield panel.close())) {
2971
- return false;
2972
- }
2973
- this.doClose(panel);
2974
- return true;
2975
- });
2973
+ this._onDidDrop = new Emitter();
2974
+ this.onDidDrop = this._onDidDrop.event;
2976
2975
  this.container.classList.add('groupview');
2977
- this.addDisposables(this._onMove, this._onDidGroupChange);
2976
+ this.addDisposables(this._onMove, this._onDidGroupChange, this._onDidChange, this._onDidDrop);
2978
2977
  this.tabsContainer = new TabsContainer(this.accessor, this.parent, {
2979
2978
  tabHeight: options.tabHeight,
2980
2979
  });
@@ -3131,6 +3130,8 @@
3131
3130
  options.index > this.panels.length) {
3132
3131
  options.index = this.panels.length;
3133
3132
  }
3133
+ // ensure the group is updated before we fire any events
3134
+ panel.updateParentGroup(this.parent, true);
3134
3135
  if (this._activePanel === panel) {
3135
3136
  this.accessor.doSetGroupActive(this.parent);
3136
3137
  return;
@@ -3151,43 +3152,19 @@
3151
3152
  return this._removePanel(panelToRemove);
3152
3153
  }
3153
3154
  closeAllPanels() {
3154
- var _a;
3155
- return __awaiter(this, void 0, void 0, function* () {
3156
- const index = this._activePanel
3157
- ? this.panels.indexOf(this._activePanel)
3158
- : -1;
3159
- if (this._activePanel && index > -1) {
3160
- if (this.panels.indexOf(this._activePanel) < 0) {
3161
- console.warn('active panel not tracked');
3162
- }
3163
- const canClose = !((_a = this._activePanel) === null || _a === void 0 ? void 0 : _a.close) || (yield this._activePanel.close());
3164
- if (!canClose) {
3165
- return false;
3166
- }
3167
- }
3168
- for (let i = 0; i < this.panels.length; i++) {
3169
- if (i === index) {
3170
- continue;
3171
- }
3172
- const panel = this.panels[i];
3173
- this.openPanel(panel);
3174
- if (panel.close) {
3175
- const canClose = yield panel.close();
3176
- if (!canClose) {
3177
- return false;
3178
- }
3179
- }
3180
- }
3181
- if (this.panels.length > 0) {
3182
- // take a copy since we will be edting the array as we iterate through
3183
- const arrPanelCpy = [...this.panels];
3184
- yield Promise.all(arrPanelCpy.map((p) => this.doClose(p)));
3155
+ if (this.panels.length > 0) {
3156
+ // take a copy since we will be edting the array as we iterate through
3157
+ const arrPanelCpy = [...this.panels];
3158
+ for (const panel of arrPanelCpy) {
3159
+ this.doClose(panel);
3185
3160
  }
3186
- else {
3187
- this.accessor.removeGroup(this.parent);
3188
- }
3189
- return true;
3190
- });
3161
+ }
3162
+ else {
3163
+ this.accessor.removeGroup(this.parent);
3164
+ }
3165
+ }
3166
+ closePanel(panel) {
3167
+ this.doClose(panel);
3191
3168
  }
3192
3169
  doClose(panel) {
3193
3170
  this.accessor.removePanel(panel);
@@ -3330,8 +3307,11 @@
3330
3307
  this.tabsContainer.show();
3331
3308
  }
3332
3309
  }
3333
- canDisplayOverlay(dragOverEvent, target) {
3310
+ canDisplayOverlay(event, target) {
3334
3311
  // custom overlay handler
3312
+ if (this.accessor.options.showDndOverlay) {
3313
+ return this.accessor.options.showDndOverlay(event, target);
3314
+ }
3335
3315
  return false;
3336
3316
  }
3337
3317
  handleDropEvent(event, position, index) {
@@ -3356,6 +3336,9 @@
3356
3336
  index,
3357
3337
  });
3358
3338
  }
3339
+ else {
3340
+ this._onDidDrop.fire({ nativeEvent: event, position, index });
3341
+ }
3359
3342
  }
3360
3343
  dispose() {
3361
3344
  for (const panel of this.panels) {
@@ -3408,10 +3391,15 @@
3408
3391
  this.onGridEvent = this._onGridEvent.event;
3409
3392
  this._onDidLayoutChange = new Emitter();
3410
3393
  this.onDidLayoutChange = this._onDidLayoutChange.event;
3394
+ this._onDidRemoveGroup = new Emitter();
3395
+ this.onDidRemoveGroup = this._onDidRemoveGroup.event;
3396
+ this._onDidAddGroup = new Emitter();
3397
+ this.onDidAddGroup = this._onDidAddGroup.event;
3398
+ this._onDidActiveGroupChange = new Emitter();
3399
+ this.onDidActiveGroupChange = this._onDidActiveGroupChange.event;
3411
3400
  this.gridview = new Gridview(!!options.proportionalLayout, options.styles, options.orientation);
3412
3401
  this.element.appendChild(this.gridview.element);
3413
- // TODO for some reason this is required before anything will layout correctly
3414
- this.layout(0, 0, true);
3402
+ this.layout(0, 0, true); // set some elements height/widths
3415
3403
  this.addDisposables(this.gridview.onDidChange(() => {
3416
3404
  this._onGridEvent.fire({ kind: exports.GroupChangeKind.LAYOUT });
3417
3405
  }));
@@ -3477,6 +3465,7 @@
3477
3465
  doAddGroup(group, location = [0], size) {
3478
3466
  this.gridview.addView(group, size !== null && size !== void 0 ? size : exports.Sizing.Distribute, location);
3479
3467
  this._onGridEvent.fire({ kind: exports.GroupChangeKind.ADD_GROUP });
3468
+ this._onDidAddGroup.fire(group);
3480
3469
  this.doSetGroupActive(group);
3481
3470
  }
3482
3471
  doRemoveGroup(group, options) {
@@ -3490,6 +3479,7 @@
3490
3479
  this._groups.delete(group.id);
3491
3480
  }
3492
3481
  this._onGridEvent.fire({ kind: exports.GroupChangeKind.REMOVE_GROUP });
3482
+ this._onDidRemoveGroup.fire(group);
3493
3483
  if (!(options === null || options === void 0 ? void 0 : options.skipActive) && this._activeGroup === group) {
3494
3484
  const groups = Array.from(this._groups.values());
3495
3485
  this.doSetGroupActive(groups.length > 0 ? groups[0].value : undefined);
@@ -3520,6 +3510,7 @@
3520
3510
  this._onGridEvent.fire({
3521
3511
  kind: exports.GroupChangeKind.GROUP_ACTIVE,
3522
3512
  });
3513
+ this._onDidActiveGroupChange.fire(group);
3523
3514
  }
3524
3515
  removeGroup(group) {
3525
3516
  this.doRemoveGroup(group);
@@ -3576,6 +3567,10 @@
3576
3567
  dispose() {
3577
3568
  super.dispose();
3578
3569
  this._onGridEvent.dispose();
3570
+ this._onDidActiveGroupChange.dispose();
3571
+ this._onDidAddGroup.dispose();
3572
+ this._onDidRemoveGroup.dispose();
3573
+ this._onDidLayoutChange.dispose();
3579
3574
  this.gridview.dispose();
3580
3575
  }
3581
3576
  }
@@ -3587,15 +3582,11 @@
3587
3582
  constructor(id) {
3588
3583
  super();
3589
3584
  this.id = id;
3590
- this._state = {};
3591
3585
  this._isFocused = false;
3592
3586
  this._isActive = false;
3593
3587
  this._isVisible = true;
3594
3588
  this._width = 0;
3595
3589
  this._height = 0;
3596
- this._onDidStateChange = new Emitter();
3597
- this.onDidStateChange = this._onDidStateChange.event;
3598
- //
3599
3590
  this._onDidPanelDimensionChange = new Emitter({
3600
3591
  replay: true,
3601
3592
  });
@@ -3624,7 +3615,7 @@
3624
3615
  //
3625
3616
  this._onActiveChange = new Emitter();
3626
3617
  this.onActiveChange = this._onActiveChange.event;
3627
- this.addDisposables(this._onDidStateChange, this._onDidPanelDimensionChange, this._onDidChangeFocus, this._onDidVisibilityChange, this._onDidActiveChange, this._onFocusEvent, this.onDidFocusChange((event) => {
3618
+ this.addDisposables(this._onDidPanelDimensionChange, this._onDidChangeFocus, this._onDidVisibilityChange, this._onDidActiveChange, this._onFocusEvent, this._onActiveChange, this._onVisibilityChange, this.onDidFocusChange((event) => {
3628
3619
  this._isFocused = event.isFocused;
3629
3620
  }), this.onDidActiveChange((event) => {
3630
3621
  this._isActive = event.isActive;
@@ -3657,21 +3648,6 @@
3657
3648
  setActive() {
3658
3649
  this._onActiveChange.fire();
3659
3650
  }
3660
- setState(key, value) {
3661
- if (typeof key === 'object') {
3662
- this._state = key;
3663
- }
3664
- else if (typeof value !== undefined) {
3665
- this._state[key] = value;
3666
- }
3667
- this._onDidStateChange.fire(undefined);
3668
- }
3669
- getState() {
3670
- return this._state;
3671
- }
3672
- getStateKey(key) {
3673
- return this._state[key];
3674
- }
3675
3651
  dispose() {
3676
3652
  super.dispose();
3677
3653
  }
@@ -3691,6 +3667,7 @@
3691
3667
  //
3692
3668
  this._onDidSizeChange = new Emitter();
3693
3669
  this.onDidSizeChange = this._onDidSizeChange.event;
3670
+ this.addDisposables(this._onDidConstraintsChangeInternal, this._onDidConstraintsChange, this._onDidSizeChange);
3694
3671
  }
3695
3672
  setConstraints(value) {
3696
3673
  this._onDidConstraintsChangeInternal.fire(value);
@@ -3704,19 +3681,19 @@
3704
3681
  constructor(panel, group) {
3705
3682
  super(panel.id);
3706
3683
  this.panel = panel;
3707
- this._onDidDirtyChange = new Emitter();
3708
- this.onDidDirtyChange = this._onDidDirtyChange.event;
3709
3684
  this._onDidTitleChange = new Emitter();
3710
3685
  this.onDidTitleChange = this._onDidTitleChange.event;
3711
3686
  this._titleChanged = new Emitter();
3712
3687
  this.titleChanged = this._titleChanged.event;
3713
3688
  this._suppressClosableChanged = new Emitter();
3714
3689
  this.suppressClosableChanged = this._suppressClosableChanged.event;
3715
- this._group = group;
3716
- this.addDisposables(this._onDidDirtyChange);
3717
- }
3718
- get tryClose() {
3719
- return this._interceptor;
3690
+ this._onDidActiveGroupChange = new Emitter();
3691
+ this.onDidActiveGroupChange = this._onDidActiveGroupChange.event;
3692
+ this._onDidGroupChange = new Emitter();
3693
+ this.onDidGroupChange = this._onDidGroupChange.event;
3694
+ this.disposable = new MutableDisposable();
3695
+ this.group = group;
3696
+ this.addDisposables(this.disposable, this._onDidTitleChange, this._titleChanged, this._suppressClosableChanged, this._onDidGroupChange, this._onDidActiveGroupChange);
3720
3697
  }
3721
3698
  get title() {
3722
3699
  return this.panel.title;
@@ -3729,7 +3706,17 @@
3729
3706
  return !!((_a = this.group) === null || _a === void 0 ? void 0 : _a.isActive);
3730
3707
  }
3731
3708
  set group(value) {
3709
+ const isOldGroupActive = this.isGroupActive;
3732
3710
  this._group = value;
3711
+ this._onDidGroupChange.fire();
3712
+ if (this._group) {
3713
+ this.disposable.value = this._group.api.onDidActiveChange(() => {
3714
+ this._onDidActiveGroupChange.fire();
3715
+ });
3716
+ if (this.isGroupActive !== isOldGroupActive) {
3717
+ this._onDidActiveGroupChange.fire();
3718
+ }
3719
+ }
3733
3720
  }
3734
3721
  get group() {
3735
3722
  return this._group;
@@ -3743,16 +3730,10 @@
3743
3730
  }
3744
3731
  return this.group.model.closePanel(this.panel);
3745
3732
  }
3746
- interceptOnCloseAction(interceptor) {
3747
- this._interceptor = interceptor;
3748
- }
3749
- dispose() {
3750
- super.dispose();
3751
- }
3752
3733
  }
3753
3734
 
3754
3735
  class DockviewGroupPanel extends CompositeDisposable {
3755
- constructor(id, containerApi) {
3736
+ constructor(id, accessor, containerApi) {
3756
3737
  super();
3757
3738
  this.id = id;
3758
3739
  this.containerApi = containerApi;
@@ -3760,9 +3741,8 @@
3760
3741
  this._suppressClosable = false;
3761
3742
  this._title = '';
3762
3743
  this.api = new DockviewPanelApiImpl(this, this._group);
3763
- this.onDidStateChange = this.api.onDidStateChange;
3764
3744
  this.addDisposables(this.api.onActiveChange(() => {
3765
- this.containerApi.setActivePanel(this);
3745
+ accessor.setActivePanel(this);
3766
3746
  }), this.api.onDidTitleChange((event) => {
3767
3747
  const title = event.title;
3768
3748
  this.update({ params: { title } });
@@ -3786,32 +3766,18 @@
3786
3766
  this._view = params.view;
3787
3767
  this.setTitle(params.title);
3788
3768
  this.setSuppressClosable(params.suppressClosable || false);
3789
- if (params.state) {
3790
- this.api.setState(params.state);
3791
- }
3792
3769
  (_a = this.view) === null || _a === void 0 ? void 0 : _a.init(Object.assign(Object.assign({}, params), { api: this.api, containerApi: this.containerApi }));
3793
3770
  }
3794
3771
  focus() {
3795
3772
  this.api._onFocusEvent.fire();
3796
3773
  }
3797
- setDirty(isDirty) {
3798
- this.api._onDidDirtyChange.fire(isDirty);
3799
- }
3800
- close() {
3801
- if (this.api.tryClose) {
3802
- return this.api.tryClose();
3803
- }
3804
- return Promise.resolve(true);
3805
- }
3806
3774
  toJSON() {
3807
- const state = this.api.getState();
3808
3775
  return {
3809
3776
  id: this.id,
3810
3777
  view: this.view.toJSON(),
3811
3778
  params: Object.keys(this._params || {}).length > 0
3812
3779
  ? this._params
3813
3780
  : undefined,
3814
- state: state && Object.keys(state).length > 0 ? state : undefined,
3815
3781
  suppressClosable: this.suppressClosable || undefined,
3816
3782
  title: this.title,
3817
3783
  };
@@ -3856,18 +3822,6 @@
3856
3822
  var _a;
3857
3823
  this._group = group;
3858
3824
  this.api.group = group;
3859
- this.mutableDisposable.value = this._group.model.onDidGroupChange((ev) => {
3860
- var _a;
3861
- if (ev.kind === exports.GroupChangeKind2.GROUP_ACTIVE) {
3862
- const isVisible = !!((_a = this._group) === null || _a === void 0 ? void 0 : _a.model.isPanelActive(this));
3863
- this.api._onDidActiveChange.fire({
3864
- isActive: isGroupActive && isVisible,
3865
- });
3866
- this.api._onDidVisibilityChange.fire({
3867
- isVisible,
3868
- });
3869
- }
3870
- });
3871
3825
  const isPanelVisible = this._group.model.isPanelActive(this);
3872
3826
  this.api._onDidActiveChange.fire({
3873
3827
  isActive: isGroupActive && isPanelVisible,
@@ -3977,15 +3931,6 @@
3977
3931
  }
3978
3932
  }
3979
3933
 
3980
- function debounce(cb, wait) {
3981
- let timeout;
3982
- const callable = (...args) => {
3983
- clearTimeout(timeout);
3984
- timeout = setTimeout(() => cb(...args), wait);
3985
- };
3986
- return callable;
3987
- }
3988
-
3989
3934
  class DefaultDeserializer {
3990
3935
  constructor(layout, panelDeserializer) {
3991
3936
  this.layout = layout;
@@ -4086,9 +4031,6 @@
4086
4031
  this._isGroupActive = false;
4087
4032
  //
4088
4033
  this.params = {};
4089
- //
4090
- this.isDirtyDisposable = new MutableDisposable();
4091
- this.addDisposables(this.isDirtyDisposable);
4092
4034
  this._element = document.createElement('div');
4093
4035
  this._element.className = 'default-tab';
4094
4036
  //
@@ -4133,10 +4075,6 @@
4133
4075
  init(params) {
4134
4076
  this.params = params;
4135
4077
  this._content.textContent = params.title;
4136
- this.isDirtyDisposable.value = this.params.api.onDidDirtyChange((event) => {
4137
- const isDirty = event;
4138
- toggleClass(this.action, 'dirty', isDirty);
4139
- });
4140
4078
  if (!this.params.suppressClosable) {
4141
4079
  addDisposableListener(this.action, 'click', (ev) => {
4142
4080
  ev.preventDefault(); //
@@ -4190,6 +4128,10 @@
4190
4128
  get height() {
4191
4129
  return this._height;
4192
4130
  }
4131
+ get params() {
4132
+ var _a;
4133
+ return (_a = this._params) === null || _a === void 0 ? void 0 : _a.params;
4134
+ }
4193
4135
  focus() {
4194
4136
  this.api._onFocusEvent.fire();
4195
4137
  }
@@ -4198,29 +4140,27 @@
4198
4140
  this._height = height;
4199
4141
  this.api._onDidPanelDimensionChange.fire({ width, height });
4200
4142
  if (this.part) {
4201
- if (this.params) {
4202
- this.part.update(this.params.params);
4143
+ if (this._params) {
4144
+ this.part.update(this._params.params);
4203
4145
  }
4204
4146
  }
4205
4147
  }
4206
4148
  init(parameters) {
4207
- this.params = parameters;
4149
+ this._params = parameters;
4208
4150
  this.part = this.getComponent();
4209
4151
  }
4210
4152
  update(event) {
4211
4153
  var _a, _b;
4212
- this.params = Object.assign(Object.assign({}, this.params), { params: Object.assign(Object.assign({}, (_a = this.params) === null || _a === void 0 ? void 0 : _a.params), event.params) });
4213
- (_b = this.part) === null || _b === void 0 ? void 0 : _b.update({ params: this.params.params });
4154
+ this._params = Object.assign(Object.assign({}, this._params), { params: Object.assign(Object.assign({}, (_a = this._params) === null || _a === void 0 ? void 0 : _a.params), event.params) });
4155
+ (_b = this.part) === null || _b === void 0 ? void 0 : _b.update({ params: this._params.params });
4214
4156
  }
4215
4157
  toJSON() {
4216
4158
  var _a, _b;
4217
- const state = this.api.getState();
4218
- const params = (_b = (_a = this.params) === null || _a === void 0 ? void 0 : _a.params) !== null && _b !== void 0 ? _b : {};
4159
+ const params = (_b = (_a = this._params) === null || _a === void 0 ? void 0 : _a.params) !== null && _b !== void 0 ? _b : {};
4219
4160
  return {
4220
4161
  id: this.id,
4221
4162
  component: this.component,
4222
4163
  params: Object.keys(params).length > 0 ? params : undefined,
4223
- state: Object.keys(state).length === 0 ? undefined : state,
4224
4164
  };
4225
4165
  }
4226
4166
  dispose() {
@@ -4243,12 +4183,12 @@
4243
4183
  this._snap = false;
4244
4184
  this._onDidChange = new Emitter();
4245
4185
  this.onDidChange = this._onDidChange.event;
4246
- this.addDisposables(this.api.onVisibilityChange((event) => {
4186
+ this.addDisposables(this._onDidChange, this.api.onVisibilityChange((event) => {
4247
4187
  const { isVisible } = event;
4248
- const { containerApi } = this.params;
4188
+ const { containerApi } = this._params;
4249
4189
  containerApi.setVisible(this, isVisible);
4250
4190
  }), this.api.onActiveChange(() => {
4251
- const { containerApi } = this.params;
4191
+ const { containerApi } = this._params;
4252
4192
  containerApi.setActive(this);
4253
4193
  }), this.api.onDidConstraintsChangeInternal((event) => {
4254
4194
  if (typeof event.minimumWidth === 'number' ||
@@ -4363,9 +4303,6 @@
4363
4303
  const minimum = (value) => (value <= 0 ? undefined : value);
4364
4304
  return Object.assign(Object.assign({}, state), { minimumHeight: minimum(this.minimumHeight), maximumHeight: maximum(this.maximumHeight), minimumWidth: minimum(this.minimumWidth), maximumWidth: maximum(this.maximumWidth), snap: this.snap, priority: this.priority });
4365
4305
  }
4366
- dispose() {
4367
- super.dispose();
4368
- }
4369
4306
  }
4370
4307
 
4371
4308
  class GroupviewPanel extends GridviewPanel {
@@ -4472,15 +4409,22 @@
4472
4409
  orientation: options.orientation || exports.Orientation.HORIZONTAL,
4473
4410
  styles: options.styles,
4474
4411
  });
4475
- this._panels = new Map();
4476
- this.dirtyPanels = new Set();
4477
- this.debouncedDeque = debounce(this.syncConfigs.bind(this), 5000);
4478
4412
  // events
4479
4413
  this._onTabInteractionEvent = new Emitter();
4480
4414
  this.onTabInteractionEvent = this._onTabInteractionEvent.event;
4481
4415
  this._onTabContextMenu = new Emitter();
4482
4416
  this.onTabContextMenu = this._onTabContextMenu.event;
4483
- this.panelState = {};
4417
+ this._onDidDrop = new Emitter();
4418
+ this.onDidDrop = this._onDidDrop.event;
4419
+ this._onDidRemovePanel = new Emitter();
4420
+ this.onDidRemovePanel = this._onDidRemovePanel.event;
4421
+ this._onDidAddPanel = new Emitter();
4422
+ this.onDidAddPanel = this._onDidAddPanel.event;
4423
+ this._onDidLayoutfromJSON = new Emitter();
4424
+ this.onDidLayoutfromJSON = this._onDidLayoutfromJSON.event;
4425
+ this._onDidActivePanelChange = new Emitter();
4426
+ this.onDidActivePanelChange = this._onDidActivePanelChange.event;
4427
+ this.addDisposables(this._onTabInteractionEvent, this._onTabContextMenu, this._onDidDrop);
4484
4428
  this._options = options;
4485
4429
  if (!this.options.components) {
4486
4430
  this.options.components = {};
@@ -4501,10 +4445,10 @@
4501
4445
  this._api = new DockviewApi(this);
4502
4446
  }
4503
4447
  get totalPanels() {
4504
- return this._panels.size;
4448
+ return this.panels.length;
4505
4449
  }
4506
4450
  get panels() {
4507
- return Array.from(this._panels.values()).map((_) => _.value);
4451
+ return this.groups.flatMap((group) => group.model.panels);
4508
4452
  }
4509
4453
  get deserializer() {
4510
4454
  return this._deserializer;
@@ -4534,10 +4478,6 @@
4534
4478
  updateOptions(options) {
4535
4479
  const hasOrientationChanged = typeof options.orientation === 'string' &&
4536
4480
  this.options.orientation !== options.orientation;
4537
- // TODO support style update
4538
- // const hasStylesChanged =
4539
- // typeof options.styles === 'object' &&
4540
- // this.options.styles !== options.styles;
4541
4481
  this._options = Object.assign(Object.assign({}, this.options), options);
4542
4482
  if (hasOrientationChanged) {
4543
4483
  this.gridview.orientation = options.orientation;
@@ -4549,8 +4489,7 @@
4549
4489
  (_a = this.activeGroup) === null || _a === void 0 ? void 0 : _a.focus();
4550
4490
  }
4551
4491
  getGroupPanel(id) {
4552
- var _a;
4553
- return (_a = this._panels.get(id)) === null || _a === void 0 ? void 0 : _a.value;
4492
+ return this.panels.find((panel) => panel.id === id);
4554
4493
  }
4555
4494
  setActivePanel(panel) {
4556
4495
  if (!panel.group) {
@@ -4599,24 +4538,6 @@
4599
4538
  this.doSetGroupActive(next);
4600
4539
  }
4601
4540
  }
4602
- registerPanel(panel) {
4603
- if (this._panels.has(panel.id)) {
4604
- throw new Error(`panel ${panel.id} already exists`);
4605
- }
4606
- const disposable = new CompositeDisposable(panel.onDidStateChange(() => this.addDirtyPanel(panel)));
4607
- this._panels.set(panel.id, { value: panel, disposable });
4608
- }
4609
- unregisterPanel(panel) {
4610
- if (!this._panels.has(panel.id)) {
4611
- throw new Error(`panel ${panel.id} doesn't exist`);
4612
- }
4613
- const item = this._panels.get(panel.id);
4614
- if (item) {
4615
- item.disposable.dispose();
4616
- item.value.dispose();
4617
- }
4618
- this._panels.delete(panel.id);
4619
- }
4620
4541
  /**
4621
4542
  * Serialize the current state of the layout
4622
4543
  *
@@ -4624,12 +4545,9 @@
4624
4545
  */
4625
4546
  toJSON() {
4626
4547
  var _a;
4627
- this.syncConfigs();
4628
4548
  const data = this.gridview.serialize();
4629
- const panels = Array.from(this._panels.values()).reduce((collection, panel) => {
4630
- if (!this.panelState[panel.value.id]) {
4631
- collection[panel.value.id] = panel.value.toJSON();
4632
- }
4549
+ const panels = this.panels.reduce((collection, panel) => {
4550
+ collection[panel.id] = panel.toJSON();
4633
4551
  return collection;
4634
4552
  }, {});
4635
4553
  return {
@@ -4641,11 +4559,9 @@
4641
4559
  }
4642
4560
  fromJSON(data) {
4643
4561
  this.gridview.clear();
4644
- this._panels.forEach((panel) => {
4645
- panel.disposable.dispose();
4646
- panel.value.dispose();
4562
+ this.panels.forEach((panel) => {
4563
+ panel.dispose();
4647
4564
  });
4648
- this._panels.clear();
4649
4565
  this._groups.clear();
4650
4566
  if (!this.deserializer) {
4651
4567
  throw new Error('invalid deserializer');
@@ -4660,9 +4576,7 @@
4660
4576
  this.gridview.deserialize(grid, new DefaultDeserializer(this, {
4661
4577
  createPanel: (id) => {
4662
4578
  const panelData = panels[id];
4663
- const panel = this.deserializer.fromJSON(panelData);
4664
- this.registerPanel(panel);
4665
- return panel;
4579
+ return this.deserializer.fromJSON(panelData);
4666
4580
  },
4667
4581
  }));
4668
4582
  if (typeof activeGroup === 'string') {
@@ -4673,30 +4587,23 @@
4673
4587
  }
4674
4588
  this.gridview.layout(this.width, this.height);
4675
4589
  this._onGridEvent.fire({ kind: exports.GroupChangeKind.LAYOUT_FROM_JSON });
4590
+ this._onDidLayoutfromJSON.fire();
4676
4591
  }
4677
4592
  closeAllGroups() {
4678
- return __awaiter(this, void 0, void 0, function* () {
4679
- for (const entry of this._groups.entries()) {
4680
- const [_, group] = entry;
4681
- const didCloseAll = yield group.value.model.closeAllPanels();
4682
- if (!didCloseAll) {
4683
- return false;
4684
- }
4685
- }
4686
- return true;
4687
- });
4593
+ for (const entry of this._groups.entries()) {
4594
+ const [_, group] = entry;
4595
+ group.value.model.closeAllPanels();
4596
+ }
4688
4597
  }
4689
4598
  fireMouseEvent(event) {
4690
- switch (event.kind) {
4691
- case exports.MouseEventKind.CONTEXT_MENU:
4692
- if (event.tab && event.panel) {
4693
- this._onTabContextMenu.fire({
4694
- event: event.event,
4695
- api: this._api,
4696
- panel: event.panel,
4697
- });
4698
- }
4699
- break;
4599
+ if (event.kind === exports.MouseEventKind.CONTEXT_MENU) {
4600
+ if (event.tab && event.panel) {
4601
+ this._onTabContextMenu.fire({
4602
+ event: event.event,
4603
+ api: this._api,
4604
+ panel: event.panel,
4605
+ });
4606
+ }
4700
4607
  }
4701
4608
  }
4702
4609
  addPanel(options) {
@@ -4730,7 +4637,6 @@
4730
4637
  return panel;
4731
4638
  }
4732
4639
  removePanel(panel) {
4733
- this.unregisterPanel(panel);
4734
4640
  const group = panel.group;
4735
4641
  if (!group) {
4736
4642
  throw new Error(`cannot remove panel ${panel.id}. it's missing a group.`);
@@ -4749,10 +4655,9 @@
4749
4655
  : {}, (_a = this.options.frameworkComponentFactory) === null || _a === void 0 ? void 0 : _a.watermark);
4750
4656
  }
4751
4657
  addEmptyGroup(options) {
4752
- var _a;
4753
4658
  const group = this.createGroup();
4754
4659
  if (options) {
4755
- const referencePanel = (_a = this._panels.get(options.referencePanel)) === null || _a === void 0 ? void 0 : _a.value;
4660
+ const referencePanel = this.panels.find((panel) => panel.id === options.referencePanel);
4756
4661
  if (!referencePanel) {
4757
4662
  throw new Error(`reference panel ${options.referencePanel} does not exist`);
4758
4663
  }
@@ -4781,13 +4686,13 @@
4781
4686
  super.removeGroup(group);
4782
4687
  }
4783
4688
  moveGroupOrPanel(referenceGroup, groupId, itemId, target, index) {
4784
- var _a, _b, _c;
4689
+ var _a;
4785
4690
  const sourceGroup = groupId
4786
4691
  ? (_a = this._groups.get(groupId)) === null || _a === void 0 ? void 0 : _a.value
4787
4692
  : undefined;
4788
4693
  if (!target || target === exports.Position.Center) {
4789
4694
  const groupItem = (sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(itemId)) ||
4790
- ((_b = this._panels.get(itemId)) === null || _b === void 0 ? void 0 : _b.value);
4695
+ this.panels.find((panel) => panel.id === itemId);
4791
4696
  if (!groupItem) {
4792
4697
  throw new Error(`No panel with id ${itemId}`);
4793
4698
  }
@@ -4823,7 +4728,7 @@
4823
4728
  }
4824
4729
  else {
4825
4730
  const groupItem = (sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(itemId)) ||
4826
- ((_c = this._panels.get(itemId)) === null || _c === void 0 ? void 0 : _c.value);
4731
+ this.panels.find((panel) => panel.id === itemId);
4827
4732
  if (!groupItem) {
4828
4733
  throw new Error(`No panel with id ${itemId}`);
4829
4734
  }
@@ -4833,7 +4738,7 @@
4833
4738
  }
4834
4739
  }
4835
4740
  doSetGroupActive(group, skipFocus) {
4836
- var _a, _b;
4741
+ var _a, _b, _c;
4837
4742
  const isGroupAlreadyFocused = this._activeGroup === group;
4838
4743
  super.doSetGroupActive(group, skipFocus);
4839
4744
  if (!isGroupAlreadyFocused && ((_a = this._activeGroup) === null || _a === void 0 ? void 0 : _a.model.activePanel)) {
@@ -4841,6 +4746,7 @@
4841
4746
  kind: exports.GroupChangeKind.PANEL_ACTIVE,
4842
4747
  panel: (_b = this._activeGroup) === null || _b === void 0 ? void 0 : _b.model.activePanel,
4843
4748
  });
4749
+ this._onDidActivePanelChange.fire((_c = this._activeGroup) === null || _c === void 0 ? void 0 : _c.model.activePanel);
4844
4750
  }
4845
4751
  }
4846
4752
  createGroup(options) {
@@ -4866,6 +4772,8 @@
4866
4772
  const disposable = new CompositeDisposable(view.model.onMove((event) => {
4867
4773
  const { groupId, itemId, target, index } = event;
4868
4774
  this.moveGroupOrPanel(view, groupId, itemId, target, index);
4775
+ }), view.model.onDidDrop((event) => {
4776
+ this._onDidDrop.fire(Object.assign(Object.assign({}, event), { api: this._api }));
4869
4777
  }), view.model.onDidGroupChange((event) => {
4870
4778
  switch (event.kind) {
4871
4779
  case exports.GroupChangeKind2.ADD_PANEL:
@@ -4873,24 +4781,25 @@
4873
4781
  kind: exports.GroupChangeKind.ADD_PANEL,
4874
4782
  panel: event.panel,
4875
4783
  });
4876
- break;
4877
- case exports.GroupChangeKind2.GROUP_ACTIVE:
4878
- this._onGridEvent.fire({
4879
- kind: exports.GroupChangeKind.GROUP_ACTIVE,
4880
- panel: event.panel,
4881
- });
4784
+ if (event.panel) {
4785
+ this._onDidAddPanel.fire(event.panel);
4786
+ }
4882
4787
  break;
4883
4788
  case exports.GroupChangeKind2.REMOVE_PANEL:
4884
4789
  this._onGridEvent.fire({
4885
4790
  kind: exports.GroupChangeKind.REMOVE_PANEL,
4886
4791
  panel: event.panel,
4887
4792
  });
4793
+ if (event.panel) {
4794
+ this._onDidRemovePanel.fire(event.panel);
4795
+ }
4888
4796
  break;
4889
4797
  case exports.GroupChangeKind2.PANEL_ACTIVE:
4890
4798
  this._onGridEvent.fire({
4891
4799
  kind: exports.GroupChangeKind.PANEL_ACTIVE,
4892
4800
  panel: event.panel,
4893
4801
  });
4802
+ this._onDidActivePanelChange.fire(event.panel);
4894
4803
  break;
4895
4804
  }
4896
4805
  }));
@@ -4904,44 +4813,18 @@
4904
4813
  }
4905
4814
  return view;
4906
4815
  }
4907
- dispose() {
4908
- super.dispose();
4909
- this._onGridEvent.dispose();
4910
- }
4911
- /**
4912
- * Ensure the local copy of the layout state is up-to-date
4913
- */
4914
- syncConfigs() {
4915
- const dirtyPanels = Array.from(this.dirtyPanels);
4916
- if (dirtyPanels.length === 0) ;
4917
- this.dirtyPanels.clear();
4918
- const partialPanelState = dirtyPanels
4919
- .map((panel) => this._panels.get(panel.id))
4920
- .filter((_) => !!_)
4921
- .reduce((collection, panel) => {
4922
- collection[panel.value.id] = panel.value.toJSON();
4923
- return collection;
4924
- }, {});
4925
- this.panelState = Object.assign(Object.assign({}, this.panelState), partialPanelState);
4926
- dirtyPanels
4927
- .filter((p) => this._panels.has(p.id))
4928
- .forEach((panel) => {
4929
- panel.setDirty(false);
4930
- });
4931
- }
4932
4816
  _addPanel(options) {
4933
4817
  const view = new DefaultGroupPanelView({
4934
4818
  content: this.createContentComponent(options.id, options.component),
4935
4819
  tab: this.createTabComponent(options.id, options.tabComponent),
4936
4820
  });
4937
- const panel = new DockviewGroupPanel(options.id, this._api);
4821
+ const panel = new DockviewGroupPanel(options.id, this, this._api);
4938
4822
  panel.init({
4939
4823
  view,
4940
4824
  title: options.title || options.id,
4941
4825
  suppressClosable: options === null || options === void 0 ? void 0 : options.suppressClosable,
4942
4826
  params: (options === null || options === void 0 ? void 0 : options.params) || {},
4943
4827
  });
4944
- this.registerPanel(panel);
4945
4828
  return panel;
4946
4829
  }
4947
4830
  createContentComponent(id, componentName) {
@@ -4961,10 +4844,12 @@
4961
4844
  var _a;
4962
4845
  return (_a = Array.from(this._groups.values()).find((group) => group.value.model.containsPanel(panel))) === null || _a === void 0 ? void 0 : _a.value;
4963
4846
  }
4964
- addDirtyPanel(panel) {
4965
- this.dirtyPanels.add(panel);
4966
- panel.setDirty(true);
4967
- this.debouncedDeque();
4847
+ dispose() {
4848
+ super.dispose();
4849
+ this._onDidActivePanelChange.dispose();
4850
+ this._onDidAddPanel.dispose();
4851
+ this._onDidRemovePanel.dispose();
4852
+ this._onDidLayoutfromJSON.dispose();
4968
4853
  }
4969
4854
  }
4970
4855
 
@@ -4975,6 +4860,8 @@
4975
4860
  orientation: options.orientation,
4976
4861
  styles: options.styles,
4977
4862
  });
4863
+ this._onDidLayoutfromJSON = new Emitter();
4864
+ this.onDidLayoutFromJSON = this._onDidLayoutfromJSON.event;
4978
4865
  this._options = options;
4979
4866
  if (!this.options.components) {
4980
4867
  this.options.components = {};
@@ -5083,6 +4970,7 @@
5083
4970
  }
5084
4971
  }
5085
4972
  this._onGridEvent.fire({ kind: exports.GroupChangeKind.LAYOUT_FROM_JSON });
4973
+ this._onDidLayoutfromJSON.fire();
5086
4974
  }
5087
4975
  movePanel(panel, options) {
5088
4976
  var _a;
@@ -5197,6 +5085,7 @@
5197
5085
  }
5198
5086
  dispose() {
5199
5087
  super.dispose();
5088
+ this._onDidLayoutfromJSON.dispose();
5200
5089
  }
5201
5090
  }
5202
5091
 
@@ -5223,7 +5112,7 @@
5223
5112
  options.frameworkComponents = {};
5224
5113
  }
5225
5114
  this.splitview = new Splitview(this.element, options);
5226
- this.addDisposables(this._disposable);
5115
+ this.addDisposables(this._disposable, this._onDidAddView, this._onDidRemoveView, this._onDidLayoutChange);
5227
5116
  }
5228
5117
  get options() {
5229
5118
  return this._options;
@@ -5445,41 +5334,6 @@
5445
5334
  }
5446
5335
  }
5447
5336
 
5448
- class DragHandler extends CompositeDisposable {
5449
- constructor(el) {
5450
- super();
5451
- this.el = el;
5452
- this.iframes = [];
5453
- this._onDragStart = new Emitter();
5454
- this.onDragStart = this._onDragStart.event;
5455
- this.configure();
5456
- }
5457
- configure() {
5458
- this.addDisposables(addDisposableListener(this.el, 'dragstart', (event) => {
5459
- var _a;
5460
- this.iframes = [
5461
- ...getElementsByTagName('iframe'),
5462
- ...getElementsByTagName('webview'),
5463
- ];
5464
- for (const iframe of this.iframes) {
5465
- iframe.style.pointerEvents = 'none';
5466
- }
5467
- this.el.classList.add('dragged');
5468
- setTimeout(() => this.el.classList.remove('dragged'), 0);
5469
- (_a = this.disposable) === null || _a === void 0 ? void 0 : _a.dispose();
5470
- this.disposable = this.getData();
5471
- }), addDisposableListener(this.el, 'dragend', (ev) => {
5472
- var _a;
5473
- for (const iframe of this.iframes) {
5474
- iframe.style.pointerEvents = 'auto';
5475
- }
5476
- this.iframes = [];
5477
- (_a = this.disposable) === null || _a === void 0 ? void 0 : _a.dispose();
5478
- this.disposable = undefined;
5479
- }));
5480
- }
5481
- }
5482
-
5483
5337
  class SplitviewPanelApiImpl extends PanelApiImpl {
5484
5338
  //
5485
5339
  constructor(id) {
@@ -5494,6 +5348,7 @@
5494
5348
  //
5495
5349
  this._onDidSizeChange = new Emitter();
5496
5350
  this.onDidSizeChange = this._onDidSizeChange.event;
5351
+ this.addDisposables(this._onDidConstraintsChangeInternal, this._onDidConstraintsChange, this._onDidSizeChange);
5497
5352
  }
5498
5353
  setConstraints(value) {
5499
5354
  this._onDidConstraintsChangeInternal.fire(value);
@@ -5501,11 +5356,6 @@
5501
5356
  setSize(event) {
5502
5357
  this._onDidSizeChange.fire(event);
5503
5358
  }
5504
- dispose() {
5505
- super.dispose();
5506
- this._onDidConstraintsChange.dispose();
5507
- this._onDidSizeChange.dispose();
5508
- }
5509
5359
  }
5510
5360
 
5511
5361
  class PaneviewPanelApiImpl extends SplitviewPanelApiImpl {
@@ -5519,6 +5369,7 @@
5519
5369
  this.onMouseEnter = this._onMouseEnter.event;
5520
5370
  this._onMouseLeave = new Emitter({});
5521
5371
  this.onMouseLeave = this._onMouseLeave.event;
5372
+ this.addDisposables(this._onDidExpansionChange, this._onMouseEnter, this._onMouseLeave);
5522
5373
  }
5523
5374
  set pane(pane) {
5524
5375
  this._pane = pane;
@@ -5687,7 +5538,7 @@
5687
5538
  }
5688
5539
  }
5689
5540
  toJSON() {
5690
- const params = this.params;
5541
+ const params = this._params;
5691
5542
  return Object.assign(Object.assign({}, super.toJSON()), { headerComponent: this.headerComponent, title: params.title });
5692
5543
  }
5693
5544
  renderOnce() {
@@ -5756,36 +5607,39 @@
5756
5607
  },
5757
5608
  });
5758
5609
  this.addDisposables(this._onDidDrop, this.handler, this.target, this.target.onDrop((event) => {
5759
- const data = getPaneData();
5760
- if (!data) {
5761
- this._onDidDrop.fire(Object.assign(Object.assign({}, event), { panel: this, getData: () => getPaneData() }));
5762
- return;
5763
- }
5764
- const containerApi = this.params
5765
- .containerApi;
5766
- const panelId = data.paneId;
5767
- const existingPanel = containerApi.getPanel(panelId);
5768
- if (!existingPanel) {
5769
- this._onDidDrop.fire(Object.assign(Object.assign({}, event), { panel: this, getData: () => getPaneData() }));
5770
- return;
5771
- }
5772
- const allPanels = containerApi.getPanels();
5773
- const fromIndex = allPanels.indexOf(existingPanel);
5774
- let toIndex = containerApi.getPanels().indexOf(this);
5775
- if (event.position === exports.Position.Left ||
5776
- event.position === exports.Position.Top) {
5777
- toIndex = Math.max(0, toIndex - 1);
5778
- }
5779
- if (event.position === exports.Position.Right ||
5780
- event.position === exports.Position.Bottom) {
5781
- if (fromIndex > toIndex) {
5782
- toIndex++;
5783
- }
5784
- toIndex = Math.min(allPanels.length - 1, toIndex);
5785
- }
5786
- containerApi.movePanel(fromIndex, toIndex);
5610
+ this.onDrop(event);
5787
5611
  }));
5788
5612
  }
5613
+ onDrop(event) {
5614
+ const data = getPaneData();
5615
+ if (!data) {
5616
+ this._onDidDrop.fire(Object.assign(Object.assign({}, event), { panel: this, getData: () => getPaneData() }));
5617
+ return;
5618
+ }
5619
+ const containerApi = this._params
5620
+ .containerApi;
5621
+ const panelId = data.paneId;
5622
+ const existingPanel = containerApi.getPanel(panelId);
5623
+ if (!existingPanel) {
5624
+ this._onDidDrop.fire(Object.assign(Object.assign({}, event), { panel: this, getData: () => getPaneData() }));
5625
+ return;
5626
+ }
5627
+ const allPanels = containerApi.getPanels();
5628
+ const fromIndex = allPanels.indexOf(existingPanel);
5629
+ let toIndex = containerApi.getPanels().indexOf(this);
5630
+ if (event.position === exports.Position.Left ||
5631
+ event.position === exports.Position.Top) {
5632
+ toIndex = Math.max(0, toIndex - 1);
5633
+ }
5634
+ if (event.position === exports.Position.Right ||
5635
+ event.position === exports.Position.Bottom) {
5636
+ if (fromIndex > toIndex) {
5637
+ toIndex++;
5638
+ }
5639
+ toIndex = Math.min(allPanels.length - 1, toIndex);
5640
+ }
5641
+ containerApi.movePanel(fromIndex, toIndex);
5642
+ }
5789
5643
  }
5790
5644
 
5791
5645
  class DefaultHeader extends CompositeDisposable {
@@ -5849,6 +5703,7 @@
5849
5703
  this.onDidAddView = this._onDidAddView.event;
5850
5704
  this._onDidRemoveView = new Emitter();
5851
5705
  this.onDidRemoveView = this._onDidRemoveView.event;
5706
+ this.addDisposables(this._onDidLayoutChange, this._onDidDrop, this._onDidAddView, this._onDidRemoveView);
5852
5707
  this._options = options;
5853
5708
  if (!options.components) {
5854
5709
  options.components = {};
@@ -6076,12 +5931,14 @@
6076
5931
  this._snap = false;
6077
5932
  this._onDidChange = new Emitter();
6078
5933
  this.onDidChange = this._onDidChange.event;
6079
- this.addDisposables(this.api.onVisibilityChange((event) => {
5934
+ this.addDisposables(this._onDidChange, this.api.onVisibilityChange((event) => {
6080
5935
  const { isVisible } = event;
6081
- const { containerApi } = this.params;
5936
+ const { containerApi } = this
5937
+ ._params;
6082
5938
  containerApi.setVisible(this, isVisible);
6083
5939
  }), this.api.onActiveChange(() => {
6084
- const { containerApi } = this.params;
5940
+ const { containerApi } = this
5941
+ ._params;
6085
5942
  containerApi.setActive(this);
6086
5943
  }), this.api.onDidConstraintsChangeInternal((event) => {
6087
5944
  if (typeof event.minimumSize === 'number' ||
@@ -6224,14 +6081,13 @@
6224
6081
  if (this.disposed) {
6225
6082
  throw new Error('invalid operation: resource is already disposed');
6226
6083
  }
6227
- // TODO use a better check for isReactFunctionalComponent
6228
6084
  if (typeof this.component !== 'function') {
6229
6085
  /**
6230
6086
  * we know this isn't a React.FunctionComponent so throw an error here.
6231
6087
  * if we do not intercept this the React library will throw a very obsure error
6232
6088
  * for the same reason, at least at this point we will emit a sensible stacktrace.
6233
6089
  */
6234
- throw new Error('invalid operation: only functional components are supported');
6090
+ throw new Error('Invalid Operation. dockview only supports React Functional Components.');
6235
6091
  }
6236
6092
  const bridgeComponent = React__namespace.createElement(React__namespace.forwardRef(ReactComponentBridge), {
6237
6093
  component: this
@@ -6295,16 +6151,14 @@
6295
6151
  this._onDidBlur = new Emitter();
6296
6152
  this.onDidBlur = this._onDidBlur.event;
6297
6153
  this._element = document.createElement('div');
6298
- this._element.style.height = '100%';
6299
- this._element.style.width = '100%';
6154
+ this._element.className = 'dockview-react-part';
6300
6155
  // this.hostedContainer = new HostedContainer({
6301
6156
  // id,
6302
6157
  // });
6303
6158
  // this.hostedContainer.onDidFocus(() => this._onDidFocus.fire());
6304
6159
  // this.hostedContainer.onDidBlur(() => this._onDidBlur.fire());
6305
6160
  this._actionsElement = document.createElement('div');
6306
- this._actionsElement.style.height = '100%';
6307
- this._actionsElement.style.width = '100%';
6161
+ this._actionsElement.className = 'dockview-react-part';
6308
6162
  }
6309
6163
  get element() {
6310
6164
  return this._element;
@@ -6352,6 +6206,8 @@
6352
6206
  }
6353
6207
  dispose() {
6354
6208
  var _a, _b;
6209
+ this._onDidFocus.dispose();
6210
+ this._onDidBlur.dispose();
6355
6211
  (_a = this.part) === null || _a === void 0 ? void 0 : _a.dispose();
6356
6212
  // this.hostedContainer?.dispose();
6357
6213
  (_b = this.actionsPart) === null || _b === void 0 ? void 0 : _b.dispose();
@@ -6364,6 +6220,7 @@
6364
6220
  this.component = component;
6365
6221
  this.reactPortalStore = reactPortalStore;
6366
6222
  this._element = document.createElement('div');
6223
+ this._element.className = 'dockview-react-part';
6367
6224
  }
6368
6225
  get element() {
6369
6226
  return this._element;
@@ -6408,7 +6265,6 @@
6408
6265
  const panelId = panelData.id;
6409
6266
  const params = panelData.params;
6410
6267
  const title = panelData.title;
6411
- const state = panelData.state;
6412
6268
  const suppressClosable = panelData.suppressClosable;
6413
6269
  const viewData = panelData.view;
6414
6270
  const view = new DefaultGroupPanelView({
@@ -6417,13 +6273,12 @@
6417
6273
  ? createComponent(viewData.tab.id, viewData.tab.id, this.layout.options.tabComponents, this.layout.options.frameworkTabComponents, (_c = this.layout.options.frameworkComponentFactory) === null || _c === void 0 ? void 0 : _c.tab)
6418
6274
  : new DefaultTab(),
6419
6275
  });
6420
- const panel = new DockviewGroupPanel(panelId, new DockviewApi(this.layout));
6276
+ const panel = new DockviewGroupPanel(panelId, this.layout, new DockviewApi(this.layout));
6421
6277
  panel.init({
6422
6278
  view,
6423
6279
  title,
6424
6280
  suppressClosable,
6425
6281
  params: params || {},
6426
- state: state || {},
6427
6282
  });
6428
6283
  return panel;
6429
6284
  }
@@ -6438,8 +6293,7 @@
6438
6293
  value: undefined,
6439
6294
  };
6440
6295
  this._element = document.createElement('div');
6441
- this._element.style.height = '100%';
6442
- this._element.style.width = '100%';
6296
+ this._element.className = 'dockview-react-part';
6443
6297
  }
6444
6298
  get element() {
6445
6299
  return this._element;
@@ -6537,12 +6391,16 @@
6537
6391
  frameworkTabComponents: props.tabComponents,
6538
6392
  tabHeight: props.tabHeight,
6539
6393
  debug: props.debug,
6540
- enableExternalDragEvents: props.enableExternalDragEvents,
6541
6394
  watermarkFrameworkComponent: props.watermarkComponent,
6542
6395
  styles: props.hideBorders
6543
6396
  ? { separatorBorder: 'transparent' }
6544
6397
  : undefined,
6545
6398
  });
6399
+ const disposable = dockview.onDidDrop((event) => {
6400
+ if (props.onDidDrop) {
6401
+ props.onDidDrop(event);
6402
+ }
6403
+ });
6546
6404
  (_a = domRef.current) === null || _a === void 0 ? void 0 : _a.appendChild(dockview.element);
6547
6405
  dockview.deserializer = new ReactPanelDeserialzier(dockview);
6548
6406
  const { clientWidth, clientHeight } = domRef.current;
@@ -6552,6 +6410,7 @@
6552
6410
  }
6553
6411
  dockviewRef.current = dockview;
6554
6412
  return () => {
6413
+ disposable.dispose();
6555
6414
  dockview.dispose();
6556
6415
  };
6557
6416
  }, []);
@@ -6563,6 +6422,14 @@
6563
6422
  frameworkComponents: props.components,
6564
6423
  });
6565
6424
  }, [props.components]);
6425
+ React__namespace.useEffect(() => {
6426
+ if (!dockviewRef.current) {
6427
+ return;
6428
+ }
6429
+ dockviewRef.current.updateOptions({
6430
+ showDndOverlay: props.showDndOverlay,
6431
+ });
6432
+ }, [props.showDndOverlay]);
6566
6433
  React__namespace.useEffect(() => {
6567
6434
  if (!dockviewRef.current) {
6568
6435
  return;
@@ -6651,9 +6518,9 @@
6651
6518
  getComponent() {
6652
6519
  var _a;
6653
6520
  return new ReactPart(this.element, this.reactPortalStore, this.reactComponent, {
6654
- params: ((_a = this.params) === null || _a === void 0 ? void 0 : _a.params) || {},
6521
+ params: ((_a = this._params) === null || _a === void 0 ? void 0 : _a.params) || {},
6655
6522
  api: this.api,
6656
- containerApi: this.params
6523
+ containerApi: this._params
6657
6524
  .containerApi,
6658
6525
  });
6659
6526
  }
@@ -6726,9 +6593,9 @@
6726
6593
  getComponent() {
6727
6594
  var _a;
6728
6595
  return new ReactPart(this.element, this.reactPortalStore, this.reactComponent, {
6729
- params: ((_a = this.params) === null || _a === void 0 ? void 0 : _a.params) || {},
6596
+ params: ((_a = this._params) === null || _a === void 0 ? void 0 : _a.params) || {},
6730
6597
  api: this.api,
6731
- containerApi: this.params
6598
+ containerApi: this._params
6732
6599
  .containerApi,
6733
6600
  });
6734
6601
  }
@@ -6919,7 +6786,6 @@
6919
6786
  exports.BaseGrid = BaseGrid;
6920
6787
  exports.CompositeDisposable = CompositeDisposable;
6921
6788
  exports.ContentContainer = ContentContainer;
6922
- exports.DATA_KEY = DATA_KEY;
6923
6789
  exports.DockviewApi = DockviewApi;
6924
6790
  exports.DockviewComponent = DockviewComponent;
6925
6791
  exports.DockviewComponents = DockviewComponents;
@@ -6954,7 +6820,6 @@
6954
6820
  exports.TickDelayedEvent = TickDelayedEvent;
6955
6821
  exports.addDisposableListener = addDisposableListener;
6956
6822
  exports.addDisposableWindowListener = addDisposableWindowListener;
6957
- exports.extractData = extractData;
6958
6823
  exports.getDirectionOrientation = getDirectionOrientation;
6959
6824
  exports.getGridLocation = getGridLocation;
6960
6825
  exports.getLocationOrientation = getLocationOrientation;
@@ -6962,11 +6827,8 @@
6962
6827
  exports.getPanelData = getPanelData;
6963
6828
  exports.getRelativeLocation = getRelativeLocation;
6964
6829
  exports.indexInParent = indexInParent;
6965
- exports.isCustomDragEvent = isCustomDragEvent;
6966
6830
  exports.isGridBranchNode = isGridBranchNode;
6967
- exports.isPanelTransferEvent = isPanelTransferEvent;
6968
6831
  exports.isReactElement = isReactElement;
6969
- exports.isTabDragEvent = isTabDragEvent;
6970
6832
  exports.orthogonal = orthogonal;
6971
6833
  exports.toTarget = toTarget;
6972
6834
  exports.usePortalsLifecycle = usePortalsLifecycle;