dockview 1.0.2 → 1.2.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 (229) hide show
  1. package/README.md +243 -186
  2. package/dist/cjs/api/component.api.d.ts +32 -23
  3. package/dist/cjs/api/component.api.js +105 -34
  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 +14 -14
  20. package/dist/cjs/dnd/abstractDragHandler.js.map +1 -1
  21. package/dist/cjs/dnd/dataTransfer.d.ts +0 -25
  22. package/dist/cjs/dnd/dataTransfer.js +1 -45
  23. package/dist/cjs/dnd/dataTransfer.js.map +1 -1
  24. package/dist/cjs/dnd/dnd.d.ts +1 -14
  25. package/dist/cjs/dnd/dnd.js +1 -79
  26. package/dist/cjs/dnd/dnd.js.map +1 -1
  27. package/dist/cjs/dnd/droptarget.d.ts +3 -0
  28. package/dist/cjs/dnd/droptarget.js +69 -45
  29. package/dist/cjs/dnd/droptarget.js.map +1 -1
  30. package/dist/cjs/dockview/components/tab/defaultTab.d.ts +0 -1
  31. package/dist/cjs/dockview/components/tab/defaultTab.js +0 -8
  32. package/dist/cjs/dockview/components/tab/defaultTab.js.map +1 -1
  33. package/dist/cjs/dockview/deserializer.js.map +1 -1
  34. package/dist/cjs/dockview/dockviewComponent.d.ts +31 -21
  35. package/dist/cjs/dockview/dockviewComponent.js +103 -207
  36. package/dist/cjs/dockview/dockviewComponent.js.map +1 -1
  37. package/dist/cjs/dockview/dockviewGroupPanel.d.ts +3 -5
  38. package/dist/cjs/dockview/dockviewGroupPanel.js +10 -31
  39. package/dist/cjs/dockview/dockviewGroupPanel.js.map +1 -1
  40. package/dist/cjs/dockview/options.d.ts +2 -1
  41. package/dist/cjs/events.js +25 -4
  42. package/dist/cjs/events.js.map +1 -1
  43. package/dist/cjs/gridview/baseComponentGridview.d.ts +12 -20
  44. package/dist/cjs/gridview/baseComponentGridview.js +23 -45
  45. package/dist/cjs/gridview/baseComponentGridview.js.map +1 -1
  46. package/dist/cjs/gridview/basePanelView.d.ts +5 -8
  47. package/dist/cjs/gridview/basePanelView.js +14 -8
  48. package/dist/cjs/gridview/basePanelView.js.map +1 -1
  49. package/dist/cjs/gridview/branchNode.js +2 -2
  50. package/dist/cjs/gridview/branchNode.js.map +1 -1
  51. package/dist/cjs/gridview/gridview.js +20 -17
  52. package/dist/cjs/gridview/gridview.js.map +1 -1
  53. package/dist/cjs/gridview/gridviewComponent.d.ts +4 -0
  54. package/dist/cjs/gridview/gridviewComponent.js +5 -1
  55. package/dist/cjs/gridview/gridviewComponent.js.map +1 -1
  56. package/dist/cjs/gridview/gridviewPanel.d.ts +0 -1
  57. package/dist/cjs/gridview/gridviewPanel.js +3 -6
  58. package/dist/cjs/gridview/gridviewPanel.js.map +1 -1
  59. package/dist/cjs/gridview/leafNode.js +2 -1
  60. package/dist/cjs/gridview/leafNode.js.map +1 -1
  61. package/dist/cjs/groupview/groupPanel.d.ts +1 -7
  62. package/dist/cjs/groupview/groupview.d.ts +15 -8
  63. package/dist/cjs/groupview/groupview.js +36 -123
  64. package/dist/cjs/groupview/groupview.js.map +1 -1
  65. package/dist/cjs/groupview/groupviewPanel.d.ts +5 -2
  66. package/dist/cjs/groupview/groupviewPanel.js.map +1 -1
  67. package/dist/cjs/groupview/panel/content.js +1 -0
  68. package/dist/cjs/groupview/panel/content.js.map +1 -1
  69. package/dist/cjs/groupview/tab.d.ts +10 -13
  70. package/dist/cjs/groupview/tab.js +22 -80
  71. package/dist/cjs/groupview/tab.js.map +1 -1
  72. package/dist/cjs/groupview/titlebar/tabsContainer.js +4 -6
  73. package/dist/cjs/groupview/titlebar/tabsContainer.js.map +1 -1
  74. package/dist/cjs/index.d.ts +3 -3
  75. package/dist/cjs/index.js +8 -4
  76. package/dist/cjs/index.js.map +1 -1
  77. package/dist/cjs/lifecycle.js +2 -1
  78. package/dist/cjs/lifecycle.js.map +1 -1
  79. package/dist/cjs/panel/types.d.ts +0 -2
  80. package/dist/cjs/paneview/draggablePaneviewPanel.d.ts +2 -2
  81. package/dist/cjs/paneview/draggablePaneviewPanel.js +32 -29
  82. package/dist/cjs/paneview/draggablePaneviewPanel.js.map +1 -1
  83. package/dist/cjs/paneview/paneview.js +4 -3
  84. package/dist/cjs/paneview/paneview.js.map +1 -1
  85. package/dist/cjs/paneview/paneviewComponent.d.ts +5 -5
  86. package/dist/cjs/paneview/paneviewComponent.js +15 -16
  87. package/dist/cjs/paneview/paneviewComponent.js.map +1 -1
  88. package/dist/cjs/paneview/paneviewPanel.d.ts +5 -1
  89. package/dist/cjs/paneview/paneviewPanel.js +14 -2
  90. package/dist/cjs/paneview/paneviewPanel.js.map +1 -1
  91. package/dist/cjs/react/deserializer.js +1 -3
  92. package/dist/cjs/react/deserializer.js.map +1 -1
  93. package/dist/cjs/react/dockview/components.js +5 -1
  94. package/dist/cjs/react/dockview/components.js.map +1 -1
  95. package/dist/cjs/react/dockview/dockview.d.ts +9 -9
  96. package/dist/cjs/react/dockview/dockview.js +28 -2
  97. package/dist/cjs/react/dockview/dockview.js.map +1 -1
  98. package/dist/cjs/react/dockview/reactContentPart.js +4 -4
  99. package/dist/cjs/react/dockview/reactContentPart.js.map +1 -1
  100. package/dist/cjs/react/dockview/reactHeaderPart.js +1 -0
  101. package/dist/cjs/react/dockview/reactHeaderPart.js.map +1 -1
  102. package/dist/cjs/react/dockview/reactWatermarkPart.d.ts +1 -2
  103. package/dist/cjs/react/dockview/reactWatermarkPart.js +1 -2
  104. package/dist/cjs/react/dockview/reactWatermarkPart.js.map +1 -1
  105. package/dist/cjs/react/gridview/gridview.js +9 -2
  106. package/dist/cjs/react/gridview/gridview.js.map +1 -1
  107. package/dist/cjs/react/gridview/view.js +2 -2
  108. package/dist/cjs/react/gridview/view.js.map +1 -1
  109. package/dist/cjs/react/index.d.ts +1 -0
  110. package/dist/cjs/react/index.js +5 -1
  111. package/dist/cjs/react/index.js.map +1 -1
  112. package/dist/cjs/react/paneview/paneview.js +5 -1
  113. package/dist/cjs/react/paneview/paneview.js.map +1 -1
  114. package/dist/cjs/react/react.js +6 -3
  115. package/dist/cjs/react/react.js.map +1 -1
  116. package/dist/cjs/react/splitview/splitview.js +8 -2
  117. package/dist/cjs/react/splitview/splitview.js.map +1 -1
  118. package/dist/cjs/react/splitview/view.js +2 -2
  119. package/dist/cjs/react/splitview/view.js.map +1 -1
  120. package/dist/cjs/splitview/core/splitview.js +2 -2
  121. package/dist/cjs/splitview/core/splitview.js.map +1 -1
  122. package/dist/cjs/splitview/splitviewComponent.d.ts +9 -6
  123. package/dist/cjs/splitview/splitviewComponent.js +12 -1
  124. package/dist/cjs/splitview/splitviewComponent.js.map +1 -1
  125. package/dist/cjs/splitview/splitviewPanel.d.ts +1 -6
  126. package/dist/cjs/splitview/splitviewPanel.js +5 -3
  127. package/dist/cjs/splitview/splitviewPanel.js.map +1 -1
  128. package/dist/dockview.amd.js +592 -745
  129. package/dist/dockview.amd.min.js +2 -16
  130. package/dist/dockview.amd.min.noStyle.js +2 -16
  131. package/dist/dockview.amd.noStyle.js +591 -744
  132. package/dist/dockview.cjs.js +592 -745
  133. package/dist/dockview.esm.js +592 -734
  134. package/dist/dockview.esm.min.js +2 -16
  135. package/dist/dockview.js +592 -745
  136. package/dist/dockview.min.js +2 -16
  137. package/dist/dockview.min.noStyle.js +2 -16
  138. package/dist/dockview.noStyle.js +591 -744
  139. package/dist/esm/api/component.api.d.ts +32 -23
  140. package/dist/esm/api/component.api.js +51 -24
  141. package/dist/esm/api/gridviewPanelApi.js +1 -0
  142. package/dist/esm/api/groupPanelApi.d.ts +11 -14
  143. package/dist/esm/api/groupPanelApi.js +18 -13
  144. package/dist/esm/api/panelApi.d.ts +0 -25
  145. package/dist/esm/api/panelApi.js +1 -20
  146. package/dist/esm/api/paneviewPanelApi.js +1 -0
  147. package/dist/esm/api/splitviewPanelApi.d.ts +0 -1
  148. package/dist/esm/api/splitviewPanelApi.js +1 -5
  149. package/dist/esm/dnd/abstractDragHandler.d.ts +2 -2
  150. package/dist/esm/dnd/abstractDragHandler.js +9 -9
  151. package/dist/esm/dnd/dataTransfer.d.ts +0 -25
  152. package/dist/esm/dnd/dataTransfer.js +0 -40
  153. package/dist/esm/dnd/dnd.d.ts +1 -14
  154. package/dist/esm/dnd/dnd.js +1 -69
  155. package/dist/esm/dnd/droptarget.d.ts +3 -0
  156. package/dist/esm/dnd/droptarget.js +69 -45
  157. package/dist/esm/dockview/components/tab/defaultTab.d.ts +0 -1
  158. package/dist/esm/dockview/components/tab/defaultTab.js +1 -9
  159. package/dist/esm/dockview/dockviewComponent.d.ts +31 -21
  160. package/dist/esm/dockview/dockviewComponent.js +68 -148
  161. package/dist/esm/dockview/dockviewGroupPanel.d.ts +3 -5
  162. package/dist/esm/dockview/dockviewGroupPanel.js +6 -30
  163. package/dist/esm/dockview/options.d.ts +2 -1
  164. package/dist/esm/events.js +2 -3
  165. package/dist/esm/gridview/baseComponentGridview.d.ts +12 -20
  166. package/dist/esm/gridview/baseComponentGridview.js +23 -45
  167. package/dist/esm/gridview/basePanelView.d.ts +5 -8
  168. package/dist/esm/gridview/basePanelView.js +10 -8
  169. package/dist/esm/gridview/branchNode.js +2 -2
  170. package/dist/esm/gridview/gridview.js +17 -15
  171. package/dist/esm/gridview/gridviewComponent.d.ts +4 -0
  172. package/dist/esm/gridview/gridviewComponent.js +6 -2
  173. package/dist/esm/gridview/gridviewPanel.d.ts +0 -1
  174. package/dist/esm/gridview/gridviewPanel.js +3 -6
  175. package/dist/esm/gridview/leafNode.js +1 -0
  176. package/dist/esm/groupview/groupPanel.d.ts +1 -7
  177. package/dist/esm/groupview/groupview.d.ts +15 -8
  178. package/dist/esm/groupview/groupview.js +22 -56
  179. package/dist/esm/groupview/groupviewPanel.d.ts +5 -2
  180. package/dist/esm/groupview/panel/content.js +1 -0
  181. package/dist/esm/groupview/tab.d.ts +10 -13
  182. package/dist/esm/groupview/tab.js +17 -24
  183. package/dist/esm/groupview/titlebar/tabsContainer.js +4 -6
  184. package/dist/esm/index.d.ts +3 -3
  185. package/dist/esm/index.js +1 -2
  186. package/dist/esm/lifecycle.js +2 -1
  187. package/dist/esm/panel/types.d.ts +0 -2
  188. package/dist/esm/paneview/draggablePaneviewPanel.d.ts +2 -2
  189. package/dist/esm/paneview/draggablePaneviewPanel.js +32 -29
  190. package/dist/esm/paneview/paneview.js +2 -2
  191. package/dist/esm/paneview/paneviewComponent.d.ts +5 -5
  192. package/dist/esm/paneview/paneviewComponent.js +15 -8
  193. package/dist/esm/paneview/paneviewPanel.d.ts +5 -1
  194. package/dist/esm/paneview/paneviewPanel.js +10 -2
  195. package/dist/esm/react/deserializer.js +1 -3
  196. package/dist/esm/react/dockview/dockview.d.ts +9 -9
  197. package/dist/esm/react/dockview/dockview.js +24 -2
  198. package/dist/esm/react/dockview/reactContentPart.js +4 -4
  199. package/dist/esm/react/dockview/reactHeaderPart.js +1 -0
  200. package/dist/esm/react/dockview/reactWatermarkPart.d.ts +1 -2
  201. package/dist/esm/react/dockview/reactWatermarkPart.js +1 -2
  202. package/dist/esm/react/gridview/gridview.js +4 -1
  203. package/dist/esm/react/gridview/view.js +2 -2
  204. package/dist/esm/react/index.d.ts +1 -0
  205. package/dist/esm/react/react.js +1 -2
  206. package/dist/esm/react/splitview/splitview.js +3 -1
  207. package/dist/esm/react/splitview/view.js +2 -2
  208. package/dist/esm/splitview/core/splitview.js +2 -2
  209. package/dist/esm/splitview/splitviewComponent.d.ts +9 -6
  210. package/dist/esm/splitview/splitviewComponent.js +11 -2
  211. package/dist/esm/splitview/splitviewPanel.d.ts +1 -6
  212. package/dist/esm/splitview/splitviewPanel.js +5 -3
  213. package/dist/styles/dockview.css +51 -54
  214. package/package.json +11 -11
  215. package/dist/cjs/functions.d.ts +0 -1
  216. package/dist/cjs/functions.js +0 -42
  217. package/dist/cjs/functions.js.map +0 -1
  218. package/dist/cjs/groupview/panel/hostedPanel.d.ts +0 -22
  219. package/dist/cjs/groupview/panel/hostedPanel.js +0 -57
  220. package/dist/cjs/groupview/panel/hostedPanel.js.map +0 -1
  221. package/dist/cjs/json.d.ts +0 -1
  222. package/dist/cjs/json.js +0 -14
  223. package/dist/cjs/json.js.map +0 -1
  224. package/dist/esm/functions.d.ts +0 -1
  225. package/dist/esm/functions.js +0 -8
  226. package/dist/esm/groupview/panel/hostedPanel.d.ts +0 -22
  227. package/dist/esm/groupview/panel/hostedPanel.js +0 -43
  228. package/dist/esm/json.d.ts +0 -1
  229. package/dist/esm/json.js +0 -9
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * dockview
3
- * @version 1.0.2
3
+ * @version 1.2.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,11 +209,17 @@
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
  }
304
- get orientation() {
305
- return this.component.orientation;
218
+ get onDidAddView() {
219
+ return this.component.onDidAddView;
220
+ }
221
+ get onDidRemoveView() {
222
+ return this.component.onDidRemoveView;
306
223
  }
307
224
  updateOptions(options) {
308
225
  this.component.updateOptions(options);
@@ -348,18 +265,18 @@
348
265
  constructor(component) {
349
266
  this.component = component;
350
267
  }
351
- get width() {
352
- return this.component.width;
353
- }
354
- get height() {
355
- return this.component.height;
356
- }
357
268
  get minimumSize() {
358
269
  return this.component.minimumSize;
359
270
  }
360
271
  get maximumSize() {
361
272
  return this.component.maximumSize;
362
273
  }
274
+ get height() {
275
+ return this.component.height;
276
+ }
277
+ get width() {
278
+ return this.component.width;
279
+ }
363
280
  get onDidLayoutChange() {
364
281
  return this.component.onDidLayoutChange;
365
282
  }
@@ -415,12 +332,6 @@
415
332
  constructor(component) {
416
333
  this.component = component;
417
334
  }
418
- get width() {
419
- return this.component.width;
420
- }
421
- get height() {
422
- return this.component.height;
423
- }
424
335
  get minimumHeight() {
425
336
  return this.component.minimumHeight;
426
337
  }
@@ -433,12 +344,27 @@
433
344
  get maximumWidth() {
434
345
  return this.component.maximumWidth;
435
346
  }
436
- get onGridEvent() {
437
- return this.component.onGridEvent;
347
+ get width() {
348
+ return this.component.width;
349
+ }
350
+ get height() {
351
+ return this.component.height;
438
352
  }
439
353
  get onDidLayoutChange() {
440
354
  return this.component.onDidLayoutChange;
441
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
+ }
442
368
  get panels() {
443
369
  return this.component.groups;
444
370
  }
@@ -513,8 +439,26 @@
513
439
  get totalPanels() {
514
440
  return this.component.totalPanels;
515
441
  }
516
- get onGridEvent() {
517
- 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;
518
462
  }
519
463
  get onDidLayoutChange() {
520
464
  return this.component.onDidLayoutChange;
@@ -543,18 +487,12 @@
543
487
  getPanel(id) {
544
488
  return this.component.getGroupPanel(id);
545
489
  }
546
- setActivePanel(panel) {
547
- this.component.setActivePanel(panel);
548
- }
549
490
  layout(width, height, force = false) {
550
491
  this.component.layout(width, height, force);
551
492
  }
552
493
  addPanel(options) {
553
494
  return this.component.addPanel(options);
554
495
  }
555
- removePanel(panel) {
556
- this.component.removePanel(panel);
557
- }
558
496
  addEmptyGroup(options) {
559
497
  this.component.addEmptyGroup(options);
560
498
  }
@@ -584,6 +522,46 @@
584
522
  }
585
523
  }
586
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
+
587
565
  function watchElementResize(element, cb) {
588
566
  const observer = new ResizeObserver((entires) => {
589
567
  const firstEntry = entires[0];
@@ -902,7 +880,7 @@
902
880
  this._onDidAddView = new Emitter();
903
881
  this.onDidAddView = this._onDidAddView.event;
904
882
  this._onDidRemoveView = new Emitter();
905
- this.onDidRemoveView = this._onDidAddView.event;
883
+ this.onDidRemoveView = this._onDidRemoveView.event;
906
884
  this._startSnappingEnabled = true;
907
885
  this._endSnappingEnabled = true;
908
886
  this.resize = (index, delta, sizes = this.views.map((x) => x.size), lowPriorityIndexes, highPriorityIndexes, overloadMinDelta = Number.NEGATIVE_INFINITY, overloadMaxDelta = Number.POSITIVE_INFINITY, snapBefore, snapAfter) => {
@@ -1529,13 +1507,13 @@
1529
1507
  this._onDidSashEnd.dispose();
1530
1508
  this._onDidAddView.dispose();
1531
1509
  this._onDidRemoveView.dispose();
1532
- this.element.remove();
1533
1510
  for (let i = 0; i < this.element.children.length; i++) {
1534
1511
  if (this.element.children.item(i) === this.element) {
1535
1512
  this.element.removeChild(this.element);
1536
1513
  break;
1537
1514
  }
1538
1515
  }
1516
+ this.element.remove();
1539
1517
  }
1540
1518
  }
1541
1519
 
@@ -1574,7 +1552,7 @@
1574
1552
  this.paneItems.push(paneItem);
1575
1553
  pane.orthogonalSize = this.splitview.orthogonalSize;
1576
1554
  });
1577
- this.addDisposables(this.splitview.onDidSashEnd(() => {
1555
+ this.addDisposables(this._onDidChange, this.splitview.onDidSashEnd(() => {
1578
1556
  this._onDidChange.fire(undefined);
1579
1557
  }), this.splitview.onDidAddView(() => {
1580
1558
  this._onDidChange.fire();
@@ -1664,7 +1642,6 @@
1664
1642
  }
1665
1643
  dispose() {
1666
1644
  super.dispose();
1667
- this.splitview.dispose();
1668
1645
  if (this.animationTimer) {
1669
1646
  clearTimeout(this.animationTimer);
1670
1647
  this.animationTimer = undefined;
@@ -1673,6 +1650,7 @@
1673
1650
  paneItem.disposable.dispose();
1674
1651
  });
1675
1652
  this.paneItems = [];
1653
+ this.splitview.dispose();
1676
1654
  this.element.remove();
1677
1655
  }
1678
1656
  }
@@ -1735,7 +1713,7 @@
1735
1713
  this.options = options;
1736
1714
  this._onDrop = new Emitter();
1737
1715
  this.onDrop = this._onDrop.event;
1738
- this.addDisposables(new DragAndDropObserver(this.element, {
1716
+ this.addDisposables(this._onDrop, new DragAndDropObserver(this.element, {
1739
1717
  onDragEnter: (e) => undefined,
1740
1718
  onDragOver: (e) => {
1741
1719
  if (isBooleanValue(this.options.canDisplayOverlay)) {
@@ -1771,51 +1749,11 @@
1771
1749
  const y = e.offsetY;
1772
1750
  const xp = (100 * x) / width;
1773
1751
  const yp = (100 * y) / height;
1774
- let isRight = false;
1775
- let isLeft = false;
1776
- let isTop = false;
1777
- let isBottom = false;
1778
- switch (this.options.validOverlays) {
1779
- case 'all':
1780
- isRight = xp > 80;
1781
- isLeft = xp < 20;
1782
- isTop = !isRight && !isLeft && yp < 20;
1783
- isBottom = !isRight && !isLeft && yp > 80;
1784
- break;
1785
- case 'vertical':
1786
- isTop = yp < 50;
1787
- isBottom = yp >= 50;
1788
- break;
1789
- case 'horizontal':
1790
- isLeft = xp < 50;
1791
- isRight = xp >= 50;
1792
- break;
1793
- }
1752
+ const quadrant = this.calculateQuadrant(this.options.validOverlays, xp, yp);
1794
1753
  const isSmallX = width < 100;
1795
1754
  const isSmallY = height < 100;
1796
- toggleClass(this.overlay, 'right', !isSmallX && isRight);
1797
- toggleClass(this.overlay, 'left', !isSmallX && isLeft);
1798
- toggleClass(this.overlay, 'top', !isSmallY && isTop);
1799
- toggleClass(this.overlay, 'bottom', !isSmallY && isBottom);
1800
- toggleClass(this.overlay, 'small-right', isSmallX && isRight);
1801
- toggleClass(this.overlay, 'small-left', isSmallX && isLeft);
1802
- toggleClass(this.overlay, 'small-top', isSmallY && isTop);
1803
- toggleClass(this.overlay, 'small-bottom', isSmallY && isBottom);
1804
- if (isRight) {
1805
- this._state = exports.Position.Right;
1806
- }
1807
- else if (isLeft) {
1808
- this._state = exports.Position.Left;
1809
- }
1810
- else if (isTop) {
1811
- this._state = exports.Position.Top;
1812
- }
1813
- else if (isBottom) {
1814
- this._state = exports.Position.Bottom;
1815
- }
1816
- else {
1817
- this._state = exports.Position.Center;
1818
- }
1755
+ this.toggleClasses(quadrant, isSmallX, isSmallY);
1756
+ this.setState(quadrant);
1819
1757
  },
1820
1758
  onDragLeave: (e) => {
1821
1759
  this.removeDropTarget();
@@ -1844,9 +1782,73 @@
1844
1782
  this.options.canDisplayOverlay = value;
1845
1783
  }
1846
1784
  dispose() {
1847
- this._onDrop.dispose();
1848
1785
  this.removeDropTarget();
1849
1786
  }
1787
+ toggleClasses(quadrant, isSmallX, isSmallY) {
1788
+ if (!this.overlay) {
1789
+ return;
1790
+ }
1791
+ const isLeft = quadrant === 'left';
1792
+ const isRight = quadrant === 'right';
1793
+ const isTop = quadrant === 'top';
1794
+ const isBottom = quadrant === 'bottom';
1795
+ toggleClass(this.overlay, 'right', !isSmallX && isRight);
1796
+ toggleClass(this.overlay, 'left', !isSmallX && isLeft);
1797
+ toggleClass(this.overlay, 'top', !isSmallY && isTop);
1798
+ toggleClass(this.overlay, 'bottom', !isSmallY && isBottom);
1799
+ toggleClass(this.overlay, 'small-right', isSmallX && isRight);
1800
+ toggleClass(this.overlay, 'small-left', isSmallX && isLeft);
1801
+ toggleClass(this.overlay, 'small-top', isSmallY && isTop);
1802
+ toggleClass(this.overlay, 'small-bottom', isSmallY && isBottom);
1803
+ }
1804
+ setState(quadrant) {
1805
+ switch (quadrant) {
1806
+ case 'top':
1807
+ this._state = exports.Position.Top;
1808
+ break;
1809
+ case 'left':
1810
+ this._state = exports.Position.Left;
1811
+ break;
1812
+ case 'bottom':
1813
+ this._state = exports.Position.Bottom;
1814
+ break;
1815
+ case 'right':
1816
+ this._state = exports.Position.Right;
1817
+ break;
1818
+ default:
1819
+ this._state = exports.Position.Center;
1820
+ break;
1821
+ }
1822
+ }
1823
+ calculateQuadrant(overlayType, xp, yp) {
1824
+ switch (overlayType) {
1825
+ case 'all':
1826
+ if (xp < 20) {
1827
+ return 'left';
1828
+ }
1829
+ if (xp > 80) {
1830
+ return 'right';
1831
+ }
1832
+ if (yp < 20) {
1833
+ return 'top';
1834
+ }
1835
+ if (yp > 80) {
1836
+ return 'bottom';
1837
+ }
1838
+ break;
1839
+ case 'vertical':
1840
+ if (yp < 50) {
1841
+ return 'top';
1842
+ }
1843
+ return 'bottom';
1844
+ case 'horizontal':
1845
+ if (xp < 50) {
1846
+ return 'left';
1847
+ }
1848
+ return 'right';
1849
+ }
1850
+ return null;
1851
+ }
1850
1852
  removeDropTarget() {
1851
1853
  if (this.target) {
1852
1854
  this._state = undefined;
@@ -1949,6 +1951,7 @@
1949
1951
  this.view.layout(this.width, this.height);
1950
1952
  }
1951
1953
  dispose() {
1954
+ this._onDidChange.dispose();
1952
1955
  this._disposable.dispose();
1953
1956
  }
1954
1957
  }
@@ -1966,7 +1969,7 @@
1966
1969
  this.children = [];
1967
1970
  this._onDidChange = new Emitter();
1968
1971
  this.onDidChange = this._onDidChange.event;
1969
- this._childrenDisposable = exports.Disposable.NONE;
1972
+ this._childrenDisposable = Disposable.NONE;
1970
1973
  this._orthogonalSize = orthogonalSize;
1971
1974
  this._size = size;
1972
1975
  this.element = document.createElement('div');
@@ -1991,7 +1994,7 @@
1991
1994
  : true,
1992
1995
  };
1993
1996
  }),
1994
- size: this.orthogonalSize,
1997
+ size: this.size,
1995
1998
  };
1996
1999
  this.children = childDescriptors.map((c) => c.node);
1997
2000
  this.splitview = new Splitview(this.element, {
@@ -2000,7 +2003,7 @@
2000
2003
  proportionalLayout,
2001
2004
  });
2002
2005
  }
2003
- this.addDisposables(this.splitview.onDidSashEnd(() => {
2006
+ this.addDisposables(this._onDidChange, this.splitview.onDidSashEnd(() => {
2004
2007
  this._onDidChange.fire(undefined);
2005
2008
  }));
2006
2009
  this.setupChildrenEvents();
@@ -2172,6 +2175,15 @@
2172
2175
  * Accreditation: This file is largly based upon the MIT licenced VSCode sourcecode found at:
2173
2176
  * https://github.com/microsoft/vscode/tree/main/src/vs/base/browser/ui/grid
2174
2177
  *--------------------------------------------------------------------------------------------*/
2178
+ function findLeaf(candiateNode, last) {
2179
+ if (candiateNode instanceof LeafNode) {
2180
+ return candiateNode;
2181
+ }
2182
+ if (candiateNode instanceof BranchNode) {
2183
+ return findLeaf(candiateNode.children[last ? candiateNode.children.length - 1 : 0], last);
2184
+ }
2185
+ throw new Error('invalid node');
2186
+ }
2175
2187
  function flipNode(node, size, orthogonalSize) {
2176
2188
  if (node instanceof BranchNode) {
2177
2189
  const result = new BranchNode(orthogonal(node.orientation), node.proportionalLayout, node.styles, size, orthogonalSize);
@@ -2303,6 +2315,7 @@
2303
2315
  this.disposable.dispose();
2304
2316
  this._onDidChange.dispose();
2305
2317
  this.root.dispose();
2318
+ this.element.remove();
2306
2319
  }
2307
2320
  clear() {
2308
2321
  const orientation = this.root.orientation;
@@ -2310,13 +2323,13 @@
2310
2323
  }
2311
2324
  deserialize(json, deserializer) {
2312
2325
  const orientation = json.orientation;
2313
- const height = json.height;
2326
+ const height = orientation === exports.Orientation.VERTICAL ? json.height : json.width;
2314
2327
  this._deserialize(json.root, orientation, deserializer, height);
2315
2328
  }
2316
2329
  _deserialize(root, orientation, deserializer, orthogonalSize) {
2317
- this.root = this._deserializeNode(root, orientation, deserializer, orthogonalSize);
2330
+ this.root = this._deserializeNode(root, orientation, deserializer, orthogonalSize, true);
2318
2331
  }
2319
- _deserializeNode(node, orientation, deserializer, orthogonalSize) {
2332
+ _deserializeNode(node, orientation, deserializer, orthogonalSize, isRoot = false) {
2320
2333
  let result;
2321
2334
  if (node.type === 'branch') {
2322
2335
  const serializedChildren = node.data;
@@ -2326,7 +2339,9 @@
2326
2339
  visible: serializedChild.visible,
2327
2340
  };
2328
2341
  });
2329
- result = new BranchNode(orientation, this.proportionalLayout, this.styles, node.size, orthogonalSize, children);
2342
+ // HORIZONTAL => height=orthogonalsize width=size
2343
+ // VERTICAL => height=size width=orthogonalsize
2344
+ result = new BranchNode(orientation, this.proportionalLayout, this.styles, isRoot ? orthogonalSize : node.size, isRoot ? node.size : orthogonalSize, children);
2330
2345
  }
2331
2346
  else {
2332
2347
  result = new LeafNode(deserializer.fromJSON(node), orientation, orthogonalSize, node.size);
@@ -2387,15 +2402,6 @@
2387
2402
  if (!(node instanceof LeafNode)) {
2388
2403
  throw new Error('invalid location');
2389
2404
  }
2390
- const findLeaf = (candiateNode, last) => {
2391
- if (candiateNode instanceof LeafNode) {
2392
- return candiateNode;
2393
- }
2394
- if (candiateNode instanceof BranchNode) {
2395
- return findLeaf(candiateNode.children[last ? candiateNode.children.length - 1 : 0], last);
2396
- }
2397
- throw new Error('invalid node');
2398
- };
2399
2405
  for (let i = path.length - 1; i > -1; i--) {
2400
2406
  const n = path[i];
2401
2407
  const l = location[i] || 0;
@@ -2497,9 +2503,9 @@
2497
2503
  if (parent.children.length > 1) {
2498
2504
  return node.view;
2499
2505
  }
2506
+ const sibling = parent.children[0];
2500
2507
  if (pathToParent.length === 0) {
2501
2508
  // parent is root
2502
- const sibling = parent.children[0];
2503
2509
  if (sibling instanceof LeafNode) {
2504
2510
  return node.view;
2505
2511
  }
@@ -2510,7 +2516,6 @@
2510
2516
  }
2511
2517
  const [grandParent, ..._] = [...pathToParent].reverse();
2512
2518
  const [parentIndex, ...__] = [...rest].reverse();
2513
- const sibling = parent.children[0];
2514
2519
  const isSiblingVisible = parent.isChildVisible(0);
2515
2520
  parent.removeChild(0, sizing);
2516
2521
  const sizes = grandParent.children.map((size, i) => grandParent.getChildSize(i));
@@ -2557,31 +2562,6 @@
2557
2562
  }
2558
2563
  }
2559
2564
 
2560
- /*! *****************************************************************************
2561
- Copyright (c) Microsoft Corporation.
2562
-
2563
- Permission to use, copy, modify, and/or distribute this software for any
2564
- purpose with or without fee is hereby granted.
2565
-
2566
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
2567
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
2568
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
2569
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
2570
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
2571
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
2572
- PERFORMANCE OF THIS SOFTWARE.
2573
- ***************************************************************************** */
2574
-
2575
- function __awaiter(thisArg, _arguments, P, generator) {
2576
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
2577
- return new (P || (P = Promise))(function (resolve, reject) {
2578
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
2579
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
2580
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
2581
- step((generator = generator.apply(thisArg, _arguments || [])).next());
2582
- });
2583
- }
2584
-
2585
2565
  class ContentContainer extends CompositeDisposable {
2586
2566
  constructor() {
2587
2567
  super();
@@ -2593,6 +2573,7 @@
2593
2573
  this._element = document.createElement('div');
2594
2574
  this._element.className = 'content-container';
2595
2575
  this._element.tabIndex = -1;
2576
+ this.addDisposables(this._onDidFocus, this._onDidBlur);
2596
2577
  // for hosted containers
2597
2578
  // 1) register a drop target on the host
2598
2579
  // 2) register window dragStart events to disable pointer events
@@ -2652,13 +2633,48 @@
2652
2633
  }
2653
2634
  }
2654
2635
 
2655
- var DockviewDropTargets;
2656
- (function (DockviewDropTargets) {
2657
- DockviewDropTargets[DockviewDropTargets["Tab"] = 0] = "Tab";
2658
- DockviewDropTargets[DockviewDropTargets["Panel"] = 1] = "Panel";
2659
- DockviewDropTargets[DockviewDropTargets["TabContainer"] = 2] = "TabContainer";
2660
- })(DockviewDropTargets || (DockviewDropTargets = {}));
2661
-
2636
+ var DockviewDropTargets;
2637
+ (function (DockviewDropTargets) {
2638
+ DockviewDropTargets[DockviewDropTargets["Tab"] = 0] = "Tab";
2639
+ DockviewDropTargets[DockviewDropTargets["Panel"] = 1] = "Panel";
2640
+ DockviewDropTargets[DockviewDropTargets["TabContainer"] = 2] = "TabContainer";
2641
+ })(DockviewDropTargets || (DockviewDropTargets = {}));
2642
+
2643
+ class DragHandler extends CompositeDisposable {
2644
+ constructor(el) {
2645
+ super();
2646
+ this.el = el;
2647
+ this.disposable = new MutableDisposable();
2648
+ this._onDragStart = new Emitter();
2649
+ this.onDragStart = this._onDragStart.event;
2650
+ this.iframes = [];
2651
+ this.configure();
2652
+ }
2653
+ configure() {
2654
+ this.addDisposables(this._onDragStart, addDisposableListener(this.el, 'dragstart', (event) => {
2655
+ this.iframes = [
2656
+ ...getElementsByTagName('iframe'),
2657
+ ...getElementsByTagName('webview'),
2658
+ ];
2659
+ for (const iframe of this.iframes) {
2660
+ iframe.style.pointerEvents = 'none';
2661
+ }
2662
+ this.el.classList.add('dragged');
2663
+ setTimeout(() => this.el.classList.remove('dragged'), 0);
2664
+ this.disposable.value = this.getData();
2665
+ if (event.dataTransfer) {
2666
+ event.dataTransfer.effectAllowed = 'move';
2667
+ }
2668
+ }), addDisposableListener(this.el, 'dragend', (ev) => {
2669
+ for (const iframe of this.iframes) {
2670
+ iframe.style.pointerEvents = 'auto';
2671
+ }
2672
+ this.iframes = [];
2673
+ this.disposable.dispose();
2674
+ }));
2675
+ }
2676
+ }
2677
+
2662
2678
  exports.MouseEventKind = void 0;
2663
2679
  (function (MouseEventKind) {
2664
2680
  MouseEventKind["CLICK"] = "CLICK";
@@ -2668,42 +2684,34 @@
2668
2684
  constructor(panelId, accessor, group) {
2669
2685
  super();
2670
2686
  this.panelId = panelId;
2671
- this.accessor = accessor;
2672
2687
  this.group = group;
2673
2688
  this._onChanged = new Emitter();
2674
2689
  this.onChanged = this._onChanged.event;
2675
2690
  this._onDropped = new Emitter();
2676
2691
  this.onDrop = this._onDropped.event;
2677
- this.panelTransfer = LocalSelectionTransfer.getInstance();
2678
- this.iframes = [];
2679
2692
  this.addDisposables(this._onChanged, this._onDropped);
2680
2693
  this._element = document.createElement('div');
2681
2694
  this._element.className = 'tab';
2682
2695
  this._element.tabIndex = 0;
2683
2696
  this._element.draggable = true;
2684
- this.addDisposables(addDisposableListener(this._element, 'dragstart', (event) => {
2685
- this.iframes = [
2686
- ...getElementsByTagName('iframe'),
2687
- ...getElementsByTagName('webview'),
2688
- ];
2689
- for (const iframe of this.iframes) {
2690
- iframe.style.pointerEvents = 'none';
2697
+ this.addDisposables(new (class Handler extends DragHandler {
2698
+ constructor() {
2699
+ super(...arguments);
2700
+ this.panelTransfer = LocalSelectionTransfer.getInstance();
2691
2701
  }
2692
- this.element.classList.add('dragged');
2693
- setTimeout(() => this.element.classList.remove('dragged'), 0);
2694
- this.panelTransfer.setData([
2695
- new PanelTransfer(this.accessor.id, this.group.id, this.panelId),
2696
- ], PanelTransfer.prototype);
2697
- if (event.dataTransfer) {
2698
- event.dataTransfer.effectAllowed = 'move';
2702
+ getData() {
2703
+ this.panelTransfer.setData([new PanelTransfer(accessor.id, group.id, panelId)], PanelTransfer.prototype);
2704
+ return {
2705
+ dispose: () => {
2706
+ this.panelTransfer.clearData(PanelTransfer.prototype);
2707
+ },
2708
+ };
2699
2709
  }
2700
- }), addDisposableListener(this._element, 'dragend', (ev) => {
2701
- for (const iframe of this.iframes) {
2702
- iframe.style.pointerEvents = 'auto';
2710
+ dispose() {
2711
+ //
2703
2712
  }
2704
- this.iframes = [];
2705
- this.panelTransfer.clearData(PanelTransfer.prototype);
2706
- }), addDisposableListener(this._element, 'mousedown', (event) => {
2713
+ })(this._element));
2714
+ this.addDisposables(addDisposableListener(this._element, 'mousedown', (event) => {
2707
2715
  if (event.defaultPrevented) {
2708
2716
  return;
2709
2717
  }
@@ -2905,12 +2913,10 @@
2905
2913
  if (!isLeftClick || event.event.defaultPrevented) {
2906
2914
  return;
2907
2915
  }
2908
- switch (event.kind) {
2909
- case exports.MouseEventKind.CLICK:
2910
- this.group.model.openPanel(panel, {
2911
- skipFocus: alreadyFocused,
2912
- });
2913
- break;
2916
+ if (event.kind === exports.MouseEventKind.CLICK) {
2917
+ this.group.model.openPanel(panel, {
2918
+ skipFocus: alreadyFocused,
2919
+ });
2914
2920
  }
2915
2921
  }), tabToAdd.onDrop((event) => {
2916
2922
  this._onDrop.fire({
@@ -2939,7 +2945,6 @@
2939
2945
  GroupChangeKind2["ADD_PANEL"] = "ADD_PANEL";
2940
2946
  GroupChangeKind2["REMOVE_PANEL"] = "REMOVE_PANEL";
2941
2947
  GroupChangeKind2["PANEL_ACTIVE"] = "PANEL_ACTIVE";
2942
- GroupChangeKind2["GROUP_ACTIVE"] = "GROUP_ACTIVE";
2943
2948
  })(exports.GroupChangeKind2 || (exports.GroupChangeKind2 = {}));
2944
2949
  class Groupview extends CompositeDisposable {
2945
2950
  constructor(container, accessor, id, options, parent) {
@@ -2960,15 +2965,10 @@
2960
2965
  this.onMove = this._onMove.event;
2961
2966
  this._onDidGroupChange = new Emitter();
2962
2967
  this.onDidGroupChange = this._onDidGroupChange.event;
2963
- this.closePanel = (panel) => __awaiter(this, void 0, void 0, function* () {
2964
- if (panel.close && !(yield panel.close())) {
2965
- return false;
2966
- }
2967
- this.doClose(panel);
2968
- return true;
2969
- });
2968
+ this._onDidDrop = new Emitter();
2969
+ this.onDidDrop = this._onDidDrop.event;
2970
2970
  this.container.classList.add('groupview');
2971
- this.addDisposables(this._onMove, this._onDidGroupChange);
2971
+ this.addDisposables(this._onMove, this._onDidGroupChange, this._onDidChange, this._onDidDrop);
2972
2972
  this.tabsContainer = new TabsContainer(this.accessor, this.parent, {
2973
2973
  tabHeight: options.tabHeight,
2974
2974
  });
@@ -3125,6 +3125,8 @@
3125
3125
  options.index > this.panels.length) {
3126
3126
  options.index = this.panels.length;
3127
3127
  }
3128
+ // ensure the group is updated before we fire any events
3129
+ panel.updateParentGroup(this.parent, true);
3128
3130
  if (this._activePanel === panel) {
3129
3131
  this.accessor.doSetGroupActive(this.parent);
3130
3132
  return;
@@ -3145,43 +3147,19 @@
3145
3147
  return this._removePanel(panelToRemove);
3146
3148
  }
3147
3149
  closeAllPanels() {
3148
- var _a;
3149
- return __awaiter(this, void 0, void 0, function* () {
3150
- const index = this._activePanel
3151
- ? this.panels.indexOf(this._activePanel)
3152
- : -1;
3153
- if (this._activePanel && index > -1) {
3154
- if (this.panels.indexOf(this._activePanel) < 0) {
3155
- console.warn('active panel not tracked');
3156
- }
3157
- const canClose = !((_a = this._activePanel) === null || _a === void 0 ? void 0 : _a.close) || (yield this._activePanel.close());
3158
- if (!canClose) {
3159
- return false;
3160
- }
3161
- }
3162
- for (let i = 0; i < this.panels.length; i++) {
3163
- if (i === index) {
3164
- continue;
3165
- }
3166
- const panel = this.panels[i];
3167
- this.openPanel(panel);
3168
- if (panel.close) {
3169
- const canClose = yield panel.close();
3170
- if (!canClose) {
3171
- return false;
3172
- }
3173
- }
3174
- }
3175
- if (this.panels.length > 0) {
3176
- // take a copy since we will be edting the array as we iterate through
3177
- const arrPanelCpy = [...this.panels];
3178
- yield Promise.all(arrPanelCpy.map((p) => this.doClose(p)));
3150
+ if (this.panels.length > 0) {
3151
+ // take a copy since we will be edting the array as we iterate through
3152
+ const arrPanelCpy = [...this.panels];
3153
+ for (const panel of arrPanelCpy) {
3154
+ this.doClose(panel);
3179
3155
  }
3180
- else {
3181
- this.accessor.removeGroup(this.parent);
3182
- }
3183
- return true;
3184
- });
3156
+ }
3157
+ else {
3158
+ this.accessor.removeGroup(this.parent);
3159
+ }
3160
+ }
3161
+ closePanel(panel) {
3162
+ this.doClose(panel);
3185
3163
  }
3186
3164
  doClose(panel) {
3187
3165
  this.accessor.removePanel(panel);
@@ -3324,8 +3302,11 @@
3324
3302
  this.tabsContainer.show();
3325
3303
  }
3326
3304
  }
3327
- canDisplayOverlay(dragOverEvent, target) {
3305
+ canDisplayOverlay(event, target) {
3328
3306
  // custom overlay handler
3307
+ if (this.accessor.options.showDndOverlay) {
3308
+ return this.accessor.options.showDndOverlay(event, target);
3309
+ }
3329
3310
  return false;
3330
3311
  }
3331
3312
  handleDropEvent(event, position, index) {
@@ -3350,6 +3331,9 @@
3350
3331
  index,
3351
3332
  });
3352
3333
  }
3334
+ else {
3335
+ this._onDidDrop.fire({ nativeEvent: event, position, index });
3336
+ }
3353
3337
  }
3354
3338
  dispose() {
3355
3339
  for (const panel of this.panels) {
@@ -3362,19 +3346,6 @@
3362
3346
  }
3363
3347
  }
3364
3348
 
3365
- exports.GroupChangeKind = void 0;
3366
- (function (GroupChangeKind) {
3367
- GroupChangeKind["ADD_PANEL"] = "ADD_PANEL";
3368
- GroupChangeKind["REMOVE_PANEL"] = "REMOVE_PANEL";
3369
- GroupChangeKind["PANEL_ACTIVE"] = "PANEL_ACTIVE";
3370
- //
3371
- GroupChangeKind["GROUP_ACTIVE"] = "GROUP_ACTIVE";
3372
- GroupChangeKind["ADD_GROUP"] = "ADD_GROUP";
3373
- GroupChangeKind["REMOVE_GROUP"] = "REMOVE_GROUP";
3374
- //
3375
- GroupChangeKind["LAYOUT_FROM_JSON"] = "LAYOUT_FROM_JSON";
3376
- GroupChangeKind["LAYOUT"] = "LAYOUT";
3377
- })(exports.GroupChangeKind || (exports.GroupChangeKind = {}));
3378
3349
  const nextLayoutId = sequentialNumberGenerator();
3379
3350
  function toTarget(direction) {
3380
3351
  switch (direction) {
@@ -3397,36 +3368,26 @@
3397
3368
  this._element = _element;
3398
3369
  this._id = nextLayoutId.next();
3399
3370
  this._groups = new Map();
3400
- //
3401
- this._onGridEvent = new Emitter();
3402
- this.onGridEvent = this._onGridEvent.event;
3403
3371
  this._onDidLayoutChange = new Emitter();
3404
3372
  this.onDidLayoutChange = this._onDidLayoutChange.event;
3373
+ this._onDidRemoveGroup = new Emitter();
3374
+ this.onDidRemoveGroup = this._onDidRemoveGroup.event;
3375
+ this._onDidAddGroup = new Emitter();
3376
+ this.onDidAddGroup = this._onDidAddGroup.event;
3377
+ this._onDidActiveGroupChange = new Emitter();
3378
+ this.onDidActiveGroupChange = this._onDidActiveGroupChange.event;
3379
+ this._bufferOnDidLayoutChange = new TickDelayedEvent();
3405
3380
  this.gridview = new Gridview(!!options.proportionalLayout, options.styles, options.orientation);
3406
3381
  this.element.appendChild(this.gridview.element);
3407
- // TODO for some reason this is required before anything will layout correctly
3408
- this.layout(0, 0, true);
3382
+ this.layout(0, 0, true); // set some elements height/widths
3409
3383
  this.addDisposables(this.gridview.onDidChange(() => {
3410
- this._onGridEvent.fire({ kind: exports.GroupChangeKind.LAYOUT });
3384
+ this._onDidLayoutChange.fire();
3411
3385
  }));
3412
- this.addDisposables((() => {
3413
- const tickDelayedEvent = new TickDelayedEvent();
3414
- return new CompositeDisposable(this.onGridEvent((event) => {
3415
- if ([
3416
- exports.GroupChangeKind.ADD_GROUP,
3417
- exports.GroupChangeKind.REMOVE_GROUP,
3418
- exports.GroupChangeKind.ADD_PANEL,
3419
- exports.GroupChangeKind.REMOVE_PANEL,
3420
- exports.GroupChangeKind.GROUP_ACTIVE,
3421
- exports.GroupChangeKind.PANEL_ACTIVE,
3422
- exports.GroupChangeKind.LAYOUT,
3423
- ].includes(event.kind)) {
3424
- tickDelayedEvent.fire();
3425
- }
3426
- }), tickDelayedEvent.onEvent(() => {
3427
- this._onDidLayoutChange.fire();
3428
- }), tickDelayedEvent);
3429
- })());
3386
+ this.addDisposables(exports.Event.any(this.onDidAddGroup, this.onDidRemoveGroup, this.onDidActiveGroupChange)(() => {
3387
+ this._bufferOnDidLayoutChange.fire();
3388
+ }), this._bufferOnDidLayoutChange.onEvent(() => {
3389
+ this._onDidLayoutChange.fire();
3390
+ }), this._bufferOnDidLayoutChange);
3430
3391
  }
3431
3392
  get id() {
3432
3393
  return this._id;
@@ -3463,14 +3424,14 @@
3463
3424
  }
3464
3425
  setVisible(panel, visible) {
3465
3426
  this.gridview.setViewVisible(getGridLocation(panel.element), visible);
3466
- this._onGridEvent.fire({ kind: exports.GroupChangeKind.LAYOUT });
3427
+ this._onDidLayoutChange.fire();
3467
3428
  }
3468
3429
  isVisible(panel) {
3469
3430
  return this.gridview.isViewVisible(getGridLocation(panel.element));
3470
3431
  }
3471
3432
  doAddGroup(group, location = [0], size) {
3472
3433
  this.gridview.addView(group, size !== null && size !== void 0 ? size : exports.Sizing.Distribute, location);
3473
- this._onGridEvent.fire({ kind: exports.GroupChangeKind.ADD_GROUP });
3434
+ this._onDidAddGroup.fire(group);
3474
3435
  this.doSetGroupActive(group);
3475
3436
  }
3476
3437
  doRemoveGroup(group, options) {
@@ -3483,7 +3444,7 @@
3483
3444
  item.disposable.dispose();
3484
3445
  this._groups.delete(group.id);
3485
3446
  }
3486
- this._onGridEvent.fire({ kind: exports.GroupChangeKind.REMOVE_GROUP });
3447
+ this._onDidRemoveGroup.fire(group);
3487
3448
  if (!(options === null || options === void 0 ? void 0 : options.skipActive) && this._activeGroup === group) {
3488
3449
  const groups = Array.from(this._groups.values());
3489
3450
  this.doSetGroupActive(groups.length > 0 ? groups[0].value : undefined);
@@ -3511,9 +3472,7 @@
3511
3472
  }
3512
3473
  }
3513
3474
  this._activeGroup = group;
3514
- this._onGridEvent.fire({
3515
- kind: exports.GroupChangeKind.GROUP_ACTIVE,
3516
- });
3475
+ this._onDidActiveGroupChange.fire(group);
3517
3476
  }
3518
3477
  removeGroup(group) {
3519
3478
  this.doRemoveGroup(group);
@@ -3569,7 +3528,10 @@
3569
3528
  }
3570
3529
  dispose() {
3571
3530
  super.dispose();
3572
- this._onGridEvent.dispose();
3531
+ this._onDidActiveGroupChange.dispose();
3532
+ this._onDidAddGroup.dispose();
3533
+ this._onDidRemoveGroup.dispose();
3534
+ this._onDidLayoutChange.dispose();
3573
3535
  this.gridview.dispose();
3574
3536
  }
3575
3537
  }
@@ -3581,15 +3543,11 @@
3581
3543
  constructor(id) {
3582
3544
  super();
3583
3545
  this.id = id;
3584
- this._state = {};
3585
3546
  this._isFocused = false;
3586
3547
  this._isActive = false;
3587
3548
  this._isVisible = true;
3588
3549
  this._width = 0;
3589
3550
  this._height = 0;
3590
- this._onDidStateChange = new Emitter();
3591
- this.onDidStateChange = this._onDidStateChange.event;
3592
- //
3593
3551
  this._onDidPanelDimensionChange = new Emitter({
3594
3552
  replay: true,
3595
3553
  });
@@ -3618,7 +3576,7 @@
3618
3576
  //
3619
3577
  this._onActiveChange = new Emitter();
3620
3578
  this.onActiveChange = this._onActiveChange.event;
3621
- this.addDisposables(this._onDidStateChange, this._onDidPanelDimensionChange, this._onDidChangeFocus, this._onDidVisibilityChange, this._onDidActiveChange, this._onFocusEvent, this.onDidFocusChange((event) => {
3579
+ this.addDisposables(this._onDidPanelDimensionChange, this._onDidChangeFocus, this._onDidVisibilityChange, this._onDidActiveChange, this._onFocusEvent, this._onActiveChange, this._onVisibilityChange, this.onDidFocusChange((event) => {
3622
3580
  this._isFocused = event.isFocused;
3623
3581
  }), this.onDidActiveChange((event) => {
3624
3582
  this._isActive = event.isActive;
@@ -3651,21 +3609,6 @@
3651
3609
  setActive() {
3652
3610
  this._onActiveChange.fire();
3653
3611
  }
3654
- setState(key, value) {
3655
- if (typeof key === 'object') {
3656
- this._state = key;
3657
- }
3658
- else if (typeof value !== undefined) {
3659
- this._state[key] = value;
3660
- }
3661
- this._onDidStateChange.fire(undefined);
3662
- }
3663
- getState() {
3664
- return this._state;
3665
- }
3666
- getStateKey(key) {
3667
- return this._state[key];
3668
- }
3669
3612
  dispose() {
3670
3613
  super.dispose();
3671
3614
  }
@@ -3685,6 +3628,7 @@
3685
3628
  //
3686
3629
  this._onDidSizeChange = new Emitter();
3687
3630
  this.onDidSizeChange = this._onDidSizeChange.event;
3631
+ this.addDisposables(this._onDidConstraintsChangeInternal, this._onDidConstraintsChange, this._onDidSizeChange);
3688
3632
  }
3689
3633
  setConstraints(value) {
3690
3634
  this._onDidConstraintsChangeInternal.fire(value);
@@ -3698,19 +3642,19 @@
3698
3642
  constructor(panel, group) {
3699
3643
  super(panel.id);
3700
3644
  this.panel = panel;
3701
- this._onDidDirtyChange = new Emitter();
3702
- this.onDidDirtyChange = this._onDidDirtyChange.event;
3703
3645
  this._onDidTitleChange = new Emitter();
3704
3646
  this.onDidTitleChange = this._onDidTitleChange.event;
3705
3647
  this._titleChanged = new Emitter();
3706
3648
  this.titleChanged = this._titleChanged.event;
3707
3649
  this._suppressClosableChanged = new Emitter();
3708
3650
  this.suppressClosableChanged = this._suppressClosableChanged.event;
3709
- this._group = group;
3710
- this.addDisposables(this._onDidDirtyChange);
3711
- }
3712
- get tryClose() {
3713
- return this._interceptor;
3651
+ this._onDidActiveGroupChange = new Emitter();
3652
+ this.onDidActiveGroupChange = this._onDidActiveGroupChange.event;
3653
+ this._onDidGroupChange = new Emitter();
3654
+ this.onDidGroupChange = this._onDidGroupChange.event;
3655
+ this.disposable = new MutableDisposable();
3656
+ this.group = group;
3657
+ this.addDisposables(this.disposable, this._onDidTitleChange, this._titleChanged, this._suppressClosableChanged, this._onDidGroupChange, this._onDidActiveGroupChange);
3714
3658
  }
3715
3659
  get title() {
3716
3660
  return this.panel.title;
@@ -3723,7 +3667,17 @@
3723
3667
  return !!((_a = this.group) === null || _a === void 0 ? void 0 : _a.isActive);
3724
3668
  }
3725
3669
  set group(value) {
3670
+ const isOldGroupActive = this.isGroupActive;
3726
3671
  this._group = value;
3672
+ this._onDidGroupChange.fire();
3673
+ if (this._group) {
3674
+ this.disposable.value = this._group.api.onDidActiveChange(() => {
3675
+ this._onDidActiveGroupChange.fire();
3676
+ });
3677
+ if (this.isGroupActive !== isOldGroupActive) {
3678
+ this._onDidActiveGroupChange.fire();
3679
+ }
3680
+ }
3727
3681
  }
3728
3682
  get group() {
3729
3683
  return this._group;
@@ -3737,16 +3691,10 @@
3737
3691
  }
3738
3692
  return this.group.model.closePanel(this.panel);
3739
3693
  }
3740
- interceptOnCloseAction(interceptor) {
3741
- this._interceptor = interceptor;
3742
- }
3743
- dispose() {
3744
- super.dispose();
3745
- }
3746
3694
  }
3747
3695
 
3748
3696
  class DockviewGroupPanel extends CompositeDisposable {
3749
- constructor(id, containerApi) {
3697
+ constructor(id, accessor, containerApi) {
3750
3698
  super();
3751
3699
  this.id = id;
3752
3700
  this.containerApi = containerApi;
@@ -3754,14 +3702,17 @@
3754
3702
  this._suppressClosable = false;
3755
3703
  this._title = '';
3756
3704
  this.api = new DockviewPanelApiImpl(this, this._group);
3757
- this.onDidStateChange = this.api.onDidStateChange;
3758
3705
  this.addDisposables(this.api.onActiveChange(() => {
3759
- this.containerApi.setActivePanel(this);
3706
+ accessor.setActivePanel(this);
3760
3707
  }), this.api.onDidTitleChange((event) => {
3761
3708
  const title = event.title;
3762
3709
  this.update({ params: { title } });
3763
3710
  }));
3764
3711
  }
3712
+ get params() {
3713
+ var _a;
3714
+ return (_a = this._params) === null || _a === void 0 ? void 0 : _a.params;
3715
+ }
3765
3716
  get title() {
3766
3717
  return this._title;
3767
3718
  }
@@ -3780,32 +3731,18 @@
3780
3731
  this._view = params.view;
3781
3732
  this.setTitle(params.title);
3782
3733
  this.setSuppressClosable(params.suppressClosable || false);
3783
- if (params.state) {
3784
- this.api.setState(params.state);
3785
- }
3786
3734
  (_a = this.view) === null || _a === void 0 ? void 0 : _a.init(Object.assign(Object.assign({}, params), { api: this.api, containerApi: this.containerApi }));
3787
3735
  }
3788
3736
  focus() {
3789
3737
  this.api._onFocusEvent.fire();
3790
3738
  }
3791
- setDirty(isDirty) {
3792
- this.api._onDidDirtyChange.fire(isDirty);
3793
- }
3794
- close() {
3795
- if (this.api.tryClose) {
3796
- return this.api.tryClose();
3797
- }
3798
- return Promise.resolve(true);
3799
- }
3800
3739
  toJSON() {
3801
- const state = this.api.getState();
3802
3740
  return {
3803
3741
  id: this.id,
3804
3742
  view: this.view.toJSON(),
3805
3743
  params: Object.keys(this._params || {}).length > 0
3806
3744
  ? this._params
3807
3745
  : undefined,
3808
- state: state && Object.keys(state).length > 0 ? state : undefined,
3809
3746
  suppressClosable: this.suppressClosable || undefined,
3810
3747
  title: this.title,
3811
3748
  };
@@ -3850,18 +3787,6 @@
3850
3787
  var _a;
3851
3788
  this._group = group;
3852
3789
  this.api.group = group;
3853
- this.mutableDisposable.value = this._group.model.onDidGroupChange((ev) => {
3854
- var _a;
3855
- if (ev.kind === exports.GroupChangeKind2.GROUP_ACTIVE) {
3856
- const isVisible = !!((_a = this._group) === null || _a === void 0 ? void 0 : _a.model.isPanelActive(this));
3857
- this.api._onDidActiveChange.fire({
3858
- isActive: isGroupActive && isVisible,
3859
- });
3860
- this.api._onDidVisibilityChange.fire({
3861
- isVisible,
3862
- });
3863
- }
3864
- });
3865
3790
  const isPanelVisible = this._group.model.isPanelActive(this);
3866
3791
  this.api._onDidActiveChange.fire({
3867
3792
  isActive: isGroupActive && isPanelVisible,
@@ -3971,15 +3896,6 @@
3971
3896
  }
3972
3897
  }
3973
3898
 
3974
- function debounce(cb, wait) {
3975
- let timeout;
3976
- const callable = (...args) => {
3977
- clearTimeout(timeout);
3978
- timeout = setTimeout(() => cb(...args), wait);
3979
- };
3980
- return callable;
3981
- }
3982
-
3983
3899
  class DefaultDeserializer {
3984
3900
  constructor(layout, panelDeserializer) {
3985
3901
  this.layout = layout;
@@ -4080,9 +3996,6 @@
4080
3996
  this._isGroupActive = false;
4081
3997
  //
4082
3998
  this.params = {};
4083
- //
4084
- this.isDirtyDisposable = new MutableDisposable();
4085
- this.addDisposables(this.isDirtyDisposable);
4086
3999
  this._element = document.createElement('div');
4087
4000
  this._element.className = 'default-tab';
4088
4001
  //
@@ -4127,10 +4040,6 @@
4127
4040
  init(params) {
4128
4041
  this.params = params;
4129
4042
  this._content.textContent = params.title;
4130
- this.isDirtyDisposable.value = this.params.api.onDidDirtyChange((event) => {
4131
- const isDirty = event;
4132
- toggleClass(this.action, 'dirty', isDirty);
4133
- });
4134
4043
  if (!this.params.suppressClosable) {
4135
4044
  addDisposableListener(this.action, 'click', (ev) => {
4136
4045
  ev.preventDefault(); //
@@ -4184,6 +4093,10 @@
4184
4093
  get height() {
4185
4094
  return this._height;
4186
4095
  }
4096
+ get params() {
4097
+ var _a;
4098
+ return (_a = this._params) === null || _a === void 0 ? void 0 : _a.params;
4099
+ }
4187
4100
  focus() {
4188
4101
  this.api._onFocusEvent.fire();
4189
4102
  }
@@ -4192,29 +4105,27 @@
4192
4105
  this._height = height;
4193
4106
  this.api._onDidPanelDimensionChange.fire({ width, height });
4194
4107
  if (this.part) {
4195
- if (this.params) {
4196
- this.part.update(this.params.params);
4108
+ if (this._params) {
4109
+ this.part.update(this._params.params);
4197
4110
  }
4198
4111
  }
4199
4112
  }
4200
4113
  init(parameters) {
4201
- this.params = parameters;
4114
+ this._params = parameters;
4202
4115
  this.part = this.getComponent();
4203
4116
  }
4204
4117
  update(event) {
4205
4118
  var _a, _b;
4206
- 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) });
4207
- (_b = this.part) === null || _b === void 0 ? void 0 : _b.update({ params: this.params.params });
4119
+ 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) });
4120
+ (_b = this.part) === null || _b === void 0 ? void 0 : _b.update({ params: this._params.params });
4208
4121
  }
4209
4122
  toJSON() {
4210
4123
  var _a, _b;
4211
- const state = this.api.getState();
4212
- const params = (_b = (_a = this.params) === null || _a === void 0 ? void 0 : _a.params) !== null && _b !== void 0 ? _b : {};
4124
+ const params = (_b = (_a = this._params) === null || _a === void 0 ? void 0 : _a.params) !== null && _b !== void 0 ? _b : {};
4213
4125
  return {
4214
4126
  id: this.id,
4215
4127
  component: this.component,
4216
4128
  params: Object.keys(params).length > 0 ? params : undefined,
4217
- state: Object.keys(state).length === 0 ? undefined : state,
4218
4129
  };
4219
4130
  }
4220
4131
  dispose() {
@@ -4237,12 +4148,12 @@
4237
4148
  this._snap = false;
4238
4149
  this._onDidChange = new Emitter();
4239
4150
  this.onDidChange = this._onDidChange.event;
4240
- this.addDisposables(this.api.onVisibilityChange((event) => {
4151
+ this.addDisposables(this._onDidChange, this.api.onVisibilityChange((event) => {
4241
4152
  const { isVisible } = event;
4242
- const { containerApi } = this.params;
4153
+ const { containerApi } = this._params;
4243
4154
  containerApi.setVisible(this, isVisible);
4244
4155
  }), this.api.onActiveChange(() => {
4245
- const { containerApi } = this.params;
4156
+ const { containerApi } = this._params;
4246
4157
  containerApi.setActive(this);
4247
4158
  }), this.api.onDidConstraintsChangeInternal((event) => {
4248
4159
  if (typeof event.minimumWidth === 'number' ||
@@ -4357,9 +4268,6 @@
4357
4268
  const minimum = (value) => (value <= 0 ? undefined : value);
4358
4269
  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 });
4359
4270
  }
4360
- dispose() {
4361
- super.dispose();
4362
- }
4363
4271
  }
4364
4272
 
4365
4273
  class GroupviewPanel extends GridviewPanel {
@@ -4466,15 +4374,24 @@
4466
4374
  orientation: options.orientation || exports.Orientation.HORIZONTAL,
4467
4375
  styles: options.styles,
4468
4376
  });
4469
- this._panels = new Map();
4470
- this.dirtyPanels = new Set();
4471
- this.debouncedDeque = debounce(this.syncConfigs.bind(this), 5000);
4472
4377
  // events
4473
4378
  this._onTabInteractionEvent = new Emitter();
4474
4379
  this.onTabInteractionEvent = this._onTabInteractionEvent.event;
4475
4380
  this._onTabContextMenu = new Emitter();
4476
4381
  this.onTabContextMenu = this._onTabContextMenu.event;
4477
- this.panelState = {};
4382
+ this._onDidDrop = new Emitter();
4383
+ this.onDidDrop = this._onDidDrop.event;
4384
+ this._onDidRemovePanel = new Emitter();
4385
+ this.onDidRemovePanel = this._onDidRemovePanel.event;
4386
+ this._onDidAddPanel = new Emitter();
4387
+ this.onDidAddPanel = this._onDidAddPanel.event;
4388
+ this._onDidLayoutfromJSON = new Emitter();
4389
+ this.onDidLayoutfromJSON = this._onDidLayoutfromJSON.event;
4390
+ this._onDidActivePanelChange = new Emitter();
4391
+ this.onDidActivePanelChange = this._onDidActivePanelChange.event;
4392
+ this.addDisposables(this._onTabInteractionEvent, this._onTabContextMenu, this._onDidDrop, exports.Event.any(this.onDidAddPanel, this.onDidRemovePanel, this.onDidActivePanelChange)(() => {
4393
+ this._bufferOnDidLayoutChange.fire();
4394
+ }));
4478
4395
  this._options = options;
4479
4396
  if (!this.options.components) {
4480
4397
  this.options.components = {};
@@ -4495,10 +4412,10 @@
4495
4412
  this._api = new DockviewApi(this);
4496
4413
  }
4497
4414
  get totalPanels() {
4498
- return this._panels.size;
4415
+ return this.panels.length;
4499
4416
  }
4500
4417
  get panels() {
4501
- return Array.from(this._panels.values()).map((_) => _.value);
4418
+ return this.groups.flatMap((group) => group.model.panels);
4502
4419
  }
4503
4420
  get deserializer() {
4504
4421
  return this._deserializer;
@@ -4528,10 +4445,6 @@
4528
4445
  updateOptions(options) {
4529
4446
  const hasOrientationChanged = typeof options.orientation === 'string' &&
4530
4447
  this.options.orientation !== options.orientation;
4531
- // TODO support style update
4532
- // const hasStylesChanged =
4533
- // typeof options.styles === 'object' &&
4534
- // this.options.styles !== options.styles;
4535
4448
  this._options = Object.assign(Object.assign({}, this.options), options);
4536
4449
  if (hasOrientationChanged) {
4537
4450
  this.gridview.orientation = options.orientation;
@@ -4543,8 +4456,7 @@
4543
4456
  (_a = this.activeGroup) === null || _a === void 0 ? void 0 : _a.focus();
4544
4457
  }
4545
4458
  getGroupPanel(id) {
4546
- var _a;
4547
- return (_a = this._panels.get(id)) === null || _a === void 0 ? void 0 : _a.value;
4459
+ return this.panels.find((panel) => panel.id === id);
4548
4460
  }
4549
4461
  setActivePanel(panel) {
4550
4462
  if (!panel.group) {
@@ -4593,24 +4505,6 @@
4593
4505
  this.doSetGroupActive(next);
4594
4506
  }
4595
4507
  }
4596
- registerPanel(panel) {
4597
- if (this._panels.has(panel.id)) {
4598
- throw new Error(`panel ${panel.id} already exists`);
4599
- }
4600
- const disposable = new CompositeDisposable(panel.onDidStateChange(() => this.addDirtyPanel(panel)));
4601
- this._panels.set(panel.id, { value: panel, disposable });
4602
- }
4603
- unregisterPanel(panel) {
4604
- if (!this._panels.has(panel.id)) {
4605
- throw new Error(`panel ${panel.id} doesn't exist`);
4606
- }
4607
- const item = this._panels.get(panel.id);
4608
- if (item) {
4609
- item.disposable.dispose();
4610
- item.value.dispose();
4611
- }
4612
- this._panels.delete(panel.id);
4613
- }
4614
4508
  /**
4615
4509
  * Serialize the current state of the layout
4616
4510
  *
@@ -4618,12 +4512,9 @@
4618
4512
  */
4619
4513
  toJSON() {
4620
4514
  var _a;
4621
- this.syncConfigs();
4622
4515
  const data = this.gridview.serialize();
4623
- const panels = Array.from(this._panels.values()).reduce((collection, panel) => {
4624
- if (!this.panelState[panel.value.id]) {
4625
- collection[panel.value.id] = panel.value.toJSON();
4626
- }
4516
+ const panels = this.panels.reduce((collection, panel) => {
4517
+ collection[panel.id] = panel.toJSON();
4627
4518
  return collection;
4628
4519
  }, {});
4629
4520
  return {
@@ -4634,13 +4525,12 @@
4634
4525
  };
4635
4526
  }
4636
4527
  fromJSON(data) {
4528
+ const groups = Array.from(this._groups.values()).map((_) => _.value);
4529
+ for (const group of groups) {
4530
+ // remove the group will automatically remove the panels
4531
+ this.removeGroup(group, true);
4532
+ }
4637
4533
  this.gridview.clear();
4638
- this._panels.forEach((panel) => {
4639
- panel.disposable.dispose();
4640
- panel.value.dispose();
4641
- });
4642
- this._panels.clear();
4643
- this._groups.clear();
4644
4534
  if (!this.deserializer) {
4645
4535
  throw new Error('invalid deserializer');
4646
4536
  }
@@ -4654,9 +4544,7 @@
4654
4544
  this.gridview.deserialize(grid, new DefaultDeserializer(this, {
4655
4545
  createPanel: (id) => {
4656
4546
  const panelData = panels[id];
4657
- const panel = this.deserializer.fromJSON(panelData);
4658
- this.registerPanel(panel);
4659
- return panel;
4547
+ return this.deserializer.fromJSON(panelData);
4660
4548
  },
4661
4549
  }));
4662
4550
  if (typeof activeGroup === 'string') {
@@ -4666,31 +4554,23 @@
4666
4554
  }
4667
4555
  }
4668
4556
  this.gridview.layout(this.width, this.height);
4669
- this._onGridEvent.fire({ kind: exports.GroupChangeKind.LAYOUT_FROM_JSON });
4557
+ this._onDidLayoutfromJSON.fire();
4670
4558
  }
4671
4559
  closeAllGroups() {
4672
- return __awaiter(this, void 0, void 0, function* () {
4673
- for (const entry of this._groups.entries()) {
4674
- const [_, group] = entry;
4675
- const didCloseAll = yield group.value.model.closeAllPanels();
4676
- if (!didCloseAll) {
4677
- return false;
4678
- }
4679
- }
4680
- return true;
4681
- });
4560
+ for (const entry of this._groups.entries()) {
4561
+ const [_, group] = entry;
4562
+ group.value.model.closeAllPanels();
4563
+ }
4682
4564
  }
4683
4565
  fireMouseEvent(event) {
4684
- switch (event.kind) {
4685
- case exports.MouseEventKind.CONTEXT_MENU:
4686
- if (event.tab && event.panel) {
4687
- this._onTabContextMenu.fire({
4688
- event: event.event,
4689
- api: this._api,
4690
- panel: event.panel,
4691
- });
4692
- }
4693
- break;
4566
+ if (event.kind === exports.MouseEventKind.CONTEXT_MENU) {
4567
+ if (event.tab && event.panel) {
4568
+ this._onTabContextMenu.fire({
4569
+ event: event.event,
4570
+ api: this._api,
4571
+ panel: event.panel,
4572
+ });
4573
+ }
4694
4574
  }
4695
4575
  }
4696
4576
  addPanel(options) {
@@ -4723,14 +4603,13 @@
4723
4603
  }
4724
4604
  return panel;
4725
4605
  }
4726
- removePanel(panel) {
4727
- this.unregisterPanel(panel);
4606
+ removePanel(panel, options = { removeEmptyGroup: true }) {
4728
4607
  const group = panel.group;
4729
4608
  if (!group) {
4730
4609
  throw new Error(`cannot remove panel ${panel.id}. it's missing a group.`);
4731
4610
  }
4732
4611
  group.model.removePanel(panel);
4733
- if (group.model.size === 0) {
4612
+ if (group.model.size === 0 && options.removeEmptyGroup) {
4734
4613
  this.removeGroup(group);
4735
4614
  }
4736
4615
  }
@@ -4743,10 +4622,9 @@
4743
4622
  : {}, (_a = this.options.frameworkComponentFactory) === null || _a === void 0 ? void 0 : _a.watermark);
4744
4623
  }
4745
4624
  addEmptyGroup(options) {
4746
- var _a;
4747
4625
  const group = this.createGroup();
4748
4626
  if (options) {
4749
- const referencePanel = (_a = this._panels.get(options.referencePanel)) === null || _a === void 0 ? void 0 : _a.value;
4627
+ const referencePanel = this.panels.find((panel) => panel.id === options.referencePanel);
4750
4628
  if (!referencePanel) {
4751
4629
  throw new Error(`reference panel ${options.referencePanel} does not exist`);
4752
4630
  }
@@ -4763,25 +4641,23 @@
4763
4641
  this.doAddGroup(group);
4764
4642
  }
4765
4643
  }
4766
- removeGroup(group) {
4644
+ removeGroup(group, skipActive = false) {
4767
4645
  const panels = [...group.model.panels]; // reassign since group panels will mutate
4768
- panels.forEach((panel) => {
4769
- this.removePanel(panel);
4770
- });
4771
- if (this._groups.size === 1) {
4772
- this._activeGroup = group;
4773
- return;
4646
+ for (const panel of panels) {
4647
+ this.removePanel(panel, {
4648
+ removeEmptyGroup: false,
4649
+ });
4774
4650
  }
4775
- super.removeGroup(group);
4651
+ super.doRemoveGroup(group, { skipActive });
4776
4652
  }
4777
4653
  moveGroupOrPanel(referenceGroup, groupId, itemId, target, index) {
4778
- var _a, _b, _c;
4654
+ var _a;
4779
4655
  const sourceGroup = groupId
4780
4656
  ? (_a = this._groups.get(groupId)) === null || _a === void 0 ? void 0 : _a.value
4781
4657
  : undefined;
4782
4658
  if (!target || target === exports.Position.Center) {
4783
4659
  const groupItem = (sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(itemId)) ||
4784
- ((_b = this._panels.get(itemId)) === null || _b === void 0 ? void 0 : _b.value);
4660
+ this.panels.find((panel) => panel.id === itemId);
4785
4661
  if (!groupItem) {
4786
4662
  throw new Error(`No panel with id ${itemId}`);
4787
4663
  }
@@ -4817,7 +4693,7 @@
4817
4693
  }
4818
4694
  else {
4819
4695
  const groupItem = (sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(itemId)) ||
4820
- ((_c = this._panels.get(itemId)) === null || _c === void 0 ? void 0 : _c.value);
4696
+ this.panels.find((panel) => panel.id === itemId);
4821
4697
  if (!groupItem) {
4822
4698
  throw new Error(`No panel with id ${itemId}`);
4823
4699
  }
@@ -4831,10 +4707,7 @@
4831
4707
  const isGroupAlreadyFocused = this._activeGroup === group;
4832
4708
  super.doSetGroupActive(group, skipFocus);
4833
4709
  if (!isGroupAlreadyFocused && ((_a = this._activeGroup) === null || _a === void 0 ? void 0 : _a.model.activePanel)) {
4834
- this._onGridEvent.fire({
4835
- kind: exports.GroupChangeKind.PANEL_ACTIVE,
4836
- panel: (_b = this._activeGroup) === null || _b === void 0 ? void 0 : _b.model.activePanel,
4837
- });
4710
+ this._onDidActivePanelChange.fire((_b = this._activeGroup) === null || _b === void 0 ? void 0 : _b.model.activePanel);
4838
4711
  }
4839
4712
  }
4840
4713
  createGroup(options) {
@@ -4860,31 +4733,22 @@
4860
4733
  const disposable = new CompositeDisposable(view.model.onMove((event) => {
4861
4734
  const { groupId, itemId, target, index } = event;
4862
4735
  this.moveGroupOrPanel(view, groupId, itemId, target, index);
4736
+ }), view.model.onDidDrop((event) => {
4737
+ this._onDidDrop.fire(Object.assign(Object.assign({}, event), { api: this._api }));
4863
4738
  }), view.model.onDidGroupChange((event) => {
4864
4739
  switch (event.kind) {
4865
4740
  case exports.GroupChangeKind2.ADD_PANEL:
4866
- this._onGridEvent.fire({
4867
- kind: exports.GroupChangeKind.ADD_PANEL,
4868
- panel: event.panel,
4869
- });
4870
- break;
4871
- case exports.GroupChangeKind2.GROUP_ACTIVE:
4872
- this._onGridEvent.fire({
4873
- kind: exports.GroupChangeKind.GROUP_ACTIVE,
4874
- panel: event.panel,
4875
- });
4741
+ if (event.panel) {
4742
+ this._onDidAddPanel.fire(event.panel);
4743
+ }
4876
4744
  break;
4877
4745
  case exports.GroupChangeKind2.REMOVE_PANEL:
4878
- this._onGridEvent.fire({
4879
- kind: exports.GroupChangeKind.REMOVE_PANEL,
4880
- panel: event.panel,
4881
- });
4746
+ if (event.panel) {
4747
+ this._onDidRemovePanel.fire(event.panel);
4748
+ }
4882
4749
  break;
4883
4750
  case exports.GroupChangeKind2.PANEL_ACTIVE:
4884
- this._onGridEvent.fire({
4885
- kind: exports.GroupChangeKind.PANEL_ACTIVE,
4886
- panel: event.panel,
4887
- });
4751
+ this._onDidActivePanelChange.fire(event.panel);
4888
4752
  break;
4889
4753
  }
4890
4754
  }));
@@ -4898,44 +4762,18 @@
4898
4762
  }
4899
4763
  return view;
4900
4764
  }
4901
- dispose() {
4902
- super.dispose();
4903
- this._onGridEvent.dispose();
4904
- }
4905
- /**
4906
- * Ensure the local copy of the layout state is up-to-date
4907
- */
4908
- syncConfigs() {
4909
- const dirtyPanels = Array.from(this.dirtyPanels);
4910
- if (dirtyPanels.length === 0) ;
4911
- this.dirtyPanels.clear();
4912
- const partialPanelState = dirtyPanels
4913
- .map((panel) => this._panels.get(panel.id))
4914
- .filter((_) => !!_)
4915
- .reduce((collection, panel) => {
4916
- collection[panel.value.id] = panel.value.toJSON();
4917
- return collection;
4918
- }, {});
4919
- this.panelState = Object.assign(Object.assign({}, this.panelState), partialPanelState);
4920
- dirtyPanels
4921
- .filter((p) => this._panels.has(p.id))
4922
- .forEach((panel) => {
4923
- panel.setDirty(false);
4924
- });
4925
- }
4926
4765
  _addPanel(options) {
4927
4766
  const view = new DefaultGroupPanelView({
4928
4767
  content: this.createContentComponent(options.id, options.component),
4929
4768
  tab: this.createTabComponent(options.id, options.tabComponent),
4930
4769
  });
4931
- const panel = new DockviewGroupPanel(options.id, this._api);
4770
+ const panel = new DockviewGroupPanel(options.id, this, this._api);
4932
4771
  panel.init({
4933
4772
  view,
4934
4773
  title: options.title || options.id,
4935
4774
  suppressClosable: options === null || options === void 0 ? void 0 : options.suppressClosable,
4936
4775
  params: (options === null || options === void 0 ? void 0 : options.params) || {},
4937
4776
  });
4938
- this.registerPanel(panel);
4939
4777
  return panel;
4940
4778
  }
4941
4779
  createContentComponent(id, componentName) {
@@ -4955,10 +4793,12 @@
4955
4793
  var _a;
4956
4794
  return (_a = Array.from(this._groups.values()).find((group) => group.value.model.containsPanel(panel))) === null || _a === void 0 ? void 0 : _a.value;
4957
4795
  }
4958
- addDirtyPanel(panel) {
4959
- this.dirtyPanels.add(panel);
4960
- panel.setDirty(true);
4961
- this.debouncedDeque();
4796
+ dispose() {
4797
+ super.dispose();
4798
+ this._onDidActivePanelChange.dispose();
4799
+ this._onDidAddPanel.dispose();
4800
+ this._onDidRemovePanel.dispose();
4801
+ this._onDidLayoutfromJSON.dispose();
4962
4802
  }
4963
4803
  }
4964
4804
 
@@ -4969,6 +4809,8 @@
4969
4809
  orientation: options.orientation,
4970
4810
  styles: options.styles,
4971
4811
  });
4812
+ this._onDidLayoutfromJSON = new Emitter();
4813
+ this.onDidLayoutFromJSON = this._onDidLayoutfromJSON.event;
4972
4814
  this._options = options;
4973
4815
  if (!this.options.components) {
4974
4816
  this.options.components = {};
@@ -5076,7 +4918,7 @@
5076
4918
  this.doSetGroupActive(panel);
5077
4919
  }
5078
4920
  }
5079
- this._onGridEvent.fire({ kind: exports.GroupChangeKind.LAYOUT_FROM_JSON });
4921
+ this._onDidLayoutfromJSON.fire();
5080
4922
  }
5081
4923
  movePanel(panel, options) {
5082
4924
  var _a;
@@ -5191,6 +5033,7 @@
5191
5033
  }
5192
5034
  dispose() {
5193
5035
  super.dispose();
5036
+ this._onDidLayoutfromJSON.dispose();
5194
5037
  }
5195
5038
  }
5196
5039
 
@@ -5203,6 +5046,10 @@
5203
5046
  this.element = element;
5204
5047
  this._disposable = new MutableDisposable();
5205
5048
  this.panels = new Map();
5049
+ this._onDidAddView = new Emitter();
5050
+ this.onDidAddView = this._onDidAddView.event;
5051
+ this._onDidRemoveView = new Emitter();
5052
+ this.onDidRemoveView = this._onDidRemoveView.event;
5206
5053
  this._onDidLayoutChange = new Emitter();
5207
5054
  this.onDidLayoutChange = this._onDidLayoutChange.event;
5208
5055
  this._options = options;
@@ -5213,7 +5060,7 @@
5213
5060
  options.frameworkComponents = {};
5214
5061
  }
5215
5062
  this.splitview = new Splitview(this.element, options);
5216
- this.addDisposables(this._disposable);
5063
+ this.addDisposables(this._disposable, this._onDidAddView, this._onDidRemoveView, this._onDidLayoutChange);
5217
5064
  }
5218
5065
  get options() {
5219
5066
  return this._options;
@@ -5228,7 +5075,7 @@
5228
5075
  this._splitview = value;
5229
5076
  this._disposable.value = new CompositeDisposable(this._splitview.onDidSashEnd(() => {
5230
5077
  this._onDidLayoutChange.fire(undefined);
5231
- }));
5078
+ }), this._splitview.onDidAddView((e) => this._onDidAddView.fire(e)), this._splitview.onDidRemoveView((e) => this._onDidRemoveView.fire(e)));
5232
5079
  }
5233
5080
  get minimumSize() {
5234
5081
  return this.splitview.minimumSize;
@@ -5402,6 +5249,10 @@
5402
5249
  });
5403
5250
  panel.orientation = orientation;
5404
5251
  this.doAddView(panel);
5252
+ setTimeout(() => {
5253
+ // the original onDidAddView events are missed since they are fired before we can subcribe to them
5254
+ this._onDidAddView.fire(panel);
5255
+ }, 0);
5405
5256
  return { size: view.size, view: panel };
5406
5257
  }),
5407
5258
  },
@@ -5427,45 +5278,11 @@
5427
5278
  value.dispose();
5428
5279
  });
5429
5280
  this.panels.clear();
5281
+ this.splitview.dispose();
5430
5282
  super.dispose();
5431
5283
  }
5432
5284
  }
5433
5285
 
5434
- class DragHandler extends CompositeDisposable {
5435
- constructor(el) {
5436
- super();
5437
- this.el = el;
5438
- this.iframes = [];
5439
- this._onDragStart = new Emitter();
5440
- this.onDragStart = this._onDragStart.event;
5441
- this.configure();
5442
- }
5443
- configure() {
5444
- this.addDisposables(addDisposableListener(this.el, 'dragstart', (event) => {
5445
- var _a;
5446
- this.iframes = [
5447
- ...getElementsByTagName('iframe'),
5448
- ...getElementsByTagName('webview'),
5449
- ];
5450
- for (const iframe of this.iframes) {
5451
- iframe.style.pointerEvents = 'none';
5452
- }
5453
- this.el.classList.add('dragged');
5454
- setTimeout(() => this.el.classList.remove('dragged'), 0);
5455
- (_a = this.disposable) === null || _a === void 0 ? void 0 : _a.dispose();
5456
- this.disposable = this.getData();
5457
- }), addDisposableListener(this.el, 'dragend', (ev) => {
5458
- var _a;
5459
- for (const iframe of this.iframes) {
5460
- iframe.style.pointerEvents = 'auto';
5461
- }
5462
- this.iframes = [];
5463
- (_a = this.disposable) === null || _a === void 0 ? void 0 : _a.dispose();
5464
- this.disposable = undefined;
5465
- }));
5466
- }
5467
- }
5468
-
5469
5286
  class SplitviewPanelApiImpl extends PanelApiImpl {
5470
5287
  //
5471
5288
  constructor(id) {
@@ -5480,6 +5297,7 @@
5480
5297
  //
5481
5298
  this._onDidSizeChange = new Emitter();
5482
5299
  this.onDidSizeChange = this._onDidSizeChange.event;
5300
+ this.addDisposables(this._onDidConstraintsChangeInternal, this._onDidConstraintsChange, this._onDidSizeChange);
5483
5301
  }
5484
5302
  setConstraints(value) {
5485
5303
  this._onDidConstraintsChangeInternal.fire(value);
@@ -5487,11 +5305,6 @@
5487
5305
  setSize(event) {
5488
5306
  this._onDidSizeChange.fire(event);
5489
5307
  }
5490
- dispose() {
5491
- super.dispose();
5492
- this._onDidConstraintsChange.dispose();
5493
- this._onDidSizeChange.dispose();
5494
- }
5495
5308
  }
5496
5309
 
5497
5310
  class PaneviewPanelApiImpl extends SplitviewPanelApiImpl {
@@ -5505,6 +5318,7 @@
5505
5318
  this.onMouseEnter = this._onMouseEnter.event;
5506
5319
  this._onMouseLeave = new Emitter({});
5507
5320
  this.onMouseLeave = this._onMouseLeave.event;
5321
+ this.addDisposables(this._onDidExpansionChange, this._onMouseEnter, this._onMouseLeave);
5508
5322
  }
5509
5323
  set pane(pane) {
5510
5324
  this._pane = pane;
@@ -5520,7 +5334,7 @@
5520
5334
  }
5521
5335
 
5522
5336
  class PaneviewPanel extends BasePanelView {
5523
- constructor(id, component, headerComponent, orientation, isExpanded) {
5337
+ constructor(id, component, headerComponent, orientation, isExpanded, isHeaderVisible) {
5524
5338
  super(id, component, new PaneviewPanelApiImpl(id));
5525
5339
  this.headerComponent = headerComponent;
5526
5340
  this._onDidChangeExpansionState = new Emitter({ replay: true });
@@ -5536,6 +5350,7 @@
5536
5350
  this.expandedSize = 0;
5537
5351
  this.api.pane = this; // TODO cannot use 'this' before 'super'
5538
5352
  this._isExpanded = isExpanded;
5353
+ this._headerVisible = isHeaderVisible;
5539
5354
  this._onDidChangeExpansionState.fire(this.isExpanded()); // initialize value
5540
5355
  this._orientation = orientation;
5541
5356
  this.element.classList.add('pane');
@@ -5603,6 +5418,13 @@
5603
5418
  this._maximumBodySize =
5604
5419
  typeof value === 'number' ? value : Number.POSITIVE_INFINITY;
5605
5420
  }
5421
+ get headerVisible() {
5422
+ return this._headerVisible;
5423
+ }
5424
+ set headerVisible(value) {
5425
+ this._headerVisible = value;
5426
+ this.header.style.display = value ? '' : 'none';
5427
+ }
5606
5428
  setVisible(isVisible) {
5607
5429
  this.api._onDidVisibilityChange.fire({ isVisible });
5608
5430
  }
@@ -5665,7 +5487,7 @@
5665
5487
  }
5666
5488
  }
5667
5489
  toJSON() {
5668
- const params = this.params;
5490
+ const params = this._params;
5669
5491
  return Object.assign(Object.assign({}, super.toJSON()), { headerComponent: this.headerComponent, title: params.title });
5670
5492
  }
5671
5493
  renderOnce() {
@@ -5700,7 +5522,7 @@
5700
5522
 
5701
5523
  class DraggablePaneviewPanel extends PaneviewPanel {
5702
5524
  constructor(id, component, headerComponent, orientation, isExpanded, disableDnd) {
5703
- super(id, component, headerComponent, orientation, isExpanded);
5525
+ super(id, component, headerComponent, orientation, isExpanded, true);
5704
5526
  this._onDidDrop = new Emitter();
5705
5527
  this.onDidDrop = this._onDidDrop.event;
5706
5528
  if (!disableDnd) {
@@ -5734,36 +5556,39 @@
5734
5556
  },
5735
5557
  });
5736
5558
  this.addDisposables(this._onDidDrop, this.handler, this.target, this.target.onDrop((event) => {
5737
- const data = getPaneData();
5738
- if (!data) {
5739
- this._onDidDrop.fire(Object.assign(Object.assign({}, event), { panel: this, getData: () => getPaneData() }));
5740
- return;
5741
- }
5742
- const containerApi = this.params
5743
- .containerApi;
5744
- const panelId = data.paneId;
5745
- const existingPanel = containerApi.getPanel(panelId);
5746
- if (!existingPanel) {
5747
- this._onDidDrop.fire(Object.assign(Object.assign({}, event), { panel: this, getData: () => getPaneData() }));
5748
- return;
5749
- }
5750
- const allPanels = containerApi.getPanels();
5751
- const fromIndex = allPanels.indexOf(existingPanel);
5752
- let toIndex = containerApi.getPanels().indexOf(this);
5753
- if (event.position === exports.Position.Left ||
5754
- event.position === exports.Position.Top) {
5755
- toIndex = Math.max(0, toIndex - 1);
5756
- }
5757
- if (event.position === exports.Position.Right ||
5758
- event.position === exports.Position.Bottom) {
5759
- if (fromIndex > toIndex) {
5760
- toIndex++;
5761
- }
5762
- toIndex = Math.min(allPanels.length - 1, toIndex);
5763
- }
5764
- containerApi.movePanel(fromIndex, toIndex);
5559
+ this.onDrop(event);
5765
5560
  }));
5766
5561
  }
5562
+ onDrop(event) {
5563
+ const data = getPaneData();
5564
+ if (!data) {
5565
+ this._onDidDrop.fire(Object.assign(Object.assign({}, event), { panel: this, getData: () => getPaneData() }));
5566
+ return;
5567
+ }
5568
+ const containerApi = this._params
5569
+ .containerApi;
5570
+ const panelId = data.paneId;
5571
+ const existingPanel = containerApi.getPanel(panelId);
5572
+ if (!existingPanel) {
5573
+ this._onDidDrop.fire(Object.assign(Object.assign({}, event), { panel: this, getData: () => getPaneData() }));
5574
+ return;
5575
+ }
5576
+ const allPanels = containerApi.getPanels();
5577
+ const fromIndex = allPanels.indexOf(existingPanel);
5578
+ let toIndex = containerApi.getPanels().indexOf(this);
5579
+ if (event.position === exports.Position.Left ||
5580
+ event.position === exports.Position.Top) {
5581
+ toIndex = Math.max(0, toIndex - 1);
5582
+ }
5583
+ if (event.position === exports.Position.Right ||
5584
+ event.position === exports.Position.Bottom) {
5585
+ if (fromIndex > toIndex) {
5586
+ toIndex++;
5587
+ }
5588
+ toIndex = Math.min(allPanels.length - 1, toIndex);
5589
+ }
5590
+ containerApi.movePanel(fromIndex, toIndex);
5591
+ }
5767
5592
  }
5768
5593
 
5769
5594
  class DefaultHeader extends CompositeDisposable {
@@ -5823,6 +5648,11 @@
5823
5648
  this.onDidLayoutChange = this._onDidLayoutChange.event;
5824
5649
  this._onDidDrop = new Emitter();
5825
5650
  this.onDidDrop = this._onDidDrop.event;
5651
+ this._onDidAddView = new Emitter();
5652
+ this.onDidAddView = this._onDidAddView.event;
5653
+ this._onDidRemoveView = new Emitter();
5654
+ this.onDidRemoveView = this._onDidRemoveView.event;
5655
+ this.addDisposables(this._onDidLayoutChange, this._onDidDrop, this._onDidAddView, this._onDidRemoveView);
5826
5656
  this._options = options;
5827
5657
  if (!options.components) {
5828
5658
  options.components = {};
@@ -5836,17 +5666,11 @@
5836
5666
  });
5837
5667
  this.addDisposables(this._disposable);
5838
5668
  }
5839
- get onDidAddView() {
5840
- return this._paneview.onDidAddView;
5841
- }
5842
- get onDidRemoveView() {
5843
- return this._paneview.onDidRemoveView;
5844
- }
5845
5669
  set paneview(value) {
5846
5670
  this._paneview = value;
5847
- this._disposable.value = new CompositeDisposable(this.paneview.onDidChange(() => {
5671
+ this._disposable.value = new CompositeDisposable(this._paneview.onDidChange(() => {
5848
5672
  this._onDidLayoutChange.fire(undefined);
5849
- }));
5673
+ }), this._paneview.onDidAddView((e) => this._onDidAddView.fire(e)), this._paneview.onDidRemoveView((e) => this._onDidRemoveView.fire(e)));
5850
5674
  }
5851
5675
  get paneview() {
5852
5676
  return this._paneview;
@@ -6026,6 +5850,10 @@
6026
5850
  });
6027
5851
  panel.orientation = this.paneview.orientation;
6028
5852
  });
5853
+ setTimeout(() => {
5854
+ // the original onDidAddView events are missed since they are fired before we can subcribe to them
5855
+ this._onDidAddView.fire(panel);
5856
+ }, 0);
6029
5857
  return { size: view.size, view: panel };
6030
5858
  }),
6031
5859
  },
@@ -6040,6 +5868,10 @@
6040
5868
  queue.forEach((f) => f());
6041
5869
  }
6042
5870
  }
5871
+ dispose() {
5872
+ super.dispose();
5873
+ this.paneview.dispose();
5874
+ }
6043
5875
  }
6044
5876
 
6045
5877
  class SplitviewPanel extends BasePanelView {
@@ -6052,12 +5884,14 @@
6052
5884
  this._snap = false;
6053
5885
  this._onDidChange = new Emitter();
6054
5886
  this.onDidChange = this._onDidChange.event;
6055
- this.addDisposables(this.api.onVisibilityChange((event) => {
5887
+ this.addDisposables(this._onDidChange, this.api.onVisibilityChange((event) => {
6056
5888
  const { isVisible } = event;
6057
- const { containerApi } = this.params;
5889
+ const { containerApi } = this
5890
+ ._params;
6058
5891
  containerApi.setVisible(this, isVisible);
6059
5892
  }), this.api.onActiveChange(() => {
6060
- const { containerApi } = this.params;
5893
+ const { containerApi } = this
5894
+ ._params;
6061
5895
  containerApi.setActive(this);
6062
5896
  }), this.api.onDidConstraintsChangeInternal((event) => {
6063
5897
  if (typeof event.minimumSize === 'number' ||
@@ -6200,14 +6034,13 @@
6200
6034
  if (this.disposed) {
6201
6035
  throw new Error('invalid operation: resource is already disposed');
6202
6036
  }
6203
- // TODO use a better check for isReactFunctionalComponent
6204
6037
  if (typeof this.component !== 'function') {
6205
6038
  /**
6206
6039
  * we know this isn't a React.FunctionComponent so throw an error here.
6207
6040
  * if we do not intercept this the React library will throw a very obsure error
6208
6041
  * for the same reason, at least at this point we will emit a sensible stacktrace.
6209
6042
  */
6210
- throw new Error('invalid operation: only functional components are supported');
6043
+ throw new Error('Invalid Operation. dockview only supports React Functional Components.');
6211
6044
  }
6212
6045
  const bridgeComponent = React__namespace.createElement(React__namespace.forwardRef(ReactComponentBridge), {
6213
6046
  component: this
@@ -6271,16 +6104,14 @@
6271
6104
  this._onDidBlur = new Emitter();
6272
6105
  this.onDidBlur = this._onDidBlur.event;
6273
6106
  this._element = document.createElement('div');
6274
- this._element.style.height = '100%';
6275
- this._element.style.width = '100%';
6107
+ this._element.className = 'dockview-react-part';
6276
6108
  // this.hostedContainer = new HostedContainer({
6277
6109
  // id,
6278
6110
  // });
6279
6111
  // this.hostedContainer.onDidFocus(() => this._onDidFocus.fire());
6280
6112
  // this.hostedContainer.onDidBlur(() => this._onDidBlur.fire());
6281
6113
  this._actionsElement = document.createElement('div');
6282
- this._actionsElement.style.height = '100%';
6283
- this._actionsElement.style.width = '100%';
6114
+ this._actionsElement.className = 'dockview-react-part';
6284
6115
  }
6285
6116
  get element() {
6286
6117
  return this._element;
@@ -6328,6 +6159,8 @@
6328
6159
  }
6329
6160
  dispose() {
6330
6161
  var _a, _b;
6162
+ this._onDidFocus.dispose();
6163
+ this._onDidBlur.dispose();
6331
6164
  (_a = this.part) === null || _a === void 0 ? void 0 : _a.dispose();
6332
6165
  // this.hostedContainer?.dispose();
6333
6166
  (_b = this.actionsPart) === null || _b === void 0 ? void 0 : _b.dispose();
@@ -6340,6 +6173,7 @@
6340
6173
  this.component = component;
6341
6174
  this.reactPortalStore = reactPortalStore;
6342
6175
  this._element = document.createElement('div');
6176
+ this._element.className = 'dockview-react-part';
6343
6177
  }
6344
6178
  get element() {
6345
6179
  return this._element;
@@ -6384,7 +6218,6 @@
6384
6218
  const panelId = panelData.id;
6385
6219
  const params = panelData.params;
6386
6220
  const title = panelData.title;
6387
- const state = panelData.state;
6388
6221
  const suppressClosable = panelData.suppressClosable;
6389
6222
  const viewData = panelData.view;
6390
6223
  const view = new DefaultGroupPanelView({
@@ -6393,13 +6226,12 @@
6393
6226
  ? 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)
6394
6227
  : new DefaultTab(),
6395
6228
  });
6396
- const panel = new DockviewGroupPanel(panelId, new DockviewApi(this.layout));
6229
+ const panel = new DockviewGroupPanel(panelId, this.layout, new DockviewApi(this.layout));
6397
6230
  panel.init({
6398
6231
  view,
6399
6232
  title,
6400
6233
  suppressClosable,
6401
6234
  params: params || {},
6402
- state: state || {},
6403
6235
  });
6404
6236
  return panel;
6405
6237
  }
@@ -6414,8 +6246,7 @@
6414
6246
  value: undefined,
6415
6247
  };
6416
6248
  this._element = document.createElement('div');
6417
- this._element.style.height = '100%';
6418
- this._element.style.width = '100%';
6249
+ this._element.className = 'dockview-react-part';
6419
6250
  }
6420
6251
  get element() {
6421
6252
  return this._element;
@@ -6513,12 +6344,16 @@
6513
6344
  frameworkTabComponents: props.tabComponents,
6514
6345
  tabHeight: props.tabHeight,
6515
6346
  debug: props.debug,
6516
- enableExternalDragEvents: props.enableExternalDragEvents,
6517
6347
  watermarkFrameworkComponent: props.watermarkComponent,
6518
6348
  styles: props.hideBorders
6519
6349
  ? { separatorBorder: 'transparent' }
6520
6350
  : undefined,
6521
6351
  });
6352
+ const disposable = dockview.onDidDrop((event) => {
6353
+ if (props.onDidDrop) {
6354
+ props.onDidDrop(event);
6355
+ }
6356
+ });
6522
6357
  (_a = domRef.current) === null || _a === void 0 ? void 0 : _a.appendChild(dockview.element);
6523
6358
  dockview.deserializer = new ReactPanelDeserialzier(dockview);
6524
6359
  const { clientWidth, clientHeight } = domRef.current;
@@ -6528,7 +6363,9 @@
6528
6363
  }
6529
6364
  dockviewRef.current = dockview;
6530
6365
  return () => {
6366
+ disposable.dispose();
6531
6367
  dockview.dispose();
6368
+ element.remove();
6532
6369
  };
6533
6370
  }, []);
6534
6371
  React__namespace.useEffect(() => {
@@ -6539,6 +6376,22 @@
6539
6376
  frameworkComponents: props.components,
6540
6377
  });
6541
6378
  }, [props.components]);
6379
+ React__namespace.useEffect(() => {
6380
+ if (!dockviewRef.current) {
6381
+ return;
6382
+ }
6383
+ dockviewRef.current.updateOptions({
6384
+ watermarkFrameworkComponent: props.watermarkComponent,
6385
+ });
6386
+ }, [props.watermarkComponent]);
6387
+ React__namespace.useEffect(() => {
6388
+ if (!dockviewRef.current) {
6389
+ return;
6390
+ }
6391
+ dockviewRef.current.updateOptions({
6392
+ showDndOverlay: props.showDndOverlay,
6393
+ });
6394
+ }, [props.showDndOverlay]);
6542
6395
  React__namespace.useEffect(() => {
6543
6396
  if (!dockviewRef.current) {
6544
6397
  return;
@@ -6627,9 +6480,9 @@
6627
6480
  getComponent() {
6628
6481
  var _a;
6629
6482
  return new ReactPart(this.element, this.reactPortalStore, this.reactComponent, {
6630
- params: ((_a = this.params) === null || _a === void 0 ? void 0 : _a.params) || {},
6483
+ params: ((_a = this._params) === null || _a === void 0 ? void 0 : _a.params) || {},
6631
6484
  api: this.api,
6632
- containerApi: this.params
6485
+ containerApi: this._params
6633
6486
  .containerApi,
6634
6487
  });
6635
6488
  }
@@ -6666,7 +6519,9 @@
6666
6519
  });
6667
6520
  },
6668
6521
  },
6669
- proportionalLayout: props.proportionalLayout,
6522
+ proportionalLayout: typeof props.proportionalLayout === 'boolean'
6523
+ ? props.proportionalLayout
6524
+ : true,
6670
6525
  styles: props.hideBorders
6671
6526
  ? { separatorBorder: 'transparent' }
6672
6527
  : undefined,
@@ -6702,9 +6557,9 @@
6702
6557
  getComponent() {
6703
6558
  var _a;
6704
6559
  return new ReactPart(this.element, this.reactPortalStore, this.reactComponent, {
6705
- params: ((_a = this.params) === null || _a === void 0 ? void 0 : _a.params) || {},
6560
+ params: ((_a = this._params) === null || _a === void 0 ? void 0 : _a.params) || {},
6706
6561
  api: this.api,
6707
- containerApi: this.params
6562
+ containerApi: this._params
6708
6563
  .containerApi,
6709
6564
  });
6710
6565
  }
@@ -6734,7 +6589,9 @@
6734
6589
  var _a;
6735
6590
  const element = document.createElement('div');
6736
6591
  const gridview = new GridviewComponent(element, {
6737
- proportionalLayout: !!props.proportionalLayout,
6592
+ proportionalLayout: typeof props.proportionalLayout === 'boolean'
6593
+ ? props.proportionalLayout
6594
+ : true,
6738
6595
  orientation: props.orientation,
6739
6596
  frameworkComponents: props.components,
6740
6597
  frameworkComponentFactory: {
@@ -6757,6 +6614,7 @@
6757
6614
  gridviewRef.current = gridview;
6758
6615
  return () => {
6759
6616
  gridview.dispose();
6617
+ element.remove();
6760
6618
  };
6761
6619
  }, []);
6762
6620
  React__namespace.useEffect(() => {
@@ -6893,14 +6751,11 @@
6893
6751
  PaneviewReact.displayName = 'PaneviewComponent';
6894
6752
 
6895
6753
  exports.BaseGrid = BaseGrid;
6896
- exports.CompositeDisposable = CompositeDisposable;
6897
6754
  exports.ContentContainer = ContentContainer;
6898
- exports.DATA_KEY = DATA_KEY;
6899
6755
  exports.DockviewApi = DockviewApi;
6900
6756
  exports.DockviewComponent = DockviewComponent;
6901
6757
  exports.DockviewComponents = DockviewComponents;
6902
6758
  exports.DockviewReact = DockviewReact;
6903
- exports.Emitter = Emitter;
6904
6759
  exports.Gridview = Gridview;
6905
6760
  exports.GridviewApi = GridviewApi;
6906
6761
  exports.GridviewComponent = GridviewComponent;
@@ -6908,7 +6763,6 @@
6908
6763
  exports.GridviewReact = GridviewReact;
6909
6764
  exports.Groupview = Groupview;
6910
6765
  exports.LocalSelectionTransfer = LocalSelectionTransfer;
6911
- exports.MutableDisposable = MutableDisposable;
6912
6766
  exports.PaneFramework = PaneFramework;
6913
6767
  exports.PaneTransfer = PaneTransfer;
6914
6768
  exports.PanelTransfer = PanelTransfer;
@@ -6927,10 +6781,6 @@
6927
6781
  exports.SplitviewPanel = SplitviewPanel;
6928
6782
  exports.SplitviewReact = SplitviewReact;
6929
6783
  exports.Tab = Tab$1;
6930
- exports.TickDelayedEvent = TickDelayedEvent;
6931
- exports.addDisposableListener = addDisposableListener;
6932
- exports.addDisposableWindowListener = addDisposableWindowListener;
6933
- exports.extractData = extractData;
6934
6784
  exports.getDirectionOrientation = getDirectionOrientation;
6935
6785
  exports.getGridLocation = getGridLocation;
6936
6786
  exports.getLocationOrientation = getLocationOrientation;
@@ -6938,11 +6788,8 @@
6938
6788
  exports.getPanelData = getPanelData;
6939
6789
  exports.getRelativeLocation = getRelativeLocation;
6940
6790
  exports.indexInParent = indexInParent;
6941
- exports.isCustomDragEvent = isCustomDragEvent;
6942
6791
  exports.isGridBranchNode = isGridBranchNode;
6943
- exports.isPanelTransferEvent = isPanelTransferEvent;
6944
6792
  exports.isReactElement = isReactElement;
6945
- exports.isTabDragEvent = isTabDragEvent;
6946
6793
  exports.orthogonal = orthogonal;
6947
6794
  exports.toTarget = toTarget;
6948
6795
  exports.usePortalsLifecycle = usePortalsLifecycle;