dockview 1.0.3 → 1.3.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 (261) hide show
  1. package/README.md +243 -186
  2. package/dist/cjs/api/component.api.d.ts +31 -25
  3. package/dist/cjs/api/component.api.js +97 -40
  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 +2 -2
  19. package/dist/cjs/dnd/abstractDragHandler.js +15 -15
  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 +72 -48
  29. package/dist/cjs/dnd/droptarget.js.map +1 -1
  30. package/dist/cjs/dockview/components/tab/defaultTab.d.ts +1 -2
  31. package/dist/cjs/dockview/components/tab/defaultTab.js +1 -9
  32. package/dist/cjs/dockview/components/tab/defaultTab.js.map +1 -1
  33. package/dist/cjs/dockview/components/watermark/watermark.d.ts +3 -3
  34. package/dist/cjs/dockview/components/watermark/watermark.js +4 -4
  35. package/dist/cjs/dockview/components/watermark/watermark.js.map +1 -1
  36. package/dist/cjs/dockview/deserializer.js.map +1 -1
  37. package/dist/cjs/dockview/dockviewComponent.d.ts +34 -23
  38. package/dist/cjs/dockview/dockviewComponent.js +117 -209
  39. package/dist/cjs/dockview/dockviewComponent.js.map +1 -1
  40. package/dist/cjs/dockview/dockviewGroupPanel.d.ts +3 -5
  41. package/dist/cjs/dockview/dockviewGroupPanel.js +10 -31
  42. package/dist/cjs/dockview/dockviewGroupPanel.js.map +1 -1
  43. package/dist/cjs/dockview/options.d.ts +2 -1
  44. package/dist/cjs/events.js +25 -4
  45. package/dist/cjs/events.js.map +1 -1
  46. package/dist/cjs/gridview/baseComponentGridview.d.ts +12 -20
  47. package/dist/cjs/gridview/baseComponentGridview.js +49 -45
  48. package/dist/cjs/gridview/baseComponentGridview.js.map +1 -1
  49. package/dist/cjs/gridview/basePanelView.d.ts +5 -8
  50. package/dist/cjs/gridview/basePanelView.js +16 -8
  51. package/dist/cjs/gridview/basePanelView.js.map +1 -1
  52. package/dist/cjs/gridview/branchNode.js +3 -3
  53. package/dist/cjs/gridview/branchNode.js.map +1 -1
  54. package/dist/cjs/gridview/gridview.js +21 -18
  55. package/dist/cjs/gridview/gridview.js.map +1 -1
  56. package/dist/cjs/gridview/gridviewComponent.d.ts +5 -6
  57. package/dist/cjs/gridview/gridviewComponent.js +33 -9
  58. package/dist/cjs/gridview/gridviewComponent.js.map +1 -1
  59. package/dist/cjs/gridview/gridviewPanel.d.ts +0 -1
  60. package/dist/cjs/gridview/gridviewPanel.js +3 -6
  61. package/dist/cjs/gridview/gridviewPanel.js.map +1 -1
  62. package/dist/cjs/gridview/leafNode.js +2 -1
  63. package/dist/cjs/gridview/leafNode.js.map +1 -1
  64. package/dist/cjs/groupview/groupPanel.d.ts +1 -7
  65. package/dist/cjs/groupview/groupview.d.ts +18 -10
  66. package/dist/cjs/groupview/groupview.js +51 -129
  67. package/dist/cjs/groupview/groupview.js.map +1 -1
  68. package/dist/cjs/groupview/groupviewPanel.d.ts +5 -2
  69. package/dist/cjs/groupview/groupviewPanel.js.map +1 -1
  70. package/dist/cjs/groupview/panel/content.d.ts +1 -1
  71. package/dist/cjs/groupview/panel/content.js +2 -1
  72. package/dist/cjs/groupview/panel/content.js.map +1 -1
  73. package/dist/cjs/groupview/tab.d.ts +10 -13
  74. package/dist/cjs/groupview/tab.js +22 -80
  75. package/dist/cjs/groupview/tab.js.map +1 -1
  76. package/dist/cjs/groupview/titlebar/tabsContainer.js +4 -6
  77. package/dist/cjs/groupview/titlebar/tabsContainer.js.map +1 -1
  78. package/dist/cjs/hostedContainer.js +2 -2
  79. package/dist/cjs/hostedContainer.js.map +1 -1
  80. package/dist/cjs/index.d.ts +3 -3
  81. package/dist/cjs/index.js +8 -4
  82. package/dist/cjs/index.js.map +1 -1
  83. package/dist/cjs/lifecycle.js +2 -1
  84. package/dist/cjs/lifecycle.js.map +1 -1
  85. package/dist/cjs/panel/types.d.ts +0 -2
  86. package/dist/cjs/paneview/defaultPaneviewHeader.d.ts +1 -1
  87. package/dist/cjs/paneview/defaultPaneviewHeader.js +1 -1
  88. package/dist/cjs/paneview/defaultPaneviewHeader.js.map +1 -1
  89. package/dist/cjs/paneview/draggablePaneviewPanel.d.ts +2 -2
  90. package/dist/cjs/paneview/draggablePaneviewPanel.js +32 -29
  91. package/dist/cjs/paneview/draggablePaneviewPanel.js.map +1 -1
  92. package/dist/cjs/paneview/paneview.d.ts +3 -1
  93. package/dist/cjs/paneview/paneview.js +13 -7
  94. package/dist/cjs/paneview/paneview.js.map +1 -1
  95. package/dist/cjs/paneview/paneviewComponent.d.ts +7 -6
  96. package/dist/cjs/paneview/paneviewComponent.js +65 -8
  97. package/dist/cjs/paneview/paneviewComponent.js.map +1 -1
  98. package/dist/cjs/paneview/paneviewPanel.js +1 -1
  99. package/dist/cjs/paneview/paneviewPanel.js.map +1 -1
  100. package/dist/cjs/react/deserializer.js +1 -3
  101. package/dist/cjs/react/deserializer.js.map +1 -1
  102. package/dist/cjs/react/dockview/components.js +5 -1
  103. package/dist/cjs/react/dockview/components.js.map +1 -1
  104. package/dist/cjs/react/dockview/dockview.d.ts +9 -9
  105. package/dist/cjs/react/dockview/dockview.js +40 -5
  106. package/dist/cjs/react/dockview/dockview.js.map +1 -1
  107. package/dist/cjs/react/dockview/reactContentPart.d.ts +2 -2
  108. package/dist/cjs/react/dockview/reactContentPart.js +6 -17
  109. package/dist/cjs/react/dockview/reactContentPart.js.map +1 -1
  110. package/dist/cjs/react/dockview/reactHeaderPart.d.ts +2 -2
  111. package/dist/cjs/react/dockview/reactHeaderPart.js +3 -2
  112. package/dist/cjs/react/dockview/reactHeaderPart.js.map +1 -1
  113. package/dist/cjs/react/dockview/reactWatermarkPart.d.ts +3 -4
  114. package/dist/cjs/react/dockview/reactWatermarkPart.js +3 -4
  115. package/dist/cjs/react/dockview/reactWatermarkPart.js.map +1 -1
  116. package/dist/cjs/react/dockview/v2/reactContentRenderer.d.ts +2 -2
  117. package/dist/cjs/react/dockview/v2/reactContentRenderer.js +2 -2
  118. package/dist/cjs/react/dockview/v2/reactContentRenderer.js.map +1 -1
  119. package/dist/cjs/react/dockview/v2/webviewContentRenderer.d.ts +2 -2
  120. package/dist/cjs/react/dockview/v2/webviewContentRenderer.js +2 -2
  121. package/dist/cjs/react/dockview/v2/webviewContentRenderer.js.map +1 -1
  122. package/dist/cjs/react/gridview/gridview.js +9 -2
  123. package/dist/cjs/react/gridview/gridview.js.map +1 -1
  124. package/dist/cjs/react/gridview/view.d.ts +3 -2
  125. package/dist/cjs/react/gridview/view.js +2 -2
  126. package/dist/cjs/react/gridview/view.js.map +1 -1
  127. package/dist/cjs/react/index.d.ts +1 -0
  128. package/dist/cjs/react/index.js +5 -1
  129. package/dist/cjs/react/index.js.map +1 -1
  130. package/dist/cjs/react/paneview/paneview.js +6 -2
  131. package/dist/cjs/react/paneview/paneview.js.map +1 -1
  132. package/dist/cjs/react/react.js +6 -3
  133. package/dist/cjs/react/react.js.map +1 -1
  134. package/dist/cjs/react/splitview/splitview.js +8 -2
  135. package/dist/cjs/react/splitview/splitview.js.map +1 -1
  136. package/dist/cjs/react/splitview/view.js +2 -2
  137. package/dist/cjs/react/splitview/view.js.map +1 -1
  138. package/dist/cjs/splitview/core/splitview.js +1 -1
  139. package/dist/cjs/splitview/core/splitview.js.map +1 -1
  140. package/dist/cjs/splitview/splitviewComponent.d.ts +0 -3
  141. package/dist/cjs/splitview/splitviewComponent.js +50 -6
  142. package/dist/cjs/splitview/splitviewComponent.js.map +1 -1
  143. package/dist/cjs/splitview/splitviewPanel.d.ts +1 -6
  144. package/dist/cjs/splitview/splitviewPanel.js +5 -3
  145. package/dist/cjs/splitview/splitviewPanel.js.map +1 -1
  146. package/dist/dockview.amd.js +666 -791
  147. package/dist/dockview.amd.min.js +2 -16
  148. package/dist/dockview.amd.min.noStyle.js +2 -16
  149. package/dist/dockview.amd.noStyle.js +665 -790
  150. package/dist/dockview.cjs.js +666 -791
  151. package/dist/dockview.esm.js +666 -780
  152. package/dist/dockview.esm.min.js +2 -16
  153. package/dist/dockview.js +666 -791
  154. package/dist/dockview.min.js +2 -16
  155. package/dist/dockview.min.noStyle.js +2 -16
  156. package/dist/dockview.noStyle.js +665 -790
  157. package/dist/esm/api/component.api.d.ts +31 -25
  158. package/dist/esm/api/component.api.js +47 -26
  159. package/dist/esm/api/gridviewPanelApi.js +1 -0
  160. package/dist/esm/api/groupPanelApi.d.ts +11 -14
  161. package/dist/esm/api/groupPanelApi.js +18 -13
  162. package/dist/esm/api/panelApi.d.ts +0 -25
  163. package/dist/esm/api/panelApi.js +1 -20
  164. package/dist/esm/api/paneviewPanelApi.js +1 -0
  165. package/dist/esm/api/splitviewPanelApi.d.ts +0 -1
  166. package/dist/esm/api/splitviewPanelApi.js +1 -5
  167. package/dist/esm/dnd/abstractDragHandler.d.ts +2 -2
  168. package/dist/esm/dnd/abstractDragHandler.js +10 -10
  169. package/dist/esm/dnd/dataTransfer.d.ts +0 -25
  170. package/dist/esm/dnd/dataTransfer.js +0 -40
  171. package/dist/esm/dnd/dnd.d.ts +1 -14
  172. package/dist/esm/dnd/dnd.js +1 -69
  173. package/dist/esm/dnd/droptarget.d.ts +3 -0
  174. package/dist/esm/dnd/droptarget.js +72 -48
  175. package/dist/esm/dockview/components/tab/defaultTab.d.ts +1 -2
  176. package/dist/esm/dockview/components/tab/defaultTab.js +2 -10
  177. package/dist/esm/dockview/components/watermark/watermark.d.ts +3 -3
  178. package/dist/esm/dockview/components/watermark/watermark.js +4 -4
  179. package/dist/esm/dockview/dockviewComponent.d.ts +34 -23
  180. package/dist/esm/dockview/dockviewComponent.js +82 -150
  181. package/dist/esm/dockview/dockviewGroupPanel.d.ts +3 -5
  182. package/dist/esm/dockview/dockviewGroupPanel.js +6 -30
  183. package/dist/esm/dockview/options.d.ts +2 -1
  184. package/dist/esm/events.js +2 -3
  185. package/dist/esm/gridview/baseComponentGridview.d.ts +12 -20
  186. package/dist/esm/gridview/baseComponentGridview.js +27 -45
  187. package/dist/esm/gridview/basePanelView.d.ts +5 -8
  188. package/dist/esm/gridview/basePanelView.js +12 -8
  189. package/dist/esm/gridview/branchNode.js +3 -3
  190. package/dist/esm/gridview/gridview.js +18 -16
  191. package/dist/esm/gridview/gridviewComponent.d.ts +5 -6
  192. package/dist/esm/gridview/gridviewComponent.js +12 -10
  193. package/dist/esm/gridview/gridviewPanel.d.ts +0 -1
  194. package/dist/esm/gridview/gridviewPanel.js +3 -6
  195. package/dist/esm/gridview/leafNode.js +1 -0
  196. package/dist/esm/groupview/groupPanel.d.ts +1 -7
  197. package/dist/esm/groupview/groupview.d.ts +18 -10
  198. package/dist/esm/groupview/groupview.js +30 -59
  199. package/dist/esm/groupview/groupviewPanel.d.ts +5 -2
  200. package/dist/esm/groupview/panel/content.d.ts +1 -1
  201. package/dist/esm/groupview/panel/content.js +2 -1
  202. package/dist/esm/groupview/tab.d.ts +10 -13
  203. package/dist/esm/groupview/tab.js +17 -24
  204. package/dist/esm/groupview/titlebar/tabsContainer.js +4 -6
  205. package/dist/esm/hostedContainer.js +2 -2
  206. package/dist/esm/index.d.ts +3 -3
  207. package/dist/esm/index.js +1 -2
  208. package/dist/esm/lifecycle.js +2 -1
  209. package/dist/esm/panel/types.d.ts +0 -2
  210. package/dist/esm/paneview/defaultPaneviewHeader.d.ts +1 -1
  211. package/dist/esm/paneview/defaultPaneviewHeader.js +1 -1
  212. package/dist/esm/paneview/draggablePaneviewPanel.d.ts +2 -2
  213. package/dist/esm/paneview/draggablePaneviewPanel.js +32 -29
  214. package/dist/esm/paneview/paneview.d.ts +3 -1
  215. package/dist/esm/paneview/paneview.js +10 -6
  216. package/dist/esm/paneview/paneviewComponent.d.ts +7 -6
  217. package/dist/esm/paneview/paneviewComponent.js +31 -7
  218. package/dist/esm/paneview/paneviewPanel.js +1 -1
  219. package/dist/esm/react/deserializer.js +1 -3
  220. package/dist/esm/react/dockview/dockview.d.ts +9 -9
  221. package/dist/esm/react/dockview/dockview.js +36 -5
  222. package/dist/esm/react/dockview/reactContentPart.d.ts +2 -2
  223. package/dist/esm/react/dockview/reactContentPart.js +6 -17
  224. package/dist/esm/react/dockview/reactHeaderPart.d.ts +2 -2
  225. package/dist/esm/react/dockview/reactHeaderPart.js +3 -2
  226. package/dist/esm/react/dockview/reactWatermarkPart.d.ts +3 -4
  227. package/dist/esm/react/dockview/reactWatermarkPart.js +3 -4
  228. package/dist/esm/react/dockview/v2/reactContentRenderer.d.ts +2 -2
  229. package/dist/esm/react/dockview/v2/reactContentRenderer.js +2 -2
  230. package/dist/esm/react/dockview/v2/webviewContentRenderer.d.ts +2 -2
  231. package/dist/esm/react/dockview/v2/webviewContentRenderer.js +2 -2
  232. package/dist/esm/react/gridview/gridview.js +4 -1
  233. package/dist/esm/react/gridview/view.d.ts +3 -2
  234. package/dist/esm/react/gridview/view.js +2 -2
  235. package/dist/esm/react/index.d.ts +1 -0
  236. package/dist/esm/react/paneview/paneview.js +1 -1
  237. package/dist/esm/react/react.js +1 -2
  238. package/dist/esm/react/splitview/splitview.js +3 -1
  239. package/dist/esm/react/splitview/view.js +2 -2
  240. package/dist/esm/splitview/core/splitview.js +1 -1
  241. package/dist/esm/splitview/splitviewComponent.d.ts +0 -3
  242. package/dist/esm/splitview/splitviewComponent.js +17 -6
  243. package/dist/esm/splitview/splitviewPanel.d.ts +1 -6
  244. package/dist/esm/splitview/splitviewPanel.js +5 -3
  245. package/dist/styles/dockview.css +14 -17
  246. package/package.json +13 -13
  247. package/dist/cjs/functions.d.ts +0 -1
  248. package/dist/cjs/functions.js +0 -42
  249. package/dist/cjs/functions.js.map +0 -1
  250. package/dist/cjs/groupview/panel/hostedPanel.d.ts +0 -22
  251. package/dist/cjs/groupview/panel/hostedPanel.js +0 -57
  252. package/dist/cjs/groupview/panel/hostedPanel.js.map +0 -1
  253. package/dist/cjs/json.d.ts +0 -1
  254. package/dist/cjs/json.js +0 -14
  255. package/dist/cjs/json.js.map +0 -1
  256. package/dist/esm/functions.d.ts +0 -1
  257. package/dist/esm/functions.js +0 -8
  258. package/dist/esm/groupview/panel/hostedPanel.d.ts +0 -22
  259. package/dist/esm/groupview/panel/hostedPanel.js +0 -43
  260. package/dist/esm/json.d.ts +0 -1
  261. package/dist/esm/json.js +0 -9
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * dockview
3
- * @version 1.0.3
3
+ * @version 1.3.0
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -31,6 +31,76 @@
31
31
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
32
32
  var ReactDOM__namespace = /*#__PURE__*/_interopNamespace(ReactDOM);
33
33
 
34
+ class TransferObject {
35
+ constructor() {
36
+ //
37
+ }
38
+ }
39
+ class PanelTransfer extends TransferObject {
40
+ constructor(viewId, groupId, panelId) {
41
+ super();
42
+ this.viewId = viewId;
43
+ this.groupId = groupId;
44
+ this.panelId = panelId;
45
+ }
46
+ }
47
+ class PaneTransfer extends TransferObject {
48
+ constructor(viewId, paneId) {
49
+ super();
50
+ this.viewId = viewId;
51
+ this.paneId = paneId;
52
+ }
53
+ }
54
+ /**
55
+ * A singleton to store transfer data during drag & drop operations that are only valid within the application.
56
+ */
57
+ class LocalSelectionTransfer {
58
+ constructor() {
59
+ // protect against external instantiation
60
+ }
61
+ static getInstance() {
62
+ return LocalSelectionTransfer.INSTANCE;
63
+ }
64
+ hasData(proto) {
65
+ return proto && proto === this.proto;
66
+ }
67
+ clearData(proto) {
68
+ if (this.hasData(proto)) {
69
+ this.proto = undefined;
70
+ this.data = undefined;
71
+ }
72
+ }
73
+ getData(proto) {
74
+ if (this.hasData(proto)) {
75
+ return this.data;
76
+ }
77
+ return undefined;
78
+ }
79
+ setData(data, proto) {
80
+ if (proto) {
81
+ this.data = data;
82
+ this.proto = proto;
83
+ }
84
+ }
85
+ }
86
+ LocalSelectionTransfer.INSTANCE = new LocalSelectionTransfer();
87
+ function getPanelData() {
88
+ const panelTransfer = LocalSelectionTransfer.getInstance();
89
+ const isPanelEvent = panelTransfer.hasData(PanelTransfer.prototype);
90
+ if (!isPanelEvent) {
91
+ return undefined;
92
+ }
93
+ return panelTransfer.getData(PanelTransfer.prototype)[0];
94
+ }
95
+ function getPaneData() {
96
+ const paneTransfer = LocalSelectionTransfer.getInstance();
97
+ const isPanelEvent = paneTransfer.hasData(PaneTransfer.prototype);
98
+ if (!isPanelEvent) {
99
+ return undefined;
100
+ }
101
+ return paneTransfer.getData(PaneTransfer.prototype)[0];
102
+ }
103
+
34
104
  exports.Event = void 0;
35
105
  (function (Event) {
36
106
  Event.any = (...children) => {
@@ -61,7 +131,6 @@
61
131
  if (((_a = this.options) === null || _a === void 0 ? void 0 : _a.replay) && this._last !== undefined) {
62
132
  listener(this._last);
63
133
  }
64
- this._listeners.length === 0;
65
134
  this._listeners.push(listener);
66
135
  return {
67
136
  dispose: () => {
@@ -77,9 +146,9 @@
77
146
  }
78
147
  fire(e) {
79
148
  this._last = e;
80
- this._listeners.forEach((listener) => {
149
+ for (const listener of this._listeners) {
81
150
  listener(e);
82
- });
151
+ }
83
152
  }
84
153
  dispose() {
85
154
  this._listeners = [];
@@ -121,164 +190,6 @@
121
190
  }
122
191
  }
123
192
 
124
- exports.Disposable = void 0;
125
- (function (Disposable) {
126
- Disposable.NONE = {
127
- dispose: () => {
128
- // noop
129
- },
130
- };
131
- })(exports.Disposable || (exports.Disposable = {}));
132
- class CompositeDisposable {
133
- constructor(...args) {
134
- this.disposables = args;
135
- }
136
- static from(...args) {
137
- return new CompositeDisposable(...args);
138
- }
139
- addDisposables(...args) {
140
- args === null || args === void 0 ? void 0 : args.forEach((arg) => this.disposables.push(arg));
141
- }
142
- dispose() {
143
- this.disposables.forEach((arg) => arg.dispose());
144
- }
145
- }
146
- class MutableDisposable {
147
- constructor() {
148
- this._disposable = exports.Disposable.NONE;
149
- }
150
- set value(disposable) {
151
- if (this._disposable) {
152
- this._disposable.dispose();
153
- }
154
- this._disposable = disposable;
155
- }
156
- dispose() {
157
- if (this._disposable) {
158
- this._disposable.dispose();
159
- }
160
- }
161
- }
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
- class TransferObject {
174
- constructor() {
175
- //
176
- }
177
- }
178
- class PanelTransfer extends TransferObject {
179
- constructor(viewId, groupId, panelId) {
180
- super();
181
- this.viewId = viewId;
182
- this.groupId = groupId;
183
- this.panelId = panelId;
184
- }
185
- }
186
- class PaneTransfer extends TransferObject {
187
- constructor(viewId, paneId) {
188
- super();
189
- this.viewId = viewId;
190
- this.paneId = paneId;
191
- }
192
- }
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
- /**
233
- * A singleton to store transfer data during drag & drop operations that are only valid within the application.
234
- */
235
- class LocalSelectionTransfer {
236
- constructor() {
237
- // protect against external instantiation
238
- }
239
- static getInstance() {
240
- return LocalSelectionTransfer.INSTANCE;
241
- }
242
- hasData(proto) {
243
- return proto && proto === this.proto;
244
- }
245
- clearData(proto) {
246
- if (this.hasData(proto)) {
247
- this.proto = undefined;
248
- this.data = undefined;
249
- }
250
- }
251
- getData(proto) {
252
- if (this.hasData(proto)) {
253
- return this.data;
254
- }
255
- return undefined;
256
- }
257
- setData(data, proto) {
258
- if (proto) {
259
- this.data = data;
260
- this.proto = proto;
261
- }
262
- }
263
- }
264
- LocalSelectionTransfer.INSTANCE = new LocalSelectionTransfer();
265
- function getPanelData() {
266
- const panelTransfer = LocalSelectionTransfer.getInstance();
267
- const isPanelEvent = panelTransfer.hasData(PanelTransfer.prototype);
268
- if (!isPanelEvent) {
269
- return undefined;
270
- }
271
- return panelTransfer.getData(PanelTransfer.prototype)[0];
272
- }
273
- function getPaneData() {
274
- const paneTransfer = LocalSelectionTransfer.getInstance();
275
- const isPanelEvent = paneTransfer.hasData(PaneTransfer.prototype);
276
- if (!isPanelEvent) {
277
- return undefined;
278
- }
279
- return paneTransfer.getData(PaneTransfer.prototype)[0];
280
- }
281
-
282
193
  class SplitviewApi {
283
194
  constructor(component) {
284
195
  this.component = component;
@@ -298,6 +209,9 @@
298
209
  get length() {
299
210
  return this.component.length;
300
211
  }
212
+ get orientation() {
213
+ return this.component.orientation;
214
+ }
301
215
  get onDidLayoutChange() {
302
216
  return this.component.onDidLayoutChange;
303
217
  }
@@ -307,9 +221,6 @@
307
221
  get onDidRemoveView() {
308
222
  return this.component.onDidRemoveView;
309
223
  }
310
- get orientation() {
311
- return this.component.orientation;
312
- }
313
224
  updateOptions(options) {
314
225
  this.component.updateOptions(options);
315
226
  }
@@ -354,18 +265,18 @@
354
265
  constructor(component) {
355
266
  this.component = component;
356
267
  }
357
- get width() {
358
- return this.component.width;
359
- }
360
- get height() {
361
- return this.component.height;
362
- }
363
268
  get minimumSize() {
364
269
  return this.component.minimumSize;
365
270
  }
366
271
  get maximumSize() {
367
272
  return this.component.maximumSize;
368
273
  }
274
+ get height() {
275
+ return this.component.height;
276
+ }
277
+ get width() {
278
+ return this.component.width;
279
+ }
369
280
  get onDidLayoutChange() {
370
281
  return this.component.onDidLayoutChange;
371
282
  }
@@ -405,7 +316,7 @@
405
316
  this.component.layout(width, height);
406
317
  }
407
318
  addPanel(options) {
408
- return this.component.addPanel(options);
319
+ this.component.addPanel(options);
409
320
  }
410
321
  resizeToFit() {
411
322
  this.component.resizeToFit();
@@ -421,12 +332,6 @@
421
332
  constructor(component) {
422
333
  this.component = component;
423
334
  }
424
- get width() {
425
- return this.component.width;
426
- }
427
- get height() {
428
- return this.component.height;
429
- }
430
335
  get minimumHeight() {
431
336
  return this.component.minimumHeight;
432
337
  }
@@ -439,12 +344,27 @@
439
344
  get maximumWidth() {
440
345
  return this.component.maximumWidth;
441
346
  }
442
- get onGridEvent() {
443
- return this.component.onGridEvent;
347
+ get width() {
348
+ return this.component.width;
349
+ }
350
+ get height() {
351
+ return this.component.height;
444
352
  }
445
353
  get onDidLayoutChange() {
446
354
  return this.component.onDidLayoutChange;
447
355
  }
356
+ get onDidAddGroup() {
357
+ return this.component.onDidAddGroup;
358
+ }
359
+ get onDidRemoveGroup() {
360
+ return this.component.onDidRemoveGroup;
361
+ }
362
+ get onDidActiveGroupChange() {
363
+ return this.component.onDidActiveGroupChange;
364
+ }
365
+ get onDidLayoutFromJSON() {
366
+ return this.component.onDidLayoutFromJSON;
367
+ }
448
368
  get panels() {
449
369
  return this.component.groups;
450
370
  }
@@ -519,8 +439,26 @@
519
439
  get totalPanels() {
520
440
  return this.component.totalPanels;
521
441
  }
522
- get onGridEvent() {
523
- return this.component.onGridEvent;
442
+ get onDidActiveGroupChange() {
443
+ return this.component.onDidActiveGroupChange;
444
+ }
445
+ get onDidAddGroup() {
446
+ return this.component.onDidAddGroup;
447
+ }
448
+ get onDidRemoveGroup() {
449
+ return this.component.onDidRemoveGroup;
450
+ }
451
+ get onDidActivePanelChange() {
452
+ return this.component.onDidActivePanelChange;
453
+ }
454
+ get onDidAddPanel() {
455
+ return this.component.onDidAddPanel;
456
+ }
457
+ get onDidRemovePanel() {
458
+ return this.component.onDidRemovePanel;
459
+ }
460
+ get onDidLayoutfromJSON() {
461
+ return this.component.onDidLayoutfromJSON;
524
462
  }
525
463
  get onDidLayoutChange() {
526
464
  return this.component.onDidLayoutChange;
@@ -549,18 +487,12 @@
549
487
  getPanel(id) {
550
488
  return this.component.getGroupPanel(id);
551
489
  }
552
- setActivePanel(panel) {
553
- this.component.setActivePanel(panel);
554
- }
555
490
  layout(width, height, force = false) {
556
491
  this.component.layout(width, height, force);
557
492
  }
558
493
  addPanel(options) {
559
494
  return this.component.addPanel(options);
560
495
  }
561
- removePanel(panel) {
562
- this.component.removePanel(panel);
563
- }
564
496
  addEmptyGroup(options) {
565
497
  this.component.addEmptyGroup(options);
566
498
  }
@@ -590,6 +522,46 @@
590
522
  }
591
523
  }
592
524
 
525
+ var Disposable;
526
+ (function (Disposable) {
527
+ Disposable.NONE = {
528
+ dispose: () => {
529
+ // noop
530
+ },
531
+ };
532
+ })(Disposable || (Disposable = {}));
533
+ class CompositeDisposable {
534
+ constructor(...args) {
535
+ this.disposables = args;
536
+ }
537
+ static from(...args) {
538
+ return new CompositeDisposable(...args);
539
+ }
540
+ addDisposables(...args) {
541
+ args.forEach((arg) => this.disposables.push(arg));
542
+ }
543
+ dispose() {
544
+ this.disposables.forEach((arg) => arg.dispose());
545
+ }
546
+ }
547
+ class MutableDisposable {
548
+ constructor() {
549
+ this._disposable = Disposable.NONE;
550
+ }
551
+ set value(disposable) {
552
+ if (this._disposable) {
553
+ this._disposable.dispose();
554
+ }
555
+ this._disposable = disposable;
556
+ }
557
+ dispose() {
558
+ if (this._disposable) {
559
+ this._disposable.dispose();
560
+ this._disposable = Disposable.NONE;
561
+ }
562
+ }
563
+ }
564
+
593
565
  function watchElementResize(element, cb) {
594
566
  const observer = new ResizeObserver((entires) => {
595
567
  const firstEntry = entires[0];
@@ -1535,13 +1507,13 @@
1535
1507
  this._onDidSashEnd.dispose();
1536
1508
  this._onDidAddView.dispose();
1537
1509
  this._onDidRemoveView.dispose();
1538
- this.element.remove();
1539
1510
  for (let i = 0; i < this.element.children.length; i++) {
1540
1511
  if (this.element.children.item(i) === this.element) {
1541
1512
  this.element.removeChild(this.element);
1542
1513
  break;
1543
1514
  }
1544
1515
  }
1516
+ this.element.remove();
1545
1517
  }
1546
1518
  }
1547
1519
 
@@ -1564,7 +1536,7 @@
1564
1536
  });
1565
1537
  // if we've added views from the descriptor we need to
1566
1538
  // add the panes to our Pane array and setup animation
1567
- this.getPanes().forEach((pane, index) => {
1539
+ this.getPanes().forEach((pane) => {
1568
1540
  const disposable = new CompositeDisposable(pane.onDidChangeExpansionState(() => {
1569
1541
  this.setupAnimation();
1570
1542
  this._onDidChange.fire(undefined);
@@ -1580,7 +1552,7 @@
1580
1552
  this.paneItems.push(paneItem);
1581
1553
  pane.orthogonalSize = this.splitview.orthogonalSize;
1582
1554
  });
1583
- this.addDisposables(this.splitview.onDidSashEnd(() => {
1555
+ this.addDisposables(this._onDidChange, this.splitview.onDidSashEnd(() => {
1584
1556
  this._onDidChange.fire(undefined);
1585
1557
  }), this.splitview.onDidAddView(() => {
1586
1558
  this._onDidChange.fire();
@@ -1632,17 +1604,20 @@
1632
1604
  getPanes() {
1633
1605
  return this.splitview.getViews();
1634
1606
  }
1635
- removePane(index) {
1607
+ removePane(index, options = { skipDispose: false }) {
1636
1608
  const paneItem = this.paneItems.splice(index, 1)[0];
1637
1609
  this.splitview.removeView(index);
1638
- paneItem.disposable.dispose();
1610
+ if (!options.skipDispose) {
1611
+ paneItem.disposable.dispose();
1612
+ paneItem.pane.dispose();
1613
+ }
1639
1614
  return paneItem;
1640
1615
  }
1641
1616
  moveView(from, to) {
1642
1617
  if (from === to) {
1643
1618
  return;
1644
1619
  }
1645
- const view = this.removePane(from);
1620
+ const view = this.removePane(from, { skipDispose: true });
1646
1621
  this.skipAnimation = true;
1647
1622
  try {
1648
1623
  this.addPane(view.pane, view.pane.size, to, false);
@@ -1670,15 +1645,16 @@
1670
1645
  }
1671
1646
  dispose() {
1672
1647
  super.dispose();
1673
- this.splitview.dispose();
1674
1648
  if (this.animationTimer) {
1675
1649
  clearTimeout(this.animationTimer);
1676
1650
  this.animationTimer = undefined;
1677
1651
  }
1678
1652
  this.paneItems.forEach((paneItem) => {
1679
1653
  paneItem.disposable.dispose();
1654
+ paneItem.pane.dispose();
1680
1655
  });
1681
1656
  this.paneItems = [];
1657
+ this.splitview.dispose();
1682
1658
  this.element.remove();
1683
1659
  }
1684
1660
  }
@@ -1741,8 +1717,8 @@
1741
1717
  this.options = options;
1742
1718
  this._onDrop = new Emitter();
1743
1719
  this.onDrop = this._onDrop.event;
1744
- this.addDisposables(new DragAndDropObserver(this.element, {
1745
- onDragEnter: (e) => undefined,
1720
+ this.addDisposables(this._onDrop, new DragAndDropObserver(this.element, {
1721
+ onDragEnter: () => undefined,
1746
1722
  onDragOver: (e) => {
1747
1723
  if (isBooleanValue(this.options.canDisplayOverlay)) {
1748
1724
  if (!this.options.canDisplayOverlay) {
@@ -1777,56 +1753,16 @@
1777
1753
  const y = e.offsetY;
1778
1754
  const xp = (100 * x) / width;
1779
1755
  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
- }
1756
+ const quadrant = this.calculateQuadrant(this.options.validOverlays, xp, yp);
1800
1757
  const isSmallX = width < 100;
1801
1758
  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
- }
1759
+ this.toggleClasses(quadrant, isSmallX, isSmallY);
1760
+ this.setState(quadrant);
1825
1761
  },
1826
- onDragLeave: (e) => {
1762
+ onDragLeave: () => {
1827
1763
  this.removeDropTarget();
1828
1764
  },
1829
- onDragEnd: (e) => {
1765
+ onDragEnd: () => {
1830
1766
  this.removeDropTarget();
1831
1767
  },
1832
1768
  onDrop: (e) => {
@@ -1850,9 +1786,73 @@
1850
1786
  this.options.canDisplayOverlay = value;
1851
1787
  }
1852
1788
  dispose() {
1853
- this._onDrop.dispose();
1854
1789
  this.removeDropTarget();
1855
1790
  }
1791
+ toggleClasses(quadrant, isSmallX, isSmallY) {
1792
+ if (!this.overlay) {
1793
+ return;
1794
+ }
1795
+ const isLeft = quadrant === 'left';
1796
+ const isRight = quadrant === 'right';
1797
+ const isTop = quadrant === 'top';
1798
+ const isBottom = quadrant === 'bottom';
1799
+ toggleClass(this.overlay, 'right', !isSmallX && isRight);
1800
+ toggleClass(this.overlay, 'left', !isSmallX && isLeft);
1801
+ toggleClass(this.overlay, 'top', !isSmallY && isTop);
1802
+ toggleClass(this.overlay, 'bottom', !isSmallY && isBottom);
1803
+ toggleClass(this.overlay, 'small-right', isSmallX && isRight);
1804
+ toggleClass(this.overlay, 'small-left', isSmallX && isLeft);
1805
+ toggleClass(this.overlay, 'small-top', isSmallY && isTop);
1806
+ toggleClass(this.overlay, 'small-bottom', isSmallY && isBottom);
1807
+ }
1808
+ setState(quadrant) {
1809
+ switch (quadrant) {
1810
+ case 'top':
1811
+ this._state = exports.Position.Top;
1812
+ break;
1813
+ case 'left':
1814
+ this._state = exports.Position.Left;
1815
+ break;
1816
+ case 'bottom':
1817
+ this._state = exports.Position.Bottom;
1818
+ break;
1819
+ case 'right':
1820
+ this._state = exports.Position.Right;
1821
+ break;
1822
+ default:
1823
+ this._state = exports.Position.Center;
1824
+ break;
1825
+ }
1826
+ }
1827
+ calculateQuadrant(overlayType, xp, yp) {
1828
+ switch (overlayType) {
1829
+ case 'all':
1830
+ if (xp < 20) {
1831
+ return 'left';
1832
+ }
1833
+ if (xp > 80) {
1834
+ return 'right';
1835
+ }
1836
+ if (yp < 20) {
1837
+ return 'top';
1838
+ }
1839
+ if (yp > 80) {
1840
+ return 'bottom';
1841
+ }
1842
+ break;
1843
+ case 'vertical':
1844
+ if (yp < 50) {
1845
+ return 'top';
1846
+ }
1847
+ return 'bottom';
1848
+ case 'horizontal':
1849
+ if (xp < 50) {
1850
+ return 'left';
1851
+ }
1852
+ return 'right';
1853
+ }
1854
+ return null;
1855
+ }
1856
1856
  removeDropTarget() {
1857
1857
  if (this.target) {
1858
1858
  this._state = undefined;
@@ -1955,6 +1955,7 @@
1955
1955
  this.view.layout(this.width, this.height);
1956
1956
  }
1957
1957
  dispose() {
1958
+ this._onDidChange.dispose();
1958
1959
  this._disposable.dispose();
1959
1960
  }
1960
1961
  }
@@ -1972,7 +1973,7 @@
1972
1973
  this.children = [];
1973
1974
  this._onDidChange = new Emitter();
1974
1975
  this.onDidChange = this._onDidChange.event;
1975
- this._childrenDisposable = exports.Disposable.NONE;
1976
+ this._childrenDisposable = Disposable.NONE;
1976
1977
  this._orthogonalSize = orthogonalSize;
1977
1978
  this._size = size;
1978
1979
  this.element = document.createElement('div');
@@ -1997,7 +1998,7 @@
1997
1998
  : true,
1998
1999
  };
1999
2000
  }),
2000
- size: this.orthogonalSize,
2001
+ size: this.size,
2001
2002
  };
2002
2003
  this.children = childDescriptors.map((c) => c.node);
2003
2004
  this.splitview = new Splitview(this.element, {
@@ -2006,7 +2007,7 @@
2006
2007
  proportionalLayout,
2007
2008
  });
2008
2009
  }
2009
- this.addDisposables(this.splitview.onDidSashEnd(() => {
2010
+ this.addDisposables(this._onDidChange, this.splitview.onDidSashEnd(() => {
2010
2011
  this._onDidChange.fire(undefined);
2011
2012
  }));
2012
2013
  this.setupChildrenEvents();
@@ -2158,7 +2159,7 @@
2158
2159
  }
2159
2160
  setupChildrenEvents() {
2160
2161
  this._childrenDisposable.dispose();
2161
- this._childrenDisposable = exports.Event.any(...this.children.map((c) => c.onDidChange))((e) => {
2162
+ this._childrenDisposable = exports.Event.any(...this.children.map((c) => c.onDidChange))(() => {
2162
2163
  /**
2163
2164
  * indicate a change has occured to allows any re-rendering but don't bubble
2164
2165
  * event because that was specific to this branch
@@ -2178,6 +2179,15 @@
2178
2179
  * Accreditation: This file is largly based upon the MIT licenced VSCode sourcecode found at:
2179
2180
  * https://github.com/microsoft/vscode/tree/main/src/vs/base/browser/ui/grid
2180
2181
  *--------------------------------------------------------------------------------------------*/
2182
+ function findLeaf(candiateNode, last) {
2183
+ if (candiateNode instanceof LeafNode) {
2184
+ return candiateNode;
2185
+ }
2186
+ if (candiateNode instanceof BranchNode) {
2187
+ return findLeaf(candiateNode.children[last ? candiateNode.children.length - 1 : 0], last);
2188
+ }
2189
+ throw new Error('invalid node');
2190
+ }
2181
2191
  function flipNode(node, size, orthogonalSize) {
2182
2192
  if (node instanceof BranchNode) {
2183
2193
  const result = new BranchNode(orthogonal(node.orientation), node.proportionalLayout, node.styles, size, orthogonalSize);
@@ -2309,6 +2319,7 @@
2309
2319
  this.disposable.dispose();
2310
2320
  this._onDidChange.dispose();
2311
2321
  this.root.dispose();
2322
+ this.element.remove();
2312
2323
  }
2313
2324
  clear() {
2314
2325
  const orientation = this.root.orientation;
@@ -2316,13 +2327,13 @@
2316
2327
  }
2317
2328
  deserialize(json, deserializer) {
2318
2329
  const orientation = json.orientation;
2319
- const height = json.height;
2330
+ const height = orientation === exports.Orientation.VERTICAL ? json.height : json.width;
2320
2331
  this._deserialize(json.root, orientation, deserializer, height);
2321
2332
  }
2322
2333
  _deserialize(root, orientation, deserializer, orthogonalSize) {
2323
- this.root = this._deserializeNode(root, orientation, deserializer, orthogonalSize);
2334
+ this.root = this._deserializeNode(root, orientation, deserializer, orthogonalSize, true);
2324
2335
  }
2325
- _deserializeNode(node, orientation, deserializer, orthogonalSize) {
2336
+ _deserializeNode(node, orientation, deserializer, orthogonalSize, isRoot = false) {
2326
2337
  let result;
2327
2338
  if (node.type === 'branch') {
2328
2339
  const serializedChildren = node.data;
@@ -2332,7 +2343,9 @@
2332
2343
  visible: serializedChild.visible,
2333
2344
  };
2334
2345
  });
2335
- result = new BranchNode(orientation, this.proportionalLayout, this.styles, node.size, orthogonalSize, children);
2346
+ // HORIZONTAL => height=orthogonalsize width=size
2347
+ // VERTICAL => height=size width=orthogonalsize
2348
+ result = new BranchNode(orientation, this.proportionalLayout, this.styles, isRoot ? orthogonalSize : node.size, isRoot ? node.size : orthogonalSize, children);
2336
2349
  }
2337
2350
  else {
2338
2351
  result = new LeafNode(deserializer.fromJSON(node), orientation, orthogonalSize, node.size);
@@ -2393,15 +2406,6 @@
2393
2406
  if (!(node instanceof LeafNode)) {
2394
2407
  throw new Error('invalid location');
2395
2408
  }
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
2409
  for (let i = path.length - 1; i > -1; i--) {
2406
2410
  const n = path[i];
2407
2411
  const l = location[i] || 0;
@@ -2503,9 +2507,9 @@
2503
2507
  if (parent.children.length > 1) {
2504
2508
  return node.view;
2505
2509
  }
2510
+ const sibling = parent.children[0];
2506
2511
  if (pathToParent.length === 0) {
2507
2512
  // parent is root
2508
- const sibling = parent.children[0];
2509
2513
  if (sibling instanceof LeafNode) {
2510
2514
  return node.view;
2511
2515
  }
@@ -2516,10 +2520,9 @@
2516
2520
  }
2517
2521
  const [grandParent, ..._] = [...pathToParent].reverse();
2518
2522
  const [parentIndex, ...__] = [...rest].reverse();
2519
- const sibling = parent.children[0];
2520
2523
  const isSiblingVisible = parent.isChildVisible(0);
2521
2524
  parent.removeChild(0, sizing);
2522
- const sizes = grandParent.children.map((size, i) => grandParent.getChildSize(i));
2525
+ const sizes = grandParent.children.map((_size, i) => grandParent.getChildSize(i));
2523
2526
  grandParent.removeChild(parentIndex, sizing);
2524
2527
  if (sibling instanceof BranchNode) {
2525
2528
  sizes.splice(parentIndex, 1, ...sibling.children.map((c) => c.size));
@@ -2563,31 +2566,6 @@
2563
2566
  }
2564
2567
  }
2565
2568
 
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
2569
  class ContentContainer extends CompositeDisposable {
2592
2570
  constructor() {
2593
2571
  super();
@@ -2599,6 +2577,7 @@
2599
2577
  this._element = document.createElement('div');
2600
2578
  this._element.className = 'content-container';
2601
2579
  this._element.tabIndex = -1;
2580
+ this.addDisposables(this._onDidFocus, this._onDidBlur);
2602
2581
  // for hosted containers
2603
2582
  // 1) register a drop target on the host
2604
2583
  // 2) register window dragStart events to disable pointer events
@@ -2642,7 +2621,7 @@
2642
2621
  }
2643
2622
  this.disposable.value = disposable;
2644
2623
  }
2645
- layout(width, height) {
2624
+ layout(_width, _height) {
2646
2625
  // noop
2647
2626
  }
2648
2627
  closePanel() {
@@ -2665,6 +2644,41 @@
2665
2644
  DockviewDropTargets[DockviewDropTargets["TabContainer"] = 2] = "TabContainer";
2666
2645
  })(DockviewDropTargets || (DockviewDropTargets = {}));
2667
2646
 
2647
+ class DragHandler extends CompositeDisposable {
2648
+ constructor(el) {
2649
+ super();
2650
+ this.el = el;
2651
+ this.disposable = new MutableDisposable();
2652
+ this._onDragStart = new Emitter();
2653
+ this.onDragStart = this._onDragStart.event;
2654
+ this.iframes = [];
2655
+ this.configure();
2656
+ }
2657
+ configure() {
2658
+ this.addDisposables(this._onDragStart, addDisposableListener(this.el, 'dragstart', (event) => {
2659
+ this.iframes = [
2660
+ ...getElementsByTagName('iframe'),
2661
+ ...getElementsByTagName('webview'),
2662
+ ];
2663
+ for (const iframe of this.iframes) {
2664
+ iframe.style.pointerEvents = 'none';
2665
+ }
2666
+ this.el.classList.add('dragged');
2667
+ setTimeout(() => this.el.classList.remove('dragged'), 0);
2668
+ this.disposable.value = this.getData();
2669
+ if (event.dataTransfer) {
2670
+ event.dataTransfer.effectAllowed = 'move';
2671
+ }
2672
+ }), addDisposableListener(this.el, 'dragend', () => {
2673
+ for (const iframe of this.iframes) {
2674
+ iframe.style.pointerEvents = 'auto';
2675
+ }
2676
+ this.iframes = [];
2677
+ this.disposable.dispose();
2678
+ }));
2679
+ }
2680
+ }
2681
+
2668
2682
  exports.MouseEventKind = void 0;
2669
2683
  (function (MouseEventKind) {
2670
2684
  MouseEventKind["CLICK"] = "CLICK";
@@ -2674,42 +2688,34 @@
2674
2688
  constructor(panelId, accessor, group) {
2675
2689
  super();
2676
2690
  this.panelId = panelId;
2677
- this.accessor = accessor;
2678
2691
  this.group = group;
2679
2692
  this._onChanged = new Emitter();
2680
2693
  this.onChanged = this._onChanged.event;
2681
2694
  this._onDropped = new Emitter();
2682
2695
  this.onDrop = this._onDropped.event;
2683
- this.panelTransfer = LocalSelectionTransfer.getInstance();
2684
- this.iframes = [];
2685
2696
  this.addDisposables(this._onChanged, this._onDropped);
2686
2697
  this._element = document.createElement('div');
2687
2698
  this._element.className = 'tab';
2688
2699
  this._element.tabIndex = 0;
2689
2700
  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';
2701
+ this.addDisposables(new (class Handler extends DragHandler {
2702
+ constructor() {
2703
+ super(...arguments);
2704
+ this.panelTransfer = LocalSelectionTransfer.getInstance();
2697
2705
  }
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';
2706
+ getData() {
2707
+ this.panelTransfer.setData([new PanelTransfer(accessor.id, group.id, panelId)], PanelTransfer.prototype);
2708
+ return {
2709
+ dispose: () => {
2710
+ this.panelTransfer.clearData(PanelTransfer.prototype);
2711
+ },
2712
+ };
2705
2713
  }
2706
- }), addDisposableListener(this._element, 'dragend', (ev) => {
2707
- for (const iframe of this.iframes) {
2708
- iframe.style.pointerEvents = 'auto';
2714
+ dispose() {
2715
+ //
2709
2716
  }
2710
- this.iframes = [];
2711
- this.panelTransfer.clearData(PanelTransfer.prototype);
2712
- }), addDisposableListener(this._element, 'mousedown', (event) => {
2717
+ })(this._element));
2718
+ this.addDisposables(addDisposableListener(this._element, 'mousedown', (event) => {
2713
2719
  if (event.defaultPrevented) {
2714
2720
  return;
2715
2721
  }
@@ -2911,12 +2917,10 @@
2911
2917
  if (!isLeftClick || event.event.defaultPrevented) {
2912
2918
  return;
2913
2919
  }
2914
- switch (event.kind) {
2915
- case exports.MouseEventKind.CLICK:
2916
- this.group.model.openPanel(panel, {
2917
- skipFocus: alreadyFocused,
2918
- });
2919
- break;
2920
+ if (event.kind === exports.MouseEventKind.CLICK) {
2921
+ this.group.model.openPanel(panel, {
2922
+ skipFocus: alreadyFocused,
2923
+ });
2920
2924
  }
2921
2925
  }), tabToAdd.onDrop((event) => {
2922
2926
  this._onDrop.fire({
@@ -2945,7 +2949,6 @@
2945
2949
  GroupChangeKind2["ADD_PANEL"] = "ADD_PANEL";
2946
2950
  GroupChangeKind2["REMOVE_PANEL"] = "REMOVE_PANEL";
2947
2951
  GroupChangeKind2["PANEL_ACTIVE"] = "PANEL_ACTIVE";
2948
- GroupChangeKind2["GROUP_ACTIVE"] = "GROUP_ACTIVE";
2949
2952
  })(exports.GroupChangeKind2 || (exports.GroupChangeKind2 = {}));
2950
2953
  class Groupview extends CompositeDisposable {
2951
2954
  constructor(container, accessor, id, options, parent) {
@@ -2966,15 +2969,10 @@
2966
2969
  this.onMove = this._onMove.event;
2967
2970
  this._onDidGroupChange = new Emitter();
2968
2971
  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
- });
2972
+ this._onDidDrop = new Emitter();
2973
+ this.onDidDrop = this._onDidDrop.event;
2976
2974
  this.container.classList.add('groupview');
2977
- this.addDisposables(this._onMove, this._onDidGroupChange);
2975
+ this.addDisposables(this._onMove, this._onDidGroupChange, this._onDidChange, this._onDidDrop);
2978
2976
  this.tabsContainer = new TabsContainer(this.accessor, this.parent, {
2979
2977
  tabHeight: options.tabHeight,
2980
2978
  });
@@ -3038,6 +3036,9 @@
3038
3036
  get maximumWidth() {
3039
3037
  return Number.MAX_SAFE_INTEGER;
3040
3038
  }
3039
+ get hasWatermark() {
3040
+ return !!(this.watermark && this.container.contains(this.watermark.element));
3041
+ }
3041
3042
  initialize() {
3042
3043
  var _a, _b;
3043
3044
  if ((_a = this.options) === null || _a === void 0 ? void 0 : _a.panels) {
@@ -3116,10 +3117,10 @@
3116
3117
  containsPanel(panel) {
3117
3118
  return this.panels.includes(panel);
3118
3119
  }
3119
- init(params) {
3120
+ init(_params) {
3120
3121
  //noop
3121
3122
  }
3122
- update(params) {
3123
+ update(_params) {
3123
3124
  //noop
3124
3125
  }
3125
3126
  focus() {
@@ -3131,6 +3132,8 @@
3131
3132
  options.index > this.panels.length) {
3132
3133
  options.index = this.panels.length;
3133
3134
  }
3135
+ // ensure the group is updated before we fire any events
3136
+ panel.updateParentGroup(this.parent, true);
3134
3137
  if (this._activePanel === panel) {
3135
3138
  this.accessor.doSetGroupActive(this.parent);
3136
3139
  return;
@@ -3151,43 +3154,19 @@
3151
3154
  return this._removePanel(panelToRemove);
3152
3155
  }
3153
3156
  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)));
3157
+ if (this.panels.length > 0) {
3158
+ // take a copy since we will be edting the array as we iterate through
3159
+ const arrPanelCpy = [...this.panels];
3160
+ for (const panel of arrPanelCpy) {
3161
+ this.doClose(panel);
3185
3162
  }
3186
- else {
3187
- this.accessor.removeGroup(this.parent);
3188
- }
3189
- return true;
3190
- });
3163
+ }
3164
+ else {
3165
+ this.accessor.removeGroup(this.parent);
3166
+ }
3167
+ }
3168
+ closePanel(panel) {
3169
+ this.doClose(panel);
3191
3170
  }
3192
3171
  doClose(panel) {
3193
3172
  this.accessor.removePanel(panel);
@@ -3330,8 +3309,11 @@
3330
3309
  this.tabsContainer.show();
3331
3310
  }
3332
3311
  }
3333
- canDisplayOverlay(dragOverEvent, target) {
3312
+ canDisplayOverlay(event, target) {
3334
3313
  // custom overlay handler
3314
+ if (this.accessor.options.showDndOverlay) {
3315
+ return this.accessor.options.showDndOverlay(event, target);
3316
+ }
3335
3317
  return false;
3336
3318
  }
3337
3319
  handleDropEvent(event, position, index) {
@@ -3356,31 +3338,23 @@
3356
3338
  index,
3357
3339
  });
3358
3340
  }
3341
+ else {
3342
+ this._onDidDrop.fire({ nativeEvent: event, position, index });
3343
+ }
3359
3344
  }
3360
3345
  dispose() {
3346
+ var _a;
3347
+ super.dispose();
3348
+ (_a = this.watermark) === null || _a === void 0 ? void 0 : _a.dispose();
3361
3349
  for (const panel of this.panels) {
3362
3350
  panel.dispose();
3363
3351
  }
3364
- super.dispose();
3365
3352
  this.dropTarget.dispose();
3366
3353
  this.tabsContainer.dispose();
3367
3354
  this.contentContainer.dispose();
3368
3355
  }
3369
3356
  }
3370
3357
 
3371
- exports.GroupChangeKind = void 0;
3372
- (function (GroupChangeKind) {
3373
- GroupChangeKind["ADD_PANEL"] = "ADD_PANEL";
3374
- GroupChangeKind["REMOVE_PANEL"] = "REMOVE_PANEL";
3375
- GroupChangeKind["PANEL_ACTIVE"] = "PANEL_ACTIVE";
3376
- //
3377
- GroupChangeKind["GROUP_ACTIVE"] = "GROUP_ACTIVE";
3378
- GroupChangeKind["ADD_GROUP"] = "ADD_GROUP";
3379
- GroupChangeKind["REMOVE_GROUP"] = "REMOVE_GROUP";
3380
- //
3381
- GroupChangeKind["LAYOUT_FROM_JSON"] = "LAYOUT_FROM_JSON";
3382
- GroupChangeKind["LAYOUT"] = "LAYOUT";
3383
- })(exports.GroupChangeKind || (exports.GroupChangeKind = {}));
3384
3358
  const nextLayoutId = sequentialNumberGenerator();
3385
3359
  function toTarget(direction) {
3386
3360
  switch (direction) {
@@ -3403,36 +3377,26 @@
3403
3377
  this._element = _element;
3404
3378
  this._id = nextLayoutId.next();
3405
3379
  this._groups = new Map();
3406
- //
3407
- this._onGridEvent = new Emitter();
3408
- this.onGridEvent = this._onGridEvent.event;
3409
3380
  this._onDidLayoutChange = new Emitter();
3410
3381
  this.onDidLayoutChange = this._onDidLayoutChange.event;
3382
+ this._onDidRemoveGroup = new Emitter();
3383
+ this.onDidRemoveGroup = this._onDidRemoveGroup.event;
3384
+ this._onDidAddGroup = new Emitter();
3385
+ this.onDidAddGroup = this._onDidAddGroup.event;
3386
+ this._onDidActiveGroupChange = new Emitter();
3387
+ this.onDidActiveGroupChange = this._onDidActiveGroupChange.event;
3388
+ this._bufferOnDidLayoutChange = new TickDelayedEvent();
3411
3389
  this.gridview = new Gridview(!!options.proportionalLayout, options.styles, options.orientation);
3412
3390
  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);
3391
+ this.layout(0, 0, true); // set some elements height/widths
3415
3392
  this.addDisposables(this.gridview.onDidChange(() => {
3416
- this._onGridEvent.fire({ kind: exports.GroupChangeKind.LAYOUT });
3393
+ this._onDidLayoutChange.fire();
3417
3394
  }));
3418
- this.addDisposables((() => {
3419
- const tickDelayedEvent = new TickDelayedEvent();
3420
- return new CompositeDisposable(this.onGridEvent((event) => {
3421
- if ([
3422
- exports.GroupChangeKind.ADD_GROUP,
3423
- exports.GroupChangeKind.REMOVE_GROUP,
3424
- exports.GroupChangeKind.ADD_PANEL,
3425
- exports.GroupChangeKind.REMOVE_PANEL,
3426
- exports.GroupChangeKind.GROUP_ACTIVE,
3427
- exports.GroupChangeKind.PANEL_ACTIVE,
3428
- exports.GroupChangeKind.LAYOUT,
3429
- ].includes(event.kind)) {
3430
- tickDelayedEvent.fire();
3431
- }
3432
- }), tickDelayedEvent.onEvent(() => {
3433
- this._onDidLayoutChange.fire();
3434
- }), tickDelayedEvent);
3435
- })());
3395
+ this.addDisposables(exports.Event.any(this.onDidAddGroup, this.onDidRemoveGroup, this.onDidActiveGroupChange)(() => {
3396
+ this._bufferOnDidLayoutChange.fire();
3397
+ }), this._bufferOnDidLayoutChange.onEvent(() => {
3398
+ this._onDidLayoutChange.fire();
3399
+ }), this._bufferOnDidLayoutChange);
3436
3400
  }
3437
3401
  get id() {
3438
3402
  return this._id;
@@ -3469,14 +3433,14 @@
3469
3433
  }
3470
3434
  setVisible(panel, visible) {
3471
3435
  this.gridview.setViewVisible(getGridLocation(panel.element), visible);
3472
- this._onGridEvent.fire({ kind: exports.GroupChangeKind.LAYOUT });
3436
+ this._onDidLayoutChange.fire();
3473
3437
  }
3474
3438
  isVisible(panel) {
3475
3439
  return this.gridview.isViewVisible(getGridLocation(panel.element));
3476
3440
  }
3477
3441
  doAddGroup(group, location = [0], size) {
3478
3442
  this.gridview.addView(group, size !== null && size !== void 0 ? size : exports.Sizing.Distribute, location);
3479
- this._onGridEvent.fire({ kind: exports.GroupChangeKind.ADD_GROUP });
3443
+ this._onDidAddGroup.fire(group);
3480
3444
  this.doSetGroupActive(group);
3481
3445
  }
3482
3446
  doRemoveGroup(group, options) {
@@ -3487,9 +3451,10 @@
3487
3451
  const view = this.gridview.remove(group, exports.Sizing.Distribute);
3488
3452
  if (item && !(options === null || options === void 0 ? void 0 : options.skipDispose)) {
3489
3453
  item.disposable.dispose();
3454
+ item.value.dispose();
3490
3455
  this._groups.delete(group.id);
3491
3456
  }
3492
- this._onGridEvent.fire({ kind: exports.GroupChangeKind.REMOVE_GROUP });
3457
+ this._onDidRemoveGroup.fire(group);
3493
3458
  if (!(options === null || options === void 0 ? void 0 : options.skipActive) && this._activeGroup === group) {
3494
3459
  const groups = Array.from(this._groups.values());
3495
3460
  this.doSetGroupActive(groups.length > 0 ? groups[0].value : undefined);
@@ -3517,9 +3482,7 @@
3517
3482
  }
3518
3483
  }
3519
3484
  this._activeGroup = group;
3520
- this._onGridEvent.fire({
3521
- kind: exports.GroupChangeKind.GROUP_ACTIVE,
3522
- });
3485
+ this._onDidActiveGroupChange.fire(group);
3523
3486
  }
3524
3487
  removeGroup(group) {
3525
3488
  this.doRemoveGroup(group);
@@ -3575,7 +3538,13 @@
3575
3538
  }
3576
3539
  dispose() {
3577
3540
  super.dispose();
3578
- this._onGridEvent.dispose();
3541
+ this._onDidActiveGroupChange.dispose();
3542
+ this._onDidAddGroup.dispose();
3543
+ this._onDidRemoveGroup.dispose();
3544
+ this._onDidLayoutChange.dispose();
3545
+ for (const group of this.groups) {
3546
+ group.dispose();
3547
+ }
3579
3548
  this.gridview.dispose();
3580
3549
  }
3581
3550
  }
@@ -3587,15 +3556,11 @@
3587
3556
  constructor(id) {
3588
3557
  super();
3589
3558
  this.id = id;
3590
- this._state = {};
3591
3559
  this._isFocused = false;
3592
3560
  this._isActive = false;
3593
3561
  this._isVisible = true;
3594
3562
  this._width = 0;
3595
3563
  this._height = 0;
3596
- this._onDidStateChange = new Emitter();
3597
- this.onDidStateChange = this._onDidStateChange.event;
3598
- //
3599
3564
  this._onDidPanelDimensionChange = new Emitter({
3600
3565
  replay: true,
3601
3566
  });
@@ -3624,7 +3589,7 @@
3624
3589
  //
3625
3590
  this._onActiveChange = new Emitter();
3626
3591
  this.onActiveChange = this._onActiveChange.event;
3627
- this.addDisposables(this._onDidStateChange, this._onDidPanelDimensionChange, this._onDidChangeFocus, this._onDidVisibilityChange, this._onDidActiveChange, this._onFocusEvent, this.onDidFocusChange((event) => {
3592
+ this.addDisposables(this._onDidPanelDimensionChange, this._onDidChangeFocus, this._onDidVisibilityChange, this._onDidActiveChange, this._onFocusEvent, this._onActiveChange, this._onVisibilityChange, this.onDidFocusChange((event) => {
3628
3593
  this._isFocused = event.isFocused;
3629
3594
  }), this.onDidActiveChange((event) => {
3630
3595
  this._isActive = event.isActive;
@@ -3657,21 +3622,6 @@
3657
3622
  setActive() {
3658
3623
  this._onActiveChange.fire();
3659
3624
  }
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
3625
  dispose() {
3676
3626
  super.dispose();
3677
3627
  }
@@ -3691,6 +3641,7 @@
3691
3641
  //
3692
3642
  this._onDidSizeChange = new Emitter();
3693
3643
  this.onDidSizeChange = this._onDidSizeChange.event;
3644
+ this.addDisposables(this._onDidConstraintsChangeInternal, this._onDidConstraintsChange, this._onDidSizeChange);
3694
3645
  }
3695
3646
  setConstraints(value) {
3696
3647
  this._onDidConstraintsChangeInternal.fire(value);
@@ -3704,19 +3655,19 @@
3704
3655
  constructor(panel, group) {
3705
3656
  super(panel.id);
3706
3657
  this.panel = panel;
3707
- this._onDidDirtyChange = new Emitter();
3708
- this.onDidDirtyChange = this._onDidDirtyChange.event;
3709
3658
  this._onDidTitleChange = new Emitter();
3710
3659
  this.onDidTitleChange = this._onDidTitleChange.event;
3711
3660
  this._titleChanged = new Emitter();
3712
3661
  this.titleChanged = this._titleChanged.event;
3713
3662
  this._suppressClosableChanged = new Emitter();
3714
3663
  this.suppressClosableChanged = this._suppressClosableChanged.event;
3715
- this._group = group;
3716
- this.addDisposables(this._onDidDirtyChange);
3717
- }
3718
- get tryClose() {
3719
- return this._interceptor;
3664
+ this._onDidActiveGroupChange = new Emitter();
3665
+ this.onDidActiveGroupChange = this._onDidActiveGroupChange.event;
3666
+ this._onDidGroupChange = new Emitter();
3667
+ this.onDidGroupChange = this._onDidGroupChange.event;
3668
+ this.disposable = new MutableDisposable();
3669
+ this.group = group;
3670
+ this.addDisposables(this.disposable, this._onDidTitleChange, this._titleChanged, this._suppressClosableChanged, this._onDidGroupChange, this._onDidActiveGroupChange);
3720
3671
  }
3721
3672
  get title() {
3722
3673
  return this.panel.title;
@@ -3729,7 +3680,17 @@
3729
3680
  return !!((_a = this.group) === null || _a === void 0 ? void 0 : _a.isActive);
3730
3681
  }
3731
3682
  set group(value) {
3683
+ const isOldGroupActive = this.isGroupActive;
3732
3684
  this._group = value;
3685
+ this._onDidGroupChange.fire();
3686
+ if (this._group) {
3687
+ this.disposable.value = this._group.api.onDidActiveChange(() => {
3688
+ this._onDidActiveGroupChange.fire();
3689
+ });
3690
+ if (this.isGroupActive !== isOldGroupActive) {
3691
+ this._onDidActiveGroupChange.fire();
3692
+ }
3693
+ }
3733
3694
  }
3734
3695
  get group() {
3735
3696
  return this._group;
@@ -3743,16 +3704,10 @@
3743
3704
  }
3744
3705
  return this.group.model.closePanel(this.panel);
3745
3706
  }
3746
- interceptOnCloseAction(interceptor) {
3747
- this._interceptor = interceptor;
3748
- }
3749
- dispose() {
3750
- super.dispose();
3751
- }
3752
3707
  }
3753
3708
 
3754
3709
  class DockviewGroupPanel extends CompositeDisposable {
3755
- constructor(id, containerApi) {
3710
+ constructor(id, accessor, containerApi) {
3756
3711
  super();
3757
3712
  this.id = id;
3758
3713
  this.containerApi = containerApi;
@@ -3760,14 +3715,17 @@
3760
3715
  this._suppressClosable = false;
3761
3716
  this._title = '';
3762
3717
  this.api = new DockviewPanelApiImpl(this, this._group);
3763
- this.onDidStateChange = this.api.onDidStateChange;
3764
3718
  this.addDisposables(this.api.onActiveChange(() => {
3765
- this.containerApi.setActivePanel(this);
3719
+ accessor.setActivePanel(this);
3766
3720
  }), this.api.onDidTitleChange((event) => {
3767
3721
  const title = event.title;
3768
3722
  this.update({ params: { title } });
3769
3723
  }));
3770
3724
  }
3725
+ get params() {
3726
+ var _a;
3727
+ return (_a = this._params) === null || _a === void 0 ? void 0 : _a.params;
3728
+ }
3771
3729
  get title() {
3772
3730
  return this._title;
3773
3731
  }
@@ -3786,32 +3744,18 @@
3786
3744
  this._view = params.view;
3787
3745
  this.setTitle(params.title);
3788
3746
  this.setSuppressClosable(params.suppressClosable || false);
3789
- if (params.state) {
3790
- this.api.setState(params.state);
3791
- }
3792
3747
  (_a = this.view) === null || _a === void 0 ? void 0 : _a.init(Object.assign(Object.assign({}, params), { api: this.api, containerApi: this.containerApi }));
3793
3748
  }
3794
3749
  focus() {
3795
3750
  this.api._onFocusEvent.fire();
3796
3751
  }
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
3752
  toJSON() {
3807
- const state = this.api.getState();
3808
3753
  return {
3809
3754
  id: this.id,
3810
3755
  view: this.view.toJSON(),
3811
3756
  params: Object.keys(this._params || {}).length > 0
3812
3757
  ? this._params
3813
3758
  : undefined,
3814
- state: state && Object.keys(state).length > 0 ? state : undefined,
3815
3759
  suppressClosable: this.suppressClosable || undefined,
3816
3760
  title: this.title,
3817
3761
  };
@@ -3856,18 +3800,6 @@
3856
3800
  var _a;
3857
3801
  this._group = group;
3858
3802
  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
3803
  const isPanelVisible = this._group.model.isPanelActive(this);
3872
3804
  this.api._onDidActiveChange.fire({
3873
3805
  isActive: isGroupActive && isPanelVisible,
@@ -3942,7 +3874,7 @@
3942
3874
  get id() {
3943
3875
  return 'watermark';
3944
3876
  }
3945
- update(event) {
3877
+ update(_event) {
3946
3878
  // noop
3947
3879
  }
3948
3880
  focus() {
@@ -3951,17 +3883,17 @@
3951
3883
  toJSON() {
3952
3884
  return {};
3953
3885
  }
3954
- layout(width, height) {
3886
+ layout(_width, _height) {
3955
3887
  // noop
3956
3888
  }
3957
3889
  init(params) {
3958
3890
  this.params = params;
3959
- this.addDisposables(this.params.containerApi.onDidLayoutChange((event) => {
3891
+ this.addDisposables(this.params.containerApi.onDidLayoutChange(() => {
3960
3892
  this.render();
3961
3893
  }));
3962
3894
  this.render();
3963
3895
  }
3964
- updateParentGroup(group, visible) {
3896
+ updateParentGroup(group, _visible) {
3965
3897
  this.group = group;
3966
3898
  this.render();
3967
3899
  }
@@ -3977,15 +3909,6 @@
3977
3909
  }
3978
3910
  }
3979
3911
 
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
3912
  class DefaultDeserializer {
3990
3913
  constructor(layout, panelDeserializer) {
3991
3914
  this.layout = layout;
@@ -4086,9 +4009,6 @@
4086
4009
  this._isGroupActive = false;
4087
4010
  //
4088
4011
  this.params = {};
4089
- //
4090
- this.isDirtyDisposable = new MutableDisposable();
4091
- this.addDisposables(this.isDirtyDisposable);
4092
4012
  this._element = document.createElement('div');
4093
4013
  this._element.className = 'default-tab';
4094
4014
  //
@@ -4133,10 +4053,6 @@
4133
4053
  init(params) {
4134
4054
  this.params = params;
4135
4055
  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
4056
  if (!this.params.suppressClosable) {
4141
4057
  addDisposableListener(this.action, 'click', (ev) => {
4142
4058
  ev.preventDefault(); //
@@ -4152,7 +4068,7 @@
4152
4068
  this._isGroupActive = group.isActive;
4153
4069
  this.render();
4154
4070
  }
4155
- layout(width, height) {
4071
+ layout(_width, _height) {
4156
4072
  // noop
4157
4073
  }
4158
4074
  render() {
@@ -4190,6 +4106,10 @@
4190
4106
  get height() {
4191
4107
  return this._height;
4192
4108
  }
4109
+ get params() {
4110
+ var _a;
4111
+ return (_a = this._params) === null || _a === void 0 ? void 0 : _a.params;
4112
+ }
4193
4113
  focus() {
4194
4114
  this.api._onFocusEvent.fire();
4195
4115
  }
@@ -4198,34 +4118,34 @@
4198
4118
  this._height = height;
4199
4119
  this.api._onDidPanelDimensionChange.fire({ width, height });
4200
4120
  if (this.part) {
4201
- if (this.params) {
4202
- this.part.update(this.params.params);
4121
+ if (this._params) {
4122
+ this.part.update(this._params.params);
4203
4123
  }
4204
4124
  }
4205
4125
  }
4206
4126
  init(parameters) {
4207
- this.params = parameters;
4127
+ this._params = parameters;
4208
4128
  this.part = this.getComponent();
4209
4129
  }
4210
4130
  update(event) {
4211
4131
  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 });
4132
+ 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) });
4133
+ (_b = this.part) === null || _b === void 0 ? void 0 : _b.update({ params: this._params.params });
4214
4134
  }
4215
4135
  toJSON() {
4216
4136
  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 : {};
4137
+ const params = (_b = (_a = this._params) === null || _a === void 0 ? void 0 : _a.params) !== null && _b !== void 0 ? _b : {};
4219
4138
  return {
4220
4139
  id: this.id,
4221
4140
  component: this.component,
4222
4141
  params: Object.keys(params).length > 0 ? params : undefined,
4223
- state: Object.keys(state).length === 0 ? undefined : state,
4224
4142
  };
4225
4143
  }
4226
4144
  dispose() {
4145
+ var _a;
4227
4146
  super.dispose();
4228
4147
  this.api.dispose();
4148
+ (_a = this.part) === null || _a === void 0 ? void 0 : _a.dispose();
4229
4149
  }
4230
4150
  }
4231
4151
 
@@ -4243,12 +4163,12 @@
4243
4163
  this._snap = false;
4244
4164
  this._onDidChange = new Emitter();
4245
4165
  this.onDidChange = this._onDidChange.event;
4246
- this.addDisposables(this.api.onVisibilityChange((event) => {
4166
+ this.addDisposables(this._onDidChange, this.api.onVisibilityChange((event) => {
4247
4167
  const { isVisible } = event;
4248
- const { containerApi } = this.params;
4168
+ const { containerApi } = this._params;
4249
4169
  containerApi.setVisible(this, isVisible);
4250
4170
  }), this.api.onActiveChange(() => {
4251
- const { containerApi } = this.params;
4171
+ const { containerApi } = this._params;
4252
4172
  containerApi.setActive(this);
4253
4173
  }), this.api.onDidConstraintsChangeInternal((event) => {
4254
4174
  if (typeof event.minimumWidth === 'number' ||
@@ -4363,9 +4283,6 @@
4363
4283
  const minimum = (value) => (value <= 0 ? undefined : value);
4364
4284
  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
4285
  }
4366
- dispose() {
4367
- super.dispose();
4368
- }
4369
4286
  }
4370
4287
 
4371
4288
  class GroupviewPanel extends GridviewPanel {
@@ -4472,15 +4389,24 @@
4472
4389
  orientation: options.orientation || exports.Orientation.HORIZONTAL,
4473
4390
  styles: options.styles,
4474
4391
  });
4475
- this._panels = new Map();
4476
- this.dirtyPanels = new Set();
4477
- this.debouncedDeque = debounce(this.syncConfigs.bind(this), 5000);
4478
4392
  // events
4479
4393
  this._onTabInteractionEvent = new Emitter();
4480
4394
  this.onTabInteractionEvent = this._onTabInteractionEvent.event;
4481
4395
  this._onTabContextMenu = new Emitter();
4482
4396
  this.onTabContextMenu = this._onTabContextMenu.event;
4483
- this.panelState = {};
4397
+ this._onDidDrop = new Emitter();
4398
+ this.onDidDrop = this._onDidDrop.event;
4399
+ this._onDidRemovePanel = new Emitter();
4400
+ this.onDidRemovePanel = this._onDidRemovePanel.event;
4401
+ this._onDidAddPanel = new Emitter();
4402
+ this.onDidAddPanel = this._onDidAddPanel.event;
4403
+ this._onDidLayoutfromJSON = new Emitter();
4404
+ this.onDidLayoutfromJSON = this._onDidLayoutfromJSON.event;
4405
+ this._onDidActivePanelChange = new Emitter();
4406
+ this.onDidActivePanelChange = this._onDidActivePanelChange.event;
4407
+ this.addDisposables(this._onTabInteractionEvent, this._onTabContextMenu, this._onDidDrop, exports.Event.any(this.onDidAddPanel, this.onDidRemovePanel, this.onDidActivePanelChange)(() => {
4408
+ this._bufferOnDidLayoutChange.fire();
4409
+ }));
4484
4410
  this._options = options;
4485
4411
  if (!this.options.components) {
4486
4412
  this.options.components = {};
@@ -4501,10 +4427,10 @@
4501
4427
  this._api = new DockviewApi(this);
4502
4428
  }
4503
4429
  get totalPanels() {
4504
- return this._panels.size;
4430
+ return this.panels.length;
4505
4431
  }
4506
4432
  get panels() {
4507
- return Array.from(this._panels.values()).map((_) => _.value);
4433
+ return this.groups.flatMap((group) => group.model.panels);
4508
4434
  }
4509
4435
  get deserializer() {
4510
4436
  return this._deserializer;
@@ -4534,10 +4460,6 @@
4534
4460
  updateOptions(options) {
4535
4461
  const hasOrientationChanged = typeof options.orientation === 'string' &&
4536
4462
  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
4463
  this._options = Object.assign(Object.assign({}, this.options), options);
4542
4464
  if (hasOrientationChanged) {
4543
4465
  this.gridview.orientation = options.orientation;
@@ -4549,8 +4471,7 @@
4549
4471
  (_a = this.activeGroup) === null || _a === void 0 ? void 0 : _a.focus();
4550
4472
  }
4551
4473
  getGroupPanel(id) {
4552
- var _a;
4553
- return (_a = this._panels.get(id)) === null || _a === void 0 ? void 0 : _a.value;
4474
+ return this.panels.find((panel) => panel.id === id);
4554
4475
  }
4555
4476
  setActivePanel(panel) {
4556
4477
  if (!panel.group) {
@@ -4599,24 +4520,6 @@
4599
4520
  this.doSetGroupActive(next);
4600
4521
  }
4601
4522
  }
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
4523
  /**
4621
4524
  * Serialize the current state of the layout
4622
4525
  *
@@ -4624,12 +4527,9 @@
4624
4527
  */
4625
4528
  toJSON() {
4626
4529
  var _a;
4627
- this.syncConfigs();
4628
4530
  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
- }
4531
+ const panels = this.panels.reduce((collection, panel) => {
4532
+ collection[panel.id] = panel.toJSON();
4633
4533
  return collection;
4634
4534
  }, {});
4635
4535
  return {
@@ -4640,13 +4540,12 @@
4640
4540
  };
4641
4541
  }
4642
4542
  fromJSON(data) {
4543
+ const groups = Array.from(this._groups.values()).map((_) => _.value);
4544
+ for (const group of groups) {
4545
+ // remove the group will automatically remove the panels
4546
+ this.removeGroup(group, true);
4547
+ }
4643
4548
  this.gridview.clear();
4644
- this._panels.forEach((panel) => {
4645
- panel.disposable.dispose();
4646
- panel.value.dispose();
4647
- });
4648
- this._panels.clear();
4649
- this._groups.clear();
4650
4549
  if (!this.deserializer) {
4651
4550
  throw new Error('invalid deserializer');
4652
4551
  }
@@ -4660,9 +4559,7 @@
4660
4559
  this.gridview.deserialize(grid, new DefaultDeserializer(this, {
4661
4560
  createPanel: (id) => {
4662
4561
  const panelData = panels[id];
4663
- const panel = this.deserializer.fromJSON(panelData);
4664
- this.registerPanel(panel);
4665
- return panel;
4562
+ return this.deserializer.fromJSON(panelData);
4666
4563
  },
4667
4564
  }));
4668
4565
  if (typeof activeGroup === 'string') {
@@ -4672,36 +4569,31 @@
4672
4569
  }
4673
4570
  }
4674
4571
  this.gridview.layout(this.width, this.height);
4675
- this._onGridEvent.fire({ kind: exports.GroupChangeKind.LAYOUT_FROM_JSON });
4572
+ this._onDidLayoutfromJSON.fire();
4676
4573
  }
4677
4574
  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
- });
4575
+ for (const entry of this._groups.entries()) {
4576
+ const [_, group] = entry;
4577
+ group.value.model.closeAllPanels();
4578
+ }
4688
4579
  }
4689
4580
  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;
4581
+ if (event.kind === exports.MouseEventKind.CONTEXT_MENU) {
4582
+ if (event.tab && event.panel) {
4583
+ this._onTabContextMenu.fire({
4584
+ event: event.event,
4585
+ api: this._api,
4586
+ panel: event.panel,
4587
+ });
4588
+ }
4700
4589
  }
4701
4590
  }
4702
4591
  addPanel(options) {
4703
4592
  var _a, _b;
4704
- const panel = this._addPanel(options);
4593
+ if (this.panels.find((_) => _.id === options.id)) {
4594
+ throw new Error(`panel with id ${options.id} already exists`);
4595
+ }
4596
+ const panel = this.createPanel(options);
4705
4597
  let referenceGroup;
4706
4598
  if ((_a = options.position) === null || _a === void 0 ? void 0 : _a.referencePanel) {
4707
4599
  const referencePanel = this.getGroupPanel(options.position.referencePanel);
@@ -4729,14 +4621,20 @@
4729
4621
  }
4730
4622
  return panel;
4731
4623
  }
4732
- removePanel(panel) {
4733
- this.unregisterPanel(panel);
4624
+ removePanel(panel, options = {
4625
+ removeEmptyGroup: true,
4626
+ skipDispose: false,
4627
+ }) {
4734
4628
  const group = panel.group;
4735
4629
  if (!group) {
4736
4630
  throw new Error(`cannot remove panel ${panel.id}. it's missing a group.`);
4737
4631
  }
4738
4632
  group.model.removePanel(panel);
4739
- if (group.model.size === 0) {
4633
+ panel.dispose();
4634
+ const retainGroupForWatermark = this.size === 1;
4635
+ if (!retainGroupForWatermark &&
4636
+ group.model.size === 0 &&
4637
+ options.removeEmptyGroup) {
4740
4638
  this.removeGroup(group);
4741
4639
  }
4742
4640
  }
@@ -4749,10 +4647,9 @@
4749
4647
  : {}, (_a = this.options.frameworkComponentFactory) === null || _a === void 0 ? void 0 : _a.watermark);
4750
4648
  }
4751
4649
  addEmptyGroup(options) {
4752
- var _a;
4753
4650
  const group = this.createGroup();
4754
4651
  if (options) {
4755
- const referencePanel = (_a = this._panels.get(options.referencePanel)) === null || _a === void 0 ? void 0 : _a.value;
4652
+ const referencePanel = this.panels.find((panel) => panel.id === options.referencePanel);
4756
4653
  if (!referencePanel) {
4757
4654
  throw new Error(`reference panel ${options.referencePanel} does not exist`);
4758
4655
  }
@@ -4769,25 +4666,24 @@
4769
4666
  this.doAddGroup(group);
4770
4667
  }
4771
4668
  }
4772
- removeGroup(group) {
4669
+ removeGroup(group, skipActive = false) {
4773
4670
  const panels = [...group.model.panels]; // reassign since group panels will mutate
4774
- panels.forEach((panel) => {
4775
- this.removePanel(panel);
4776
- });
4777
- if (this._groups.size === 1) {
4778
- this._activeGroup = group;
4779
- return;
4671
+ for (const panel of panels) {
4672
+ this.removePanel(panel, {
4673
+ removeEmptyGroup: false,
4674
+ skipDispose: false,
4675
+ });
4780
4676
  }
4781
- super.removeGroup(group);
4677
+ super.doRemoveGroup(group, { skipActive });
4782
4678
  }
4783
4679
  moveGroupOrPanel(referenceGroup, groupId, itemId, target, index) {
4784
- var _a, _b, _c;
4680
+ var _a;
4785
4681
  const sourceGroup = groupId
4786
4682
  ? (_a = this._groups.get(groupId)) === null || _a === void 0 ? void 0 : _a.value
4787
4683
  : undefined;
4788
4684
  if (!target || target === exports.Position.Center) {
4789
4685
  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);
4686
+ this.panels.find((panel) => panel.id === itemId);
4791
4687
  if (!groupItem) {
4792
4688
  throw new Error(`No panel with id ${itemId}`);
4793
4689
  }
@@ -4823,7 +4719,7 @@
4823
4719
  }
4824
4720
  else {
4825
4721
  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);
4722
+ this.panels.find((panel) => panel.id === itemId);
4827
4723
  if (!groupItem) {
4828
4724
  throw new Error(`No panel with id ${itemId}`);
4829
4725
  }
@@ -4837,10 +4733,7 @@
4837
4733
  const isGroupAlreadyFocused = this._activeGroup === group;
4838
4734
  super.doSetGroupActive(group, skipFocus);
4839
4735
  if (!isGroupAlreadyFocused && ((_a = this._activeGroup) === null || _a === void 0 ? void 0 : _a.model.activePanel)) {
4840
- this._onGridEvent.fire({
4841
- kind: exports.GroupChangeKind.PANEL_ACTIVE,
4842
- panel: (_b = this._activeGroup) === null || _b === void 0 ? void 0 : _b.model.activePanel,
4843
- });
4736
+ this._onDidActivePanelChange.fire((_b = this._activeGroup) === null || _b === void 0 ? void 0 : _b.model.activePanel);
4844
4737
  }
4845
4738
  }
4846
4739
  createGroup(options) {
@@ -4862,35 +4755,27 @@
4862
4755
  }
4863
4756
  }
4864
4757
  const view = new GroupviewPanel(this, id, options);
4758
+ view.init({ params: {}, containerApi: null }); // required to initialized .part and allow for correct disposal of group
4865
4759
  if (!this._groups.has(view.id)) {
4866
4760
  const disposable = new CompositeDisposable(view.model.onMove((event) => {
4867
4761
  const { groupId, itemId, target, index } = event;
4868
4762
  this.moveGroupOrPanel(view, groupId, itemId, target, index);
4763
+ }), view.model.onDidDrop((event) => {
4764
+ this._onDidDrop.fire(Object.assign(Object.assign({}, event), { api: this._api }));
4869
4765
  }), view.model.onDidGroupChange((event) => {
4870
4766
  switch (event.kind) {
4871
4767
  case exports.GroupChangeKind2.ADD_PANEL:
4872
- this._onGridEvent.fire({
4873
- kind: exports.GroupChangeKind.ADD_PANEL,
4874
- panel: event.panel,
4875
- });
4876
- break;
4877
- case exports.GroupChangeKind2.GROUP_ACTIVE:
4878
- this._onGridEvent.fire({
4879
- kind: exports.GroupChangeKind.GROUP_ACTIVE,
4880
- panel: event.panel,
4881
- });
4768
+ if (event.panel) {
4769
+ this._onDidAddPanel.fire(event.panel);
4770
+ }
4882
4771
  break;
4883
4772
  case exports.GroupChangeKind2.REMOVE_PANEL:
4884
- this._onGridEvent.fire({
4885
- kind: exports.GroupChangeKind.REMOVE_PANEL,
4886
- panel: event.panel,
4887
- });
4773
+ if (event.panel) {
4774
+ this._onDidRemovePanel.fire(event.panel);
4775
+ }
4888
4776
  break;
4889
4777
  case exports.GroupChangeKind2.PANEL_ACTIVE:
4890
- this._onGridEvent.fire({
4891
- kind: exports.GroupChangeKind.PANEL_ACTIVE,
4892
- panel: event.panel,
4893
- });
4778
+ this._onDidActivePanelChange.fire(event.panel);
4894
4779
  break;
4895
4780
  }
4896
4781
  }));
@@ -4904,44 +4789,18 @@
4904
4789
  }
4905
4790
  return view;
4906
4791
  }
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
- _addPanel(options) {
4792
+ createPanel(options) {
4933
4793
  const view = new DefaultGroupPanelView({
4934
4794
  content: this.createContentComponent(options.id, options.component),
4935
4795
  tab: this.createTabComponent(options.id, options.tabComponent),
4936
4796
  });
4937
- const panel = new DockviewGroupPanel(options.id, this._api);
4797
+ const panel = new DockviewGroupPanel(options.id, this, this._api);
4938
4798
  panel.init({
4939
4799
  view,
4940
4800
  title: options.title || options.id,
4941
4801
  suppressClosable: options === null || options === void 0 ? void 0 : options.suppressClosable,
4942
4802
  params: (options === null || options === void 0 ? void 0 : options.params) || {},
4943
4803
  });
4944
- this.registerPanel(panel);
4945
4804
  return panel;
4946
4805
  }
4947
4806
  createContentComponent(id, componentName) {
@@ -4961,10 +4820,12 @@
4961
4820
  var _a;
4962
4821
  return (_a = Array.from(this._groups.values()).find((group) => group.value.model.containsPanel(panel))) === null || _a === void 0 ? void 0 : _a.value;
4963
4822
  }
4964
- addDirtyPanel(panel) {
4965
- this.dirtyPanels.add(panel);
4966
- panel.setDirty(true);
4967
- this.debouncedDeque();
4823
+ dispose() {
4824
+ super.dispose();
4825
+ this._onDidActivePanelChange.dispose();
4826
+ this._onDidAddPanel.dispose();
4827
+ this._onDidRemovePanel.dispose();
4828
+ this._onDidLayoutfromJSON.dispose();
4968
4829
  }
4969
4830
  }
4970
4831
 
@@ -4975,6 +4836,8 @@
4975
4836
  orientation: options.orientation,
4976
4837
  styles: options.styles,
4977
4838
  });
4839
+ this._onDidLayoutfromJSON = new Emitter();
4840
+ this.onDidLayoutFromJSON = this._onDidLayoutfromJSON.event;
4978
4841
  this._options = options;
4979
4842
  if (!this.options.components) {
4980
4843
  this.options.components = {};
@@ -5027,7 +4890,7 @@
5027
4890
  this.gridview.setViewVisible(getGridLocation(panel.element), visible);
5028
4891
  }
5029
4892
  setActive(panel) {
5030
- this._groups.forEach((value, key) => {
4893
+ this._groups.forEach((value, _key) => {
5031
4894
  value.value.setActive(panel === value.value);
5032
4895
  });
5033
4896
  }
@@ -5040,8 +4903,12 @@
5040
4903
  }
5041
4904
  fromJSON(serializedGridview, deferComponentLayout) {
5042
4905
  const { grid, activePanel } = serializedGridview;
4906
+ const groups = Array.from(this._groups.values()); // reassign since group panels will mutate
4907
+ for (const group of groups) {
4908
+ group.disposable.dispose();
4909
+ this.doRemoveGroup(group.value, { skipActive: true });
4910
+ }
5043
4911
  this.gridview.clear();
5044
- this._groups.clear();
5045
4912
  const queue = [];
5046
4913
  this.gridview.deserialize(grid, {
5047
4914
  fromJSON: (node) => {
@@ -5082,7 +4949,7 @@
5082
4949
  this.doSetGroupActive(panel);
5083
4950
  }
5084
4951
  }
5085
- this._onGridEvent.fire({ kind: exports.GroupChangeKind.LAYOUT_FROM_JSON });
4952
+ this._onDidLayoutfromJSON.fire();
5086
4953
  }
5087
4954
  movePanel(panel, options) {
5088
4955
  var _a;
@@ -5138,7 +5005,6 @@
5138
5005
  });
5139
5006
  this.registerPanel(view);
5140
5007
  this.doAddGroup(view, relativeLocation, options.size);
5141
- return { api: view.api };
5142
5008
  }
5143
5009
  registerPanel(panel) {
5144
5010
  const disposable = new CompositeDisposable(panel.api.onDidFocusChange((event) => {
@@ -5189,14 +5055,10 @@
5189
5055
  }
5190
5056
  removeGroup(group) {
5191
5057
  super.removeGroup(group);
5192
- const panel = this._groups.get(group.id);
5193
- if (panel) {
5194
- panel.disposable.dispose();
5195
- this._groups.delete(group.id);
5196
- }
5197
5058
  }
5198
5059
  dispose() {
5199
5060
  super.dispose();
5061
+ this._onDidLayoutfromJSON.dispose();
5200
5062
  }
5201
5063
  }
5202
5064
 
@@ -5223,7 +5085,7 @@
5223
5085
  options.frameworkComponents = {};
5224
5086
  }
5225
5087
  this.splitview = new Splitview(this.element, options);
5226
- this.addDisposables(this._disposable);
5088
+ this.addDisposables(this._disposable, this._onDidAddView, this._onDidRemoveView, this._onDidLayoutChange);
5227
5089
  }
5228
5090
  get options() {
5229
5091
  return this._options;
@@ -5299,7 +5161,11 @@
5299
5161
  }
5300
5162
  removePanel(panel, sizing) {
5301
5163
  const disposable = this.panels.get(panel.id);
5302
- disposable === null || disposable === void 0 ? void 0 : disposable.dispose();
5164
+ if (!disposable) {
5165
+ throw new Error(`unknown splitview panel ${panel.id}`);
5166
+ }
5167
+ disposable.disposable.dispose();
5168
+ disposable.value.dispose();
5303
5169
  this.panels.delete(panel.id);
5304
5170
  const index = this.getPanels().findIndex((_) => _ === panel);
5305
5171
  this.splitview.removeView(index, sizing);
@@ -5358,7 +5224,7 @@
5358
5224
  }
5359
5225
  this.setActive(view, true);
5360
5226
  });
5361
- this.panels.set(view.id, disposable);
5227
+ this.panels.set(view.id, { disposable, value: view });
5362
5228
  }
5363
5229
  toJSON() {
5364
5230
  var _a;
@@ -5382,6 +5248,11 @@
5382
5248
  }
5383
5249
  fromJSON(serializedSplitview, deferComponentLayout = false) {
5384
5250
  const { views, orientation, size, activeView } = serializedSplitview;
5251
+ for (const [_, value] of this.panels.entries()) {
5252
+ value.disposable.dispose();
5253
+ value.value.dispose();
5254
+ }
5255
+ this.panels.clear();
5385
5256
  this.splitview.dispose();
5386
5257
  const queue = [];
5387
5258
  this.splitview = new Splitview(this.element, {
@@ -5437,49 +5308,16 @@
5437
5308
  }
5438
5309
  }
5439
5310
  dispose() {
5440
- Array.from(this.panels.values()).forEach((value) => {
5441
- value.dispose();
5442
- });
5311
+ for (const [_, value] of this.panels.entries()) {
5312
+ value.disposable.dispose();
5313
+ value.value.dispose();
5314
+ }
5443
5315
  this.panels.clear();
5316
+ this.splitview.dispose();
5444
5317
  super.dispose();
5445
5318
  }
5446
5319
  }
5447
5320
 
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
5321
  class SplitviewPanelApiImpl extends PanelApiImpl {
5484
5322
  //
5485
5323
  constructor(id) {
@@ -5494,6 +5332,7 @@
5494
5332
  //
5495
5333
  this._onDidSizeChange = new Emitter();
5496
5334
  this.onDidSizeChange = this._onDidSizeChange.event;
5335
+ this.addDisposables(this._onDidConstraintsChangeInternal, this._onDidConstraintsChange, this._onDidSizeChange);
5497
5336
  }
5498
5337
  setConstraints(value) {
5499
5338
  this._onDidConstraintsChangeInternal.fire(value);
@@ -5501,11 +5340,6 @@
5501
5340
  setSize(event) {
5502
5341
  this._onDidSizeChange.fire(event);
5503
5342
  }
5504
- dispose() {
5505
- super.dispose();
5506
- this._onDidConstraintsChange.dispose();
5507
- this._onDidSizeChange.dispose();
5508
- }
5509
5343
  }
5510
5344
 
5511
5345
  class PaneviewPanelApiImpl extends SplitviewPanelApiImpl {
@@ -5519,6 +5353,7 @@
5519
5353
  this.onMouseEnter = this._onMouseEnter.event;
5520
5354
  this._onMouseLeave = new Emitter({});
5521
5355
  this.onMouseLeave = this._onMouseLeave.event;
5356
+ this.addDisposables(this._onDidExpansionChange, this._onMouseEnter, this._onMouseLeave);
5522
5357
  }
5523
5358
  set pane(pane) {
5524
5359
  this._pane = pane;
@@ -5687,7 +5522,7 @@
5687
5522
  }
5688
5523
  }
5689
5524
  toJSON() {
5690
- const params = this.params;
5525
+ const params = this._params;
5691
5526
  return Object.assign(Object.assign({}, super.toJSON()), { headerComponent: this.headerComponent, title: params.title });
5692
5527
  }
5693
5528
  renderOnce() {
@@ -5747,7 +5582,7 @@
5747
5582
  })(this.header);
5748
5583
  this.target = new Droptarget(this.element, {
5749
5584
  validOverlays: 'vertical',
5750
- canDisplayOverlay: (event) => {
5585
+ canDisplayOverlay: () => {
5751
5586
  const data = getPaneData();
5752
5587
  if (!data) {
5753
5588
  return true;
@@ -5756,36 +5591,39 @@
5756
5591
  },
5757
5592
  });
5758
5593
  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);
5594
+ this.onDrop(event);
5787
5595
  }));
5788
5596
  }
5597
+ onDrop(event) {
5598
+ const data = getPaneData();
5599
+ if (!data) {
5600
+ this._onDidDrop.fire(Object.assign(Object.assign({}, event), { panel: this, getData: () => getPaneData() }));
5601
+ return;
5602
+ }
5603
+ const containerApi = this._params
5604
+ .containerApi;
5605
+ const panelId = data.paneId;
5606
+ const existingPanel = containerApi.getPanel(panelId);
5607
+ if (!existingPanel) {
5608
+ this._onDidDrop.fire(Object.assign(Object.assign({}, event), { panel: this, getData: () => getPaneData() }));
5609
+ return;
5610
+ }
5611
+ const allPanels = containerApi.getPanels();
5612
+ const fromIndex = allPanels.indexOf(existingPanel);
5613
+ let toIndex = containerApi.getPanels().indexOf(this);
5614
+ if (event.position === exports.Position.Left ||
5615
+ event.position === exports.Position.Top) {
5616
+ toIndex = Math.max(0, toIndex - 1);
5617
+ }
5618
+ if (event.position === exports.Position.Right ||
5619
+ event.position === exports.Position.Bottom) {
5620
+ if (fromIndex > toIndex) {
5621
+ toIndex++;
5622
+ }
5623
+ toIndex = Math.min(allPanels.length - 1, toIndex);
5624
+ }
5625
+ containerApi.movePanel(fromIndex, toIndex);
5626
+ }
5789
5627
  }
5790
5628
 
5791
5629
  class DefaultHeader extends CompositeDisposable {
@@ -5815,7 +5653,7 @@
5815
5653
  this._expander.textContent = e.isExpanded ? '<' : '>';
5816
5654
  });
5817
5655
  }
5818
- update(params) {
5656
+ update(_params) {
5819
5657
  //
5820
5658
  }
5821
5659
  dispose() {
@@ -5841,6 +5679,7 @@
5841
5679
  super();
5842
5680
  this.element = element;
5843
5681
  this._disposable = new MutableDisposable();
5682
+ this._viewDisposables = new Map();
5844
5683
  this._onDidLayoutChange = new Emitter();
5845
5684
  this.onDidLayoutChange = this._onDidLayoutChange.event;
5846
5685
  this._onDidDrop = new Emitter();
@@ -5849,6 +5688,7 @@
5849
5688
  this.onDidAddView = this._onDidAddView.event;
5850
5689
  this._onDidRemoveView = new Emitter();
5851
5690
  this.onDidRemoveView = this._onDidRemoveView.event;
5691
+ this.addDisposables(this._onDidLayoutChange, this._onDidDrop, this._onDidAddView, this._onDidRemoveView);
5852
5692
  this._options = options;
5853
5693
  if (!options.components) {
5854
5694
  options.components = {};
@@ -5924,9 +5764,7 @@
5924
5764
  isExpanded: !!options.isExpanded,
5925
5765
  disableDnd: !!this.options.disableDnd,
5926
5766
  });
5927
- const disposable = new CompositeDisposable(view.onDidDrop((event) => {
5928
- this._onDidDrop.fire(event);
5929
- }));
5767
+ this.doAddPanel(view);
5930
5768
  const size = typeof options.size === 'number' ? options.size : exports.Sizing.Distribute;
5931
5769
  const index = typeof options.index === 'number' ? options.index : undefined;
5932
5770
  view.init({
@@ -5939,7 +5777,7 @@
5939
5777
  });
5940
5778
  this.paneview.addPane(view, size, index);
5941
5779
  view.orientation = this.paneview.orientation;
5942
- return disposable;
5780
+ return view;
5943
5781
  }
5944
5782
  getPanels() {
5945
5783
  return this.paneview.getPanes();
@@ -5948,6 +5786,7 @@
5948
5786
  const views = this.getPanels();
5949
5787
  const index = views.findIndex((_) => _ === panel);
5950
5788
  this.paneview.removePane(index);
5789
+ this.doRemovePanel(panel);
5951
5790
  }
5952
5791
  movePanel(from, to) {
5953
5792
  this.paneview.moveView(from, to);
@@ -5997,6 +5836,10 @@
5997
5836
  fromJSON(serializedPaneview, deferComponentLayout) {
5998
5837
  const { views, size } = serializedPaneview;
5999
5838
  const queue = [];
5839
+ for (const [_, value] of this._viewDisposables.entries()) {
5840
+ value.dispose();
5841
+ }
5842
+ this._viewDisposables.clear();
6000
5843
  this.paneview.dispose();
6001
5844
  this.paneview = new Paneview(this.element, {
6002
5845
  orientation: exports.Orientation.VERTICAL,
@@ -6032,9 +5875,7 @@
6032
5875
  isExpanded: !!view.expanded,
6033
5876
  disableDnd: !!this.options.disableDnd,
6034
5877
  });
6035
- panel.onDidDrop((event) => {
6036
- this._onDidDrop.fire(event);
6037
- });
5878
+ this.doAddPanel(panel);
6038
5879
  queue.push(() => {
6039
5880
  panel.init({
6040
5881
  params: data.params || {},
@@ -6064,6 +5905,27 @@
6064
5905
  queue.forEach((f) => f());
6065
5906
  }
6066
5907
  }
5908
+ doAddPanel(panel) {
5909
+ const disposable = panel.onDidDrop((event) => {
5910
+ this._onDidDrop.fire(event);
5911
+ });
5912
+ this._viewDisposables.set(panel.id, disposable);
5913
+ }
5914
+ doRemovePanel(panel) {
5915
+ const disposable = this._viewDisposables.get(panel.id);
5916
+ if (disposable) {
5917
+ disposable.dispose();
5918
+ this._viewDisposables.delete(panel.id);
5919
+ }
5920
+ }
5921
+ dispose() {
5922
+ super.dispose();
5923
+ for (const [_, value] of this._viewDisposables.entries()) {
5924
+ value.dispose();
5925
+ }
5926
+ this._viewDisposables.clear();
5927
+ this.paneview.dispose();
5928
+ }
6067
5929
  }
6068
5930
 
6069
5931
  class SplitviewPanel extends BasePanelView {
@@ -6076,12 +5938,14 @@
6076
5938
  this._snap = false;
6077
5939
  this._onDidChange = new Emitter();
6078
5940
  this.onDidChange = this._onDidChange.event;
6079
- this.addDisposables(this.api.onVisibilityChange((event) => {
5941
+ this.addDisposables(this._onDidChange, this.api.onVisibilityChange((event) => {
6080
5942
  const { isVisible } = event;
6081
- const { containerApi } = this.params;
5943
+ const { containerApi } = this
5944
+ ._params;
6082
5945
  containerApi.setVisible(this, isVisible);
6083
5946
  }), this.api.onActiveChange(() => {
6084
- const { containerApi } = this.params;
5947
+ const { containerApi } = this
5948
+ ._params;
6085
5949
  containerApi.setActive(this);
6086
5950
  }), this.api.onDidConstraintsChangeInternal((event) => {
6087
5951
  if (typeof event.minimumSize === 'number' ||
@@ -6224,14 +6088,13 @@
6224
6088
  if (this.disposed) {
6225
6089
  throw new Error('invalid operation: resource is already disposed');
6226
6090
  }
6227
- // TODO use a better check for isReactFunctionalComponent
6228
6091
  if (typeof this.component !== 'function') {
6229
6092
  /**
6230
6093
  * we know this isn't a React.FunctionComponent so throw an error here.
6231
6094
  * if we do not intercept this the React library will throw a very obsure error
6232
6095
  * for the same reason, at least at this point we will emit a sensible stacktrace.
6233
6096
  */
6234
- throw new Error('invalid operation: only functional components are supported');
6097
+ throw new Error('Invalid Operation. dockview only supports React Functional Components.');
6235
6098
  }
6236
6099
  const bridgeComponent = React__namespace.createElement(React__namespace.forwardRef(ReactComponentBridge), {
6237
6100
  component: this
@@ -6289,22 +6152,14 @@
6289
6152
  this.id = id;
6290
6153
  this.component = component;
6291
6154
  this.reactPortalStore = reactPortalStore;
6292
- // private hostedContainer: HostedContainer;
6293
6155
  this._onDidFocus = new Emitter();
6294
6156
  this.onDidFocus = this._onDidFocus.event;
6295
6157
  this._onDidBlur = new Emitter();
6296
6158
  this.onDidBlur = this._onDidBlur.event;
6297
6159
  this._element = document.createElement('div');
6298
- this._element.style.height = '100%';
6299
- this._element.style.width = '100%';
6300
- // this.hostedContainer = new HostedContainer({
6301
- // id,
6302
- // });
6303
- // this.hostedContainer.onDidFocus(() => this._onDidFocus.fire());
6304
- // this.hostedContainer.onDidBlur(() => this._onDidBlur.fire());
6160
+ this._element.className = 'dockview-react-part';
6305
6161
  this._actionsElement = document.createElement('div');
6306
- this._actionsElement.style.height = '100%';
6307
- this._actionsElement.style.width = '100%';
6162
+ this._actionsElement.className = 'dockview-react-part';
6308
6163
  }
6309
6164
  get element() {
6310
6165
  return this._element;
@@ -6337,23 +6192,20 @@
6337
6192
  var _a;
6338
6193
  (_a = this.part) === null || _a === void 0 ? void 0 : _a.update(event.params);
6339
6194
  }
6340
- updateParentGroup(group, isPanelVisible) {
6195
+ updateParentGroup(group, _isPanelVisible) {
6341
6196
  this._group = group;
6342
6197
  }
6343
- layout(width, height) {
6198
+ layout(_width, _height) {
6344
6199
  // noop
6345
- // this.hostedContainer.layout(
6346
- // this.element
6347
- // // { width, height }
6348
- // );
6349
6200
  }
6350
6201
  close() {
6351
6202
  return Promise.resolve(true);
6352
6203
  }
6353
6204
  dispose() {
6354
6205
  var _a, _b;
6206
+ this._onDidFocus.dispose();
6207
+ this._onDidBlur.dispose();
6355
6208
  (_a = this.part) === null || _a === void 0 ? void 0 : _a.dispose();
6356
- // this.hostedContainer?.dispose();
6357
6209
  (_b = this.actionsPart) === null || _b === void 0 ? void 0 : _b.dispose();
6358
6210
  }
6359
6211
  }
@@ -6364,6 +6216,7 @@
6364
6216
  this.component = component;
6365
6217
  this.reactPortalStore = reactPortalStore;
6366
6218
  this._element = document.createElement('div');
6219
+ this._element.className = 'dockview-react-part';
6367
6220
  }
6368
6221
  get element() {
6369
6222
  return this._element;
@@ -6387,10 +6240,10 @@
6387
6240
  id: this.id,
6388
6241
  };
6389
6242
  }
6390
- layout(width, height) {
6243
+ layout(_width, _height) {
6391
6244
  // noop - retrieval from api
6392
6245
  }
6393
- updateParentGroup(group, isPanelVisible) {
6246
+ updateParentGroup(_group, _isPanelVisible) {
6394
6247
  // noop - retrieval from api
6395
6248
  }
6396
6249
  dispose() {
@@ -6408,7 +6261,6 @@
6408
6261
  const panelId = panelData.id;
6409
6262
  const params = panelData.params;
6410
6263
  const title = panelData.title;
6411
- const state = panelData.state;
6412
6264
  const suppressClosable = panelData.suppressClosable;
6413
6265
  const viewData = panelData.view;
6414
6266
  const view = new DefaultGroupPanelView({
@@ -6417,13 +6269,12 @@
6417
6269
  ? 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
6270
  : new DefaultTab(),
6419
6271
  });
6420
- const panel = new DockviewGroupPanel(panelId, new DockviewApi(this.layout));
6272
+ const panel = new DockviewGroupPanel(panelId, this.layout, new DockviewApi(this.layout));
6421
6273
  panel.init({
6422
6274
  view,
6423
6275
  title,
6424
6276
  suppressClosable,
6425
6277
  params: params || {},
6426
- state: state || {},
6427
6278
  });
6428
6279
  return panel;
6429
6280
  }
@@ -6438,8 +6289,7 @@
6438
6289
  value: undefined,
6439
6290
  };
6440
6291
  this._element = document.createElement('div');
6441
- this._element.style.height = '100%';
6442
- this._element.style.width = '100%';
6292
+ this._element.className = 'dockview-react-part';
6443
6293
  }
6444
6294
  get element() {
6445
6295
  return this._element;
@@ -6472,10 +6322,10 @@
6472
6322
  id: this.id,
6473
6323
  };
6474
6324
  }
6475
- layout(width, height) {
6325
+ layout(_width, _height) {
6476
6326
  // noop - retrieval from api
6477
6327
  }
6478
- updateParentGroup(group, isPanelVisible) {
6328
+ updateParentGroup(group, _isPanelVisible) {
6479
6329
  // noop - retrieval from api
6480
6330
  this._groupRef.value = group;
6481
6331
  }
@@ -6509,21 +6359,21 @@
6509
6359
  var _a;
6510
6360
  const factory = {
6511
6361
  content: {
6512
- createComponent: (id, componentId, component) => {
6362
+ createComponent: (_id, componentId, component) => {
6513
6363
  return new ReactPanelContentPart(componentId, component, {
6514
6364
  addPortal,
6515
6365
  });
6516
6366
  },
6517
6367
  },
6518
6368
  tab: {
6519
- createComponent: (id, componentId, component) => {
6369
+ createComponent: (_id, componentId, component) => {
6520
6370
  return new ReactPanelHeaderPart(componentId, component, {
6521
6371
  addPortal,
6522
6372
  });
6523
6373
  },
6524
6374
  },
6525
6375
  watermark: {
6526
- createComponent: (id, componentId, component) => {
6376
+ createComponent: (_id, componentId, component) => {
6527
6377
  return new ReactWatermarkPart(componentId, component, {
6528
6378
  addPortal,
6529
6379
  });
@@ -6537,7 +6387,6 @@
6537
6387
  frameworkTabComponents: props.tabComponents,
6538
6388
  tabHeight: props.tabHeight,
6539
6389
  debug: props.debug,
6540
- enableExternalDragEvents: props.enableExternalDragEvents,
6541
6390
  watermarkFrameworkComponent: props.watermarkComponent,
6542
6391
  styles: props.hideBorders
6543
6392
  ? { separatorBorder: 'transparent' }
@@ -6553,8 +6402,24 @@
6553
6402
  dockviewRef.current = dockview;
6554
6403
  return () => {
6555
6404
  dockview.dispose();
6405
+ element.remove();
6556
6406
  };
6557
6407
  }, []);
6408
+ React__namespace.useEffect(() => {
6409
+ if (!dockviewRef.current) {
6410
+ return () => {
6411
+ // noop
6412
+ };
6413
+ }
6414
+ const disposable = dockviewRef.current.onDidDrop((event) => {
6415
+ if (props.onDidDrop) {
6416
+ props.onDidDrop(event);
6417
+ }
6418
+ });
6419
+ return () => {
6420
+ disposable.dispose();
6421
+ };
6422
+ }, [props.onDidDrop]);
6558
6423
  React__namespace.useEffect(() => {
6559
6424
  if (!dockviewRef.current) {
6560
6425
  return;
@@ -6563,6 +6428,22 @@
6563
6428
  frameworkComponents: props.components,
6564
6429
  });
6565
6430
  }, [props.components]);
6431
+ React__namespace.useEffect(() => {
6432
+ if (!dockviewRef.current) {
6433
+ return;
6434
+ }
6435
+ dockviewRef.current.updateOptions({
6436
+ watermarkFrameworkComponent: props.watermarkComponent,
6437
+ });
6438
+ }, [props.watermarkComponent]);
6439
+ React__namespace.useEffect(() => {
6440
+ if (!dockviewRef.current) {
6441
+ return;
6442
+ }
6443
+ dockviewRef.current.updateOptions({
6444
+ showDndOverlay: props.showDndOverlay,
6445
+ });
6446
+ }, [props.showDndOverlay]);
6566
6447
  React__namespace.useEffect(() => {
6567
6448
  if (!dockviewRef.current) {
6568
6449
  return;
@@ -6651,9 +6532,9 @@
6651
6532
  getComponent() {
6652
6533
  var _a;
6653
6534
  return new ReactPart(this.element, this.reactPortalStore, this.reactComponent, {
6654
- params: ((_a = this.params) === null || _a === void 0 ? void 0 : _a.params) || {},
6535
+ params: ((_a = this._params) === null || _a === void 0 ? void 0 : _a.params) || {},
6655
6536
  api: this.api,
6656
- containerApi: this.params
6537
+ containerApi: this._params
6657
6538
  .containerApi,
6658
6539
  });
6659
6540
  }
@@ -6690,7 +6571,9 @@
6690
6571
  });
6691
6572
  },
6692
6573
  },
6693
- proportionalLayout: props.proportionalLayout,
6574
+ proportionalLayout: typeof props.proportionalLayout === 'boolean'
6575
+ ? props.proportionalLayout
6576
+ : true,
6694
6577
  styles: props.hideBorders
6695
6578
  ? { separatorBorder: 'transparent' }
6696
6579
  : undefined,
@@ -6726,9 +6609,9 @@
6726
6609
  getComponent() {
6727
6610
  var _a;
6728
6611
  return new ReactPart(this.element, this.reactPortalStore, this.reactComponent, {
6729
- params: ((_a = this.params) === null || _a === void 0 ? void 0 : _a.params) || {},
6612
+ params: ((_a = this._params) === null || _a === void 0 ? void 0 : _a.params) || {},
6730
6613
  api: this.api,
6731
- containerApi: this.params
6614
+ containerApi: this._params
6732
6615
  .containerApi,
6733
6616
  });
6734
6617
  }
@@ -6758,7 +6641,9 @@
6758
6641
  var _a;
6759
6642
  const element = document.createElement('div');
6760
6643
  const gridview = new GridviewComponent(element, {
6761
- proportionalLayout: !!props.proportionalLayout,
6644
+ proportionalLayout: typeof props.proportionalLayout === 'boolean'
6645
+ ? props.proportionalLayout
6646
+ : true,
6762
6647
  orientation: props.orientation,
6763
6648
  frameworkComponents: props.components,
6764
6649
  frameworkComponentFactory: {
@@ -6781,6 +6666,7 @@
6781
6666
  gridviewRef.current = gridview;
6782
6667
  return () => {
6783
6668
  gridview.dispose();
6669
+ element.remove();
6784
6670
  };
6785
6671
  }, []);
6786
6672
  React__namespace.useEffect(() => {
@@ -6851,7 +6737,7 @@
6851
6737
  };
6852
6738
  }, [props.disableAutoResizing]);
6853
6739
  React__namespace.useEffect(() => {
6854
- const createComponent = (id, componentId, component) => new PanePanelSection(id, component, {
6740
+ const createComponent = (id, _componentId, component) => new PanePanelSection(id, component, {
6855
6741
  addPortal,
6856
6742
  });
6857
6743
  const paneview = new PaneviewComponent(domRef.current, {
@@ -6917,14 +6803,11 @@
6917
6803
  PaneviewReact.displayName = 'PaneviewComponent';
6918
6804
 
6919
6805
  exports.BaseGrid = BaseGrid;
6920
- exports.CompositeDisposable = CompositeDisposable;
6921
6806
  exports.ContentContainer = ContentContainer;
6922
- exports.DATA_KEY = DATA_KEY;
6923
6807
  exports.DockviewApi = DockviewApi;
6924
6808
  exports.DockviewComponent = DockviewComponent;
6925
6809
  exports.DockviewComponents = DockviewComponents;
6926
6810
  exports.DockviewReact = DockviewReact;
6927
- exports.Emitter = Emitter;
6928
6811
  exports.Gridview = Gridview;
6929
6812
  exports.GridviewApi = GridviewApi;
6930
6813
  exports.GridviewComponent = GridviewComponent;
@@ -6932,7 +6815,6 @@
6932
6815
  exports.GridviewReact = GridviewReact;
6933
6816
  exports.Groupview = Groupview;
6934
6817
  exports.LocalSelectionTransfer = LocalSelectionTransfer;
6935
- exports.MutableDisposable = MutableDisposable;
6936
6818
  exports.PaneFramework = PaneFramework;
6937
6819
  exports.PaneTransfer = PaneTransfer;
6938
6820
  exports.PanelTransfer = PanelTransfer;
@@ -6951,10 +6833,6 @@
6951
6833
  exports.SplitviewPanel = SplitviewPanel;
6952
6834
  exports.SplitviewReact = SplitviewReact;
6953
6835
  exports.Tab = Tab$1;
6954
- exports.TickDelayedEvent = TickDelayedEvent;
6955
- exports.addDisposableListener = addDisposableListener;
6956
- exports.addDisposableWindowListener = addDisposableWindowListener;
6957
- exports.extractData = extractData;
6958
6836
  exports.getDirectionOrientation = getDirectionOrientation;
6959
6837
  exports.getGridLocation = getGridLocation;
6960
6838
  exports.getLocationOrientation = getLocationOrientation;
@@ -6962,11 +6840,8 @@
6962
6840
  exports.getPanelData = getPanelData;
6963
6841
  exports.getRelativeLocation = getRelativeLocation;
6964
6842
  exports.indexInParent = indexInParent;
6965
- exports.isCustomDragEvent = isCustomDragEvent;
6966
6843
  exports.isGridBranchNode = isGridBranchNode;
6967
- exports.isPanelTransferEvent = isPanelTransferEvent;
6968
6844
  exports.isReactElement = isReactElement;
6969
- exports.isTabDragEvent = isTabDragEvent;
6970
6845
  exports.orthogonal = orthogonal;
6971
6846
  exports.toTarget = toTarget;
6972
6847
  exports.usePortalsLifecycle = usePortalsLifecycle;