dockview-core 1.8.4 → 1.8.5

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 (334) hide show
  1. package/README.md +51 -51
  2. package/dist/cjs/api/component.api.d.ts +455 -152
  3. package/dist/cjs/api/component.api.d.ts.map +1 -1
  4. package/dist/cjs/api/component.api.js +895 -592
  5. package/dist/cjs/api/component.api.js.map +1 -1
  6. package/dist/cjs/api/dockviewGroupPanelApi.d.ts +29 -29
  7. package/dist/cjs/api/dockviewGroupPanelApi.js +53 -53
  8. package/dist/cjs/api/dockviewPanelApi.d.ts +47 -47
  9. package/dist/cjs/api/dockviewPanelApi.js +88 -88
  10. package/dist/cjs/api/gridviewPanelApi.d.ts +37 -37
  11. package/dist/cjs/api/gridviewPanelApi.js +47 -47
  12. package/dist/cjs/api/panelApi.d.ts +88 -88
  13. package/dist/cjs/api/panelApi.js +135 -135
  14. package/dist/cjs/api/paneviewPanelApi.d.ts +26 -26
  15. package/dist/cjs/api/paneviewPanelApi.js +57 -57
  16. package/dist/cjs/api/splitviewPanelApi.d.ts +32 -32
  17. package/dist/cjs/api/splitviewPanelApi.js +47 -47
  18. package/dist/cjs/array.d.ts +13 -13
  19. package/dist/cjs/array.js +67 -67
  20. package/dist/cjs/dnd/abstractDragHandler.d.ts +12 -12
  21. package/dist/cjs/dnd/abstractDragHandler.js +141 -141
  22. package/dist/cjs/dnd/dataTransfer.d.ts +30 -31
  23. package/dist/cjs/dnd/dataTransfer.d.ts.map +1 -1
  24. package/dist/cjs/dnd/dataTransfer.js +99 -100
  25. package/dist/cjs/dnd/dataTransfer.js.map +1 -1
  26. package/dist/cjs/dnd/dnd.d.ts +27 -27
  27. package/dist/cjs/dnd/dnd.js +59 -59
  28. package/dist/cjs/dnd/droptarget.d.ts +53 -53
  29. package/dist/cjs/dnd/droptarget.js +304 -304
  30. package/dist/cjs/dnd/droptarget.js.map +1 -1
  31. package/dist/cjs/dnd/ghost.d.ts +1 -1
  32. package/dist/cjs/dnd/ghost.js +15 -15
  33. package/dist/cjs/dnd/groupDragHandler.d.ts +12 -12
  34. package/dist/cjs/dnd/groupDragHandler.js +77 -77
  35. package/dist/cjs/dnd/overlay.d.ts +43 -43
  36. package/dist/cjs/dnd/overlay.d.ts.map +1 -1
  37. package/dist/cjs/dnd/overlay.js +412 -412
  38. package/dist/cjs/dnd/overlay.js.map +1 -1
  39. package/dist/cjs/dockview/components/panel/content.d.ts +30 -30
  40. package/dist/cjs/dockview/components/panel/content.js +100 -100
  41. package/dist/cjs/dockview/components/tab/defaultTab.d.ts +21 -21
  42. package/dist/cjs/dockview/components/tab/defaultTab.js +105 -105
  43. package/dist/cjs/dockview/components/tab/tab.d.ts +34 -34
  44. package/dist/cjs/dockview/components/tab/tab.js +120 -120
  45. package/dist/cjs/dockview/components/titlebar/tabsContainer.d.ts +81 -81
  46. package/dist/cjs/dockview/components/titlebar/tabsContainer.js +325 -325
  47. package/dist/cjs/dockview/components/titlebar/voidContainer.d.ts +17 -17
  48. package/dist/cjs/dockview/components/titlebar/voidContainer.js +77 -77
  49. package/dist/cjs/dockview/components/watermark/watermark.d.ts +18 -18
  50. package/dist/cjs/dockview/components/watermark/watermark.js +87 -87
  51. package/dist/cjs/dockview/deserializer.d.ts +12 -12
  52. package/dist/cjs/dockview/deserializer.js +33 -33
  53. package/dist/cjs/dockview/deserializer.js.map +1 -1
  54. package/dist/cjs/dockview/dockviewComponent.d.ts +159 -159
  55. package/dist/cjs/dockview/dockviewComponent.d.ts.map +1 -1
  56. package/dist/cjs/dockview/dockviewComponent.js +1170 -1156
  57. package/dist/cjs/dockview/dockviewComponent.js.map +1 -1
  58. package/dist/cjs/dockview/dockviewFloatingGroupPanel.d.ts +23 -23
  59. package/dist/cjs/dockview/dockviewFloatingGroupPanel.js +34 -34
  60. package/dist/cjs/dockview/dockviewGroupPanel.d.ts +30 -30
  61. package/dist/cjs/dockview/dockviewGroupPanel.js +97 -97
  62. package/dist/cjs/dockview/dockviewGroupPanelModel.d.ts +185 -185
  63. package/dist/cjs/dockview/dockviewGroupPanelModel.js +632 -631
  64. package/dist/cjs/dockview/dockviewGroupPanelModel.js.map +1 -1
  65. package/dist/cjs/dockview/dockviewPanel.d.ts +41 -41
  66. package/dist/cjs/dockview/dockviewPanel.js +172 -171
  67. package/dist/cjs/dockview/dockviewPanel.js.map +1 -1
  68. package/dist/cjs/dockview/dockviewPanelModel.d.ts +35 -35
  69. package/dist/cjs/dockview/dockviewPanelModel.js +98 -98
  70. package/dist/cjs/dockview/dockviewPanelModel.js.map +1 -1
  71. package/dist/cjs/dockview/options.d.ts +133 -136
  72. package/dist/cjs/dockview/options.d.ts.map +1 -1
  73. package/dist/cjs/dockview/options.js +31 -31
  74. package/dist/cjs/dockview/types.d.ts +63 -63
  75. package/dist/cjs/dockview/types.js +10 -10
  76. package/dist/cjs/dockview/types.js.map +1 -1
  77. package/dist/cjs/dom.d.ts +16 -16
  78. package/dist/cjs/dom.js +197 -197
  79. package/dist/cjs/events.d.ts +47 -47
  80. package/dist/cjs/events.js +216 -216
  81. package/dist/cjs/events.js.map +1 -1
  82. package/dist/cjs/gridview/baseComponentGridview.d.ts +88 -87
  83. package/dist/cjs/gridview/baseComponentGridview.d.ts.map +1 -1
  84. package/dist/cjs/gridview/baseComponentGridview.js +270 -270
  85. package/dist/cjs/gridview/baseComponentGridview.js.map +1 -1
  86. package/dist/cjs/gridview/basePanelView.d.ts +40 -40
  87. package/dist/cjs/gridview/basePanelView.js +156 -156
  88. package/dist/cjs/gridview/branchNode.d.ts +49 -49
  89. package/dist/cjs/gridview/branchNode.js +343 -343
  90. package/dist/cjs/gridview/gridview.d.ts +133 -133
  91. package/dist/cjs/gridview/gridview.js +547 -547
  92. package/dist/cjs/gridview/gridviewComponent.d.ts +80 -80
  93. package/dist/cjs/gridview/gridviewComponent.d.ts.map +1 -1
  94. package/dist/cjs/gridview/gridviewComponent.js +362 -360
  95. package/dist/cjs/gridview/gridviewComponent.js.map +1 -1
  96. package/dist/cjs/gridview/gridviewPanel.d.ts +65 -65
  97. package/dist/cjs/gridview/gridviewPanel.js +214 -214
  98. package/dist/cjs/gridview/leafNode.d.ts +34 -34
  99. package/dist/cjs/gridview/leafNode.js +170 -170
  100. package/dist/cjs/gridview/leafNode.js.map +1 -1
  101. package/dist/cjs/gridview/options.d.ts +17 -18
  102. package/dist/cjs/gridview/options.d.ts.map +1 -1
  103. package/dist/cjs/gridview/options.js +2 -2
  104. package/dist/cjs/gridview/types.d.ts +3 -3
  105. package/dist/cjs/gridview/types.js +2 -2
  106. package/dist/cjs/index.d.ts +42 -42
  107. package/dist/cjs/index.js +61 -61
  108. package/dist/cjs/lifecycle.d.ts +23 -23
  109. package/dist/cjs/lifecycle.js +65 -65
  110. package/dist/cjs/lifecycle.js.map +1 -1
  111. package/dist/cjs/math.d.ts +5 -5
  112. package/dist/cjs/math.js +34 -34
  113. package/dist/cjs/panel/componentFactory.d.ts +11 -10
  114. package/dist/cjs/panel/componentFactory.d.ts.map +1 -1
  115. package/dist/cjs/panel/componentFactory.js +30 -30
  116. package/dist/cjs/panel/componentFactory.js.map +1 -1
  117. package/dist/cjs/panel/types.d.ts +33 -33
  118. package/dist/cjs/panel/types.js +2 -2
  119. package/dist/cjs/paneview/defaultPaneviewHeader.d.ts +21 -21
  120. package/dist/cjs/paneview/defaultPaneviewHeader.js +90 -90
  121. package/dist/cjs/paneview/draggablePaneviewPanel.d.ts +21 -21
  122. package/dist/cjs/paneview/draggablePaneviewPanel.js +131 -131
  123. package/dist/cjs/paneview/options.d.ts +25 -28
  124. package/dist/cjs/paneview/options.d.ts.map +1 -1
  125. package/dist/cjs/paneview/options.js +2 -2
  126. package/dist/cjs/paneview/paneview.d.ts +40 -40
  127. package/dist/cjs/paneview/paneview.d.ts.map +1 -1
  128. package/dist/cjs/paneview/paneview.js +200 -201
  129. package/dist/cjs/paneview/paneview.js.map +1 -1
  130. package/dist/cjs/paneview/paneviewComponent.d.ts +128 -128
  131. package/dist/cjs/paneview/paneviewComponent.js +400 -397
  132. package/dist/cjs/paneview/paneviewComponent.js.map +1 -1
  133. package/dist/cjs/paneview/paneviewPanel.d.ts +92 -92
  134. package/dist/cjs/paneview/paneviewPanel.d.ts.map +1 -1
  135. package/dist/cjs/paneview/paneviewPanel.js +275 -275
  136. package/dist/cjs/resizable.d.ts +10 -7
  137. package/dist/cjs/resizable.d.ts.map +1 -1
  138. package/dist/cjs/resizable.js +79 -64
  139. package/dist/cjs/resizable.js.map +1 -1
  140. package/dist/cjs/splitview/options.d.ts +26 -27
  141. package/dist/cjs/splitview/options.d.ts.map +1 -1
  142. package/dist/cjs/splitview/options.js +2 -2
  143. package/dist/cjs/splitview/splitview.d.ts +128 -128
  144. package/dist/cjs/splitview/splitview.js +936 -936
  145. package/dist/cjs/splitview/splitview.js.map +1 -1
  146. package/dist/cjs/splitview/splitviewComponent.d.ts +101 -101
  147. package/dist/cjs/splitview/splitviewComponent.js +395 -392
  148. package/dist/cjs/splitview/splitviewComponent.js.map +1 -1
  149. package/dist/cjs/splitview/splitviewPanel.d.ts +45 -45
  150. package/dist/cjs/splitview/splitviewPanel.d.ts.map +1 -1
  151. package/dist/cjs/splitview/splitviewPanel.js +179 -179
  152. package/dist/cjs/splitview/splitviewPanel.js.map +1 -1
  153. package/dist/cjs/splitview/viewItem.d.ts +25 -25
  154. package/dist/cjs/splitview/viewItem.js +119 -119
  155. package/dist/cjs/svg.d.ts +3 -3
  156. package/dist/cjs/svg.js +43 -43
  157. package/dist/cjs/types.d.ts +2 -2
  158. package/dist/cjs/types.js +2 -2
  159. package/dist/dockview-core.amd.js +7650 -7316
  160. package/dist/dockview-core.amd.js.map +1 -1
  161. package/dist/dockview-core.amd.min.js +2 -2
  162. package/dist/dockview-core.amd.min.js.map +1 -1
  163. package/dist/dockview-core.amd.min.noStyle.js +2 -2
  164. package/dist/dockview-core.amd.min.noStyle.js.map +1 -1
  165. package/dist/dockview-core.amd.noStyle.js +7601 -7267
  166. package/dist/dockview-core.amd.noStyle.js.map +1 -1
  167. package/dist/dockview-core.cjs.js +7650 -7316
  168. package/dist/dockview-core.cjs.js.map +1 -1
  169. package/dist/dockview-core.esm.js +7650 -7316
  170. package/dist/dockview-core.esm.js.map +1 -1
  171. package/dist/dockview-core.esm.min.js +2 -2
  172. package/dist/dockview-core.esm.min.js.map +1 -1
  173. package/dist/dockview-core.js +7650 -7316
  174. package/dist/dockview-core.js.map +1 -1
  175. package/dist/dockview-core.min.js +2 -2
  176. package/dist/dockview-core.min.js.map +1 -1
  177. package/dist/dockview-core.min.noStyle.js +2 -2
  178. package/dist/dockview-core.min.noStyle.js.map +1 -1
  179. package/dist/dockview-core.noStyle.js +7601 -7267
  180. package/dist/dockview-core.noStyle.js.map +1 -1
  181. package/dist/esm/api/component.api.d.ts +455 -152
  182. package/dist/esm/api/component.api.d.ts.map +1 -1
  183. package/dist/esm/api/component.api.js +638 -335
  184. package/dist/esm/api/component.api.js.map +1 -1
  185. package/dist/esm/api/dockviewGroupPanelApi.d.ts +29 -29
  186. package/dist/esm/api/dockviewGroupPanelApi.js +27 -27
  187. package/dist/esm/api/dockviewPanelApi.d.ts +47 -47
  188. package/dist/esm/api/dockviewPanelApi.js +53 -53
  189. package/dist/esm/api/gridviewPanelApi.d.ts +37 -37
  190. package/dist/esm/api/gridviewPanelApi.js +25 -25
  191. package/dist/esm/api/panelApi.d.ts +88 -88
  192. package/dist/esm/api/panelApi.js +93 -93
  193. package/dist/esm/api/paneviewPanelApi.d.ts +26 -26
  194. package/dist/esm/api/paneviewPanelApi.js +27 -27
  195. package/dist/esm/api/splitviewPanelApi.d.ts +32 -32
  196. package/dist/esm/api/splitviewPanelApi.js +25 -25
  197. package/dist/esm/array.d.ts +13 -13
  198. package/dist/esm/array.js +57 -57
  199. package/dist/esm/dnd/abstractDragHandler.d.ts +12 -12
  200. package/dist/esm/dnd/abstractDragHandler.js +63 -63
  201. package/dist/esm/dnd/dataTransfer.d.ts +30 -31
  202. package/dist/esm/dnd/dataTransfer.d.ts.map +1 -1
  203. package/dist/esm/dnd/dataTransfer.js +66 -69
  204. package/dist/esm/dnd/dataTransfer.js.map +1 -1
  205. package/dist/esm/dnd/dnd.d.ts +27 -27
  206. package/dist/esm/dnd/dnd.js +36 -36
  207. package/dist/esm/dnd/droptarget.d.ts +53 -53
  208. package/dist/esm/dnd/droptarget.js +274 -274
  209. package/dist/esm/dnd/droptarget.js.map +1 -1
  210. package/dist/esm/dnd/ghost.d.ts +1 -1
  211. package/dist/esm/dnd/ghost.js +11 -11
  212. package/dist/esm/dnd/groupDragHandler.d.ts +12 -12
  213. package/dist/esm/dnd/groupDragHandler.js +54 -54
  214. package/dist/esm/dnd/overlay.d.ts +43 -43
  215. package/dist/esm/dnd/overlay.d.ts.map +1 -1
  216. package/dist/esm/dnd/overlay.js +304 -304
  217. package/dist/esm/dnd/overlay.js.map +1 -1
  218. package/dist/esm/dockview/components/panel/content.d.ts +30 -30
  219. package/dist/esm/dockview/components/panel/content.js +73 -73
  220. package/dist/esm/dockview/components/tab/defaultTab.d.ts +21 -21
  221. package/dist/esm/dockview/components/tab/defaultTab.js +67 -67
  222. package/dist/esm/dockview/components/tab/tab.d.ts +34 -34
  223. package/dist/esm/dockview/components/tab/tab.js +90 -90
  224. package/dist/esm/dockview/components/titlebar/tabsContainer.d.ts +81 -81
  225. package/dist/esm/dockview/components/titlebar/tabsContainer.js +239 -239
  226. package/dist/esm/dockview/components/titlebar/voidContainer.d.ts +17 -17
  227. package/dist/esm/dockview/components/titlebar/voidContainer.js +51 -51
  228. package/dist/esm/dockview/components/watermark/watermark.d.ts +18 -18
  229. package/dist/esm/dockview/components/watermark/watermark.js +61 -61
  230. package/dist/esm/dockview/deserializer.d.ts +12 -12
  231. package/dist/esm/dockview/deserializer.js +28 -28
  232. package/dist/esm/dockview/deserializer.js.map +1 -1
  233. package/dist/esm/dockview/dockviewComponent.d.ts +159 -159
  234. package/dist/esm/dockview/dockviewComponent.d.ts.map +1 -1
  235. package/dist/esm/dockview/dockviewComponent.js +932 -918
  236. package/dist/esm/dockview/dockviewComponent.js.map +1 -1
  237. package/dist/esm/dockview/dockviewFloatingGroupPanel.d.ts +23 -23
  238. package/dist/esm/dockview/dockviewFloatingGroupPanel.js +12 -12
  239. package/dist/esm/dockview/dockviewGroupPanel.d.ts +30 -30
  240. package/dist/esm/dockview/dockviewGroupPanel.js +51 -51
  241. package/dist/esm/dockview/dockviewGroupPanelModel.d.ts +185 -185
  242. package/dist/esm/dockview/dockviewGroupPanelModel.js +499 -498
  243. package/dist/esm/dockview/dockviewGroupPanelModel.js.map +1 -1
  244. package/dist/esm/dockview/dockviewPanel.d.ts +41 -41
  245. package/dist/esm/dockview/dockviewPanel.js +105 -104
  246. package/dist/esm/dockview/dockviewPanel.js.map +1 -1
  247. package/dist/esm/dockview/dockviewPanelModel.d.ts +35 -35
  248. package/dist/esm/dockview/dockviewPanelModel.js +74 -74
  249. package/dist/esm/dockview/dockviewPanelModel.js.map +1 -1
  250. package/dist/esm/dockview/options.d.ts +133 -136
  251. package/dist/esm/dockview/options.d.ts.map +1 -1
  252. package/dist/esm/dockview/options.js +24 -24
  253. package/dist/esm/dockview/types.d.ts +63 -63
  254. package/dist/esm/dockview/types.js +7 -7
  255. package/dist/esm/dom.d.ts +16 -16
  256. package/dist/esm/dom.js +126 -126
  257. package/dist/esm/events.d.ts +47 -47
  258. package/dist/esm/events.js +156 -156
  259. package/dist/esm/events.js.map +1 -1
  260. package/dist/esm/gridview/baseComponentGridview.d.ts +88 -87
  261. package/dist/esm/gridview/baseComponentGridview.d.ts.map +1 -1
  262. package/dist/esm/gridview/baseComponentGridview.js +184 -184
  263. package/dist/esm/gridview/baseComponentGridview.js.map +1 -1
  264. package/dist/esm/gridview/basePanelView.d.ts +40 -40
  265. package/dist/esm/gridview/basePanelView.js +85 -85
  266. package/dist/esm/gridview/branchNode.d.ts +49 -49
  267. package/dist/esm/gridview/branchNode.js +219 -219
  268. package/dist/esm/gridview/gridview.d.ts +133 -133
  269. package/dist/esm/gridview/gridview.js +461 -461
  270. package/dist/esm/gridview/gridviewComponent.d.ts +80 -80
  271. package/dist/esm/gridview/gridviewComponent.d.ts.map +1 -1
  272. package/dist/esm/gridview/gridviewComponent.js +264 -262
  273. package/dist/esm/gridview/gridviewComponent.js.map +1 -1
  274. package/dist/esm/gridview/gridviewPanel.d.ts +65 -65
  275. package/dist/esm/gridview/gridviewPanel.js +151 -151
  276. package/dist/esm/gridview/leafNode.d.ts +34 -34
  277. package/dist/esm/gridview/leafNode.js +103 -103
  278. package/dist/esm/gridview/options.d.ts +17 -18
  279. package/dist/esm/gridview/options.d.ts.map +1 -1
  280. package/dist/esm/gridview/options.js +1 -1
  281. package/dist/esm/gridview/types.d.ts +3 -3
  282. package/dist/esm/gridview/types.js +1 -1
  283. package/dist/esm/index.d.ts +42 -42
  284. package/dist/esm/index.js +34 -34
  285. package/dist/esm/lifecycle.d.ts +23 -23
  286. package/dist/esm/lifecycle.js +41 -41
  287. package/dist/esm/math.d.ts +5 -5
  288. package/dist/esm/math.js +28 -28
  289. package/dist/esm/panel/componentFactory.d.ts +11 -10
  290. package/dist/esm/panel/componentFactory.d.ts.map +1 -1
  291. package/dist/esm/panel/componentFactory.js +24 -24
  292. package/dist/esm/panel/componentFactory.js.map +1 -1
  293. package/dist/esm/panel/types.d.ts +33 -33
  294. package/dist/esm/panel/types.js +1 -1
  295. package/dist/esm/paneview/defaultPaneviewHeader.d.ts +21 -21
  296. package/dist/esm/paneview/defaultPaneviewHeader.js +63 -63
  297. package/dist/esm/paneview/draggablePaneviewPanel.d.ts +21 -21
  298. package/dist/esm/paneview/draggablePaneviewPanel.js +92 -92
  299. package/dist/esm/paneview/options.d.ts +25 -28
  300. package/dist/esm/paneview/options.d.ts.map +1 -1
  301. package/dist/esm/paneview/options.js +1 -1
  302. package/dist/esm/paneview/paneview.d.ts +40 -40
  303. package/dist/esm/paneview/paneview.d.ts.map +1 -1
  304. package/dist/esm/paneview/paneview.js +145 -145
  305. package/dist/esm/paneview/paneviewComponent.d.ts +128 -128
  306. package/dist/esm/paneview/paneviewComponent.js +276 -273
  307. package/dist/esm/paneview/paneviewComponent.js.map +1 -1
  308. package/dist/esm/paneview/paneviewPanel.d.ts +92 -92
  309. package/dist/esm/paneview/paneviewPanel.d.ts.map +1 -1
  310. package/dist/esm/paneview/paneviewPanel.js +192 -192
  311. package/dist/esm/resizable.d.ts +10 -7
  312. package/dist/esm/resizable.d.ts.map +1 -1
  313. package/dist/esm/resizable.js +48 -38
  314. package/dist/esm/resizable.js.map +1 -1
  315. package/dist/esm/splitview/options.d.ts +26 -27
  316. package/dist/esm/splitview/options.d.ts.map +1 -1
  317. package/dist/esm/splitview/options.js +1 -1
  318. package/dist/esm/splitview/splitview.d.ts +128 -128
  319. package/dist/esm/splitview/splitview.js +704 -704
  320. package/dist/esm/splitview/splitviewComponent.d.ts +101 -101
  321. package/dist/esm/splitview/splitviewComponent.js +261 -258
  322. package/dist/esm/splitview/splitviewComponent.js.map +1 -1
  323. package/dist/esm/splitview/splitviewPanel.d.ts +45 -45
  324. package/dist/esm/splitview/splitviewPanel.d.ts.map +1 -1
  325. package/dist/esm/splitview/splitviewPanel.js +108 -108
  326. package/dist/esm/splitview/splitviewPanel.js.map +1 -1
  327. package/dist/esm/splitview/viewItem.d.ts +25 -25
  328. package/dist/esm/splitview/viewItem.js +74 -74
  329. package/dist/esm/svg.d.ts +3 -3
  330. package/dist/esm/svg.js +31 -31
  331. package/dist/esm/types.d.ts +2 -2
  332. package/dist/esm/types.js +1 -1
  333. package/package.json +30 -42
  334. package/LICENSE +0 -21
@@ -1,1157 +1,1171 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- var __assign = (this && this.__assign) || function () {
18
- __assign = Object.assign || function(t) {
19
- for (var s, i = 1, n = arguments.length; i < n; i++) {
20
- s = arguments[i];
21
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
22
- t[p] = s[p];
23
- }
24
- return t;
25
- };
26
- return __assign.apply(this, arguments);
27
- };
28
- var __values = (this && this.__values) || function(o) {
29
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
30
- if (m) return m.call(o);
31
- if (o && typeof o.length === "number") return {
32
- next: function () {
33
- if (o && i >= o.length) o = void 0;
34
- return { value: o && o[i++], done: !o };
35
- }
36
- };
37
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
38
- };
39
- var __read = (this && this.__read) || function (o, n) {
40
- var m = typeof Symbol === "function" && o[Symbol.iterator];
41
- if (!m) return o;
42
- var i = m.call(o), r, ar = [], e;
43
- try {
44
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
45
- }
46
- catch (error) { e = { error: error }; }
47
- finally {
48
- try {
49
- if (r && !r.done && (m = i["return"])) m.call(i);
50
- }
51
- finally { if (e) throw e.error; }
52
- }
53
- return ar;
54
- };
55
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
56
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
57
- if (ar || !(i in from)) {
58
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
59
- ar[i] = from[i];
60
- }
61
- }
62
- return to.concat(ar || Array.prototype.slice.call(from));
63
- };
64
- Object.defineProperty(exports, "__esModule", { value: true });
65
- exports.DockviewComponent = void 0;
66
- var gridview_1 = require("../gridview/gridview");
67
- var droptarget_1 = require("../dnd/droptarget");
68
- var array_1 = require("../array");
69
- var dockviewPanel_1 = require("./dockviewPanel");
70
- var lifecycle_1 = require("../lifecycle");
71
- var events_1 = require("../events");
72
- var watermark_1 = require("./components/watermark/watermark");
73
- var types_1 = require("./types");
74
- var math_1 = require("../math");
75
- var deserializer_1 = require("./deserializer");
76
- var componentFactory_1 = require("../panel/componentFactory");
77
- var options_1 = require("./options");
78
- var baseComponentGridview_1 = require("../gridview/baseComponentGridview");
79
- var component_api_1 = require("../api/component.api");
80
- var splitview_1 = require("../splitview/splitview");
81
- var dockviewGroupPanel_1 = require("./dockviewGroupPanel");
82
- var dockviewPanelModel_1 = require("./dockviewPanelModel");
83
- var dataTransfer_1 = require("../dnd/dataTransfer");
84
- var overlay_1 = require("../dnd/overlay");
85
- var dom_1 = require("../dom");
86
- var dockviewFloatingGroupPanel_1 = require("./dockviewFloatingGroupPanel");
87
- var DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE = 100;
88
- function typeValidate3(data, path) {
89
- if (typeof data.id !== 'string') {
90
- throw new Error("".concat(path, ".id must be a string"));
91
- }
92
- if (typeof data.activeView !== 'string' ||
93
- typeof data.activeView !== 'undefined') {
94
- throw new Error("".concat(path, ".activeView must be a string of undefined"));
95
- }
96
- }
97
- function typeValidate2(data, path) {
98
- if (typeof data.size !== 'number' && typeof data.size !== 'undefined') {
99
- throw new Error("".concat(path, ".size must be a number or undefined"));
100
- }
101
- if (typeof data.visible !== 'boolean' &&
102
- typeof data.visible !== 'undefined') {
103
- throw new Error("".concat(path, ".visible must be a boolean or undefined"));
104
- }
105
- if (data.type === 'leaf') {
106
- if (typeof data.data !== 'object' ||
107
- data.data === null ||
108
- Array.isArray(data.data)) {
109
- throw new Error('object must be a non-null object');
110
- }
111
- typeValidate3(data.data, "".concat(path, ".data"));
112
- }
113
- else if (data.type === 'branch') {
114
- if (!Array.isArray(data.data)) {
115
- throw new Error("".concat(path, ".data must be an array"));
116
- }
117
- }
118
- else {
119
- throw new Error("".concat(path, ".type must be onew of {'branch', 'leaf'}"));
120
- }
121
- }
122
- function typeValidate(data) {
123
- if (typeof data !== 'object' || data === null) {
124
- throw new Error('object must be a non-null object');
125
- }
126
- var grid = data.grid, panels = data.panels, activeGroup = data.activeGroup, floatingGroups = data.floatingGroups;
127
- if (typeof grid !== 'object' || grid === null) {
128
- throw new Error("'.grid' must be a non-null object");
129
- }
130
- if (typeof grid.height !== 'number') {
131
- throw new Error("'.grid.height' must be a number");
132
- }
133
- if (typeof grid.width !== 'number') {
134
- throw new Error("'.grid.width' must be a number");
135
- }
136
- if (typeof grid.root !== 'object' || grid.root === null) {
137
- throw new Error("'.grid.root' must be a non-null object");
138
- }
139
- if (grid.root.type !== 'branch') {
140
- throw new Error(".grid.root.type must be of type 'branch'");
141
- }
142
- if (grid.orientation !== splitview_1.Orientation.HORIZONTAL &&
143
- grid.orientation !== splitview_1.Orientation.VERTICAL) {
144
- throw new Error("'.grid.width' must be one of {".concat(splitview_1.Orientation.HORIZONTAL, ", ").concat(splitview_1.Orientation.VERTICAL, "}"));
145
- }
146
- typeValidate2(grid.root, '.grid.root');
147
- }
148
- var DockviewComponent = /** @class */ (function (_super) {
149
- __extends(DockviewComponent, _super);
150
- function DockviewComponent(options) {
151
- var _this = _super.call(this, {
152
- proportionalLayout: true,
153
- orientation: options.orientation || splitview_1.Orientation.HORIZONTAL,
154
- styles: options.styles,
155
- parentElement: options.parentElement,
156
- }) || this;
157
- _this.nextGroupId = (0, math_1.sequentialNumberGenerator)();
158
- _this._deserializer = new deserializer_1.DefaultDockviewDeserialzier(_this);
159
- _this.watermark = null;
160
- _this._onWillDragPanel = new events_1.Emitter();
161
- _this.onWillDragPanel = _this._onWillDragPanel.event;
162
- _this._onWillDragGroup = new events_1.Emitter();
163
- _this.onWillDragGroup = _this._onWillDragGroup.event;
164
- _this._onDidDrop = new events_1.Emitter();
165
- _this.onDidDrop = _this._onDidDrop.event;
166
- _this._onDidRemovePanel = new events_1.Emitter();
167
- _this.onDidRemovePanel = _this._onDidRemovePanel.event;
168
- _this._onDidAddPanel = new events_1.Emitter();
169
- _this.onDidAddPanel = _this._onDidAddPanel.event;
170
- _this._onDidLayoutFromJSON = new events_1.Emitter();
171
- _this.onDidLayoutFromJSON = _this._onDidLayoutFromJSON.event;
172
- _this._onDidActivePanelChange = new events_1.Emitter();
173
- _this.onDidActivePanelChange = _this._onDidActivePanelChange.event;
174
- _this.floatingGroups = [];
175
- (0, dom_1.toggleClass)(_this.gridview.element, 'dv-dockview', true);
176
- _this.addDisposables(_this._onWillDragPanel, _this._onWillDragGroup, _this._onDidActivePanelChange, _this._onDidAddPanel, _this._onDidRemovePanel, _this._onDidLayoutFromJSON, _this._onDidDrop, events_1.Event.any(_this.onDidAddGroup, _this.onDidRemoveGroup)(function () {
177
- _this.updateWatermark();
178
- }), events_1.Event.any(_this.onDidAddPanel, _this.onDidRemovePanel, _this.onDidActivePanelChange)(function () {
179
- _this._bufferOnDidLayoutChange.fire();
180
- }));
181
- _this._options = options;
182
- if (!_this.options.components) {
183
- _this.options.components = {};
184
- }
185
- if (!_this.options.frameworkComponents) {
186
- _this.options.frameworkComponents = {};
187
- }
188
- if (!_this.options.frameworkTabComponents) {
189
- _this.options.frameworkTabComponents = {};
190
- }
191
- if (!_this.options.tabComponents) {
192
- _this.options.tabComponents = {};
193
- }
194
- if (!_this.options.watermarkComponent &&
195
- !_this.options.watermarkFrameworkComponent) {
196
- _this.options.watermarkComponent = watermark_1.Watermark;
197
- }
198
- var dropTarget = new droptarget_1.Droptarget(_this.element, {
199
- canDisplayOverlay: function (event, position) {
200
- var data = (0, dataTransfer_1.getPanelData)();
201
- if (data) {
202
- if (data.viewId !== _this.id) {
203
- return false;
204
- }
205
- if (position === 'center') {
206
- // center drop target is only allowed if there are no panels in the grid
207
- // floating panels are allowed
208
- return _this.gridview.length === 0;
209
- }
210
- return true;
211
- }
212
- if (_this.options.showDndOverlay) {
213
- if (position === 'center' && _this.gridview.length !== 0) {
214
- /**
215
- * for external events only show the four-corner drag overlays, disable
216
- * the center position so that external drag events can fall through to the group
217
- * and panel drop target handlers
218
- */
219
- return false;
220
- }
221
- return _this.options.showDndOverlay({
222
- nativeEvent: event,
223
- position: position,
224
- target: types_1.DockviewDropTargets.Edge,
225
- getData: dataTransfer_1.getPanelData,
226
- });
227
- }
228
- return false;
229
- },
230
- acceptedTargetZones: ['top', 'bottom', 'left', 'right', 'center'],
231
- overlayModel: {
232
- activationSize: { type: 'pixels', value: 10 },
233
- size: { type: 'pixels', value: 20 },
234
- },
235
- });
236
- _this.addDisposables(dropTarget.onDrop(function (event) {
237
- var data = (0, dataTransfer_1.getPanelData)();
238
- if (data) {
239
- _this.moveGroupOrPanel(_this.orthogonalize(event.position), data.groupId, data.panelId || undefined, 'center');
240
- }
241
- else {
242
- _this._onDidDrop.fire(__assign(__assign({}, event), { api: _this._api, group: null, getData: dataTransfer_1.getPanelData }));
243
- }
244
- }), dropTarget);
245
- _this._api = new component_api_1.DockviewApi(_this);
246
- _this.updateWatermark();
247
- return _this;
248
- }
249
- Object.defineProperty(DockviewComponent.prototype, "orientation", {
250
- get: function () {
251
- return this.gridview.orientation;
252
- },
253
- enumerable: false,
254
- configurable: true
255
- });
256
- Object.defineProperty(DockviewComponent.prototype, "totalPanels", {
257
- get: function () {
258
- return this.panels.length;
259
- },
260
- enumerable: false,
261
- configurable: true
262
- });
263
- Object.defineProperty(DockviewComponent.prototype, "panels", {
264
- get: function () {
265
- return this.groups.flatMap(function (group) { return group.panels; });
266
- },
267
- enumerable: false,
268
- configurable: true
269
- });
270
- Object.defineProperty(DockviewComponent.prototype, "options", {
271
- get: function () {
272
- return this._options;
273
- },
274
- enumerable: false,
275
- configurable: true
276
- });
277
- Object.defineProperty(DockviewComponent.prototype, "activePanel", {
278
- get: function () {
279
- var activeGroup = this.activeGroup;
280
- if (!activeGroup) {
281
- return undefined;
282
- }
283
- return activeGroup.activePanel;
284
- },
285
- enumerable: false,
286
- configurable: true
287
- });
288
- DockviewComponent.prototype.addFloatingGroup = function (item, coord, options) {
289
- var _this = this;
290
- var _a, _b, _c, _d, _e, _f;
291
- var group;
292
- if (item instanceof dockviewPanel_1.DockviewPanel) {
293
- group = this.createGroup();
294
- this.removePanel(item, {
295
- removeEmptyGroup: true,
296
- skipDispose: true,
297
- });
298
- group.model.openPanel(item);
299
- }
300
- else {
301
- group = item;
302
- var skip = typeof (options === null || options === void 0 ? void 0 : options.skipRemoveGroup) === 'boolean' &&
303
- options.skipRemoveGroup;
304
- if (!skip) {
305
- this.doRemoveGroup(item, { skipDispose: true });
306
- }
307
- }
308
- group.model.isFloating = true;
309
- var overlayLeft = typeof (coord === null || coord === void 0 ? void 0 : coord.x) === 'number' ? Math.max(coord.x, 0) : 100;
310
- var overlayTop = typeof (coord === null || coord === void 0 ? void 0 : coord.y) === 'number' ? Math.max(coord.y, 0) : 100;
311
- var overlay = new overlay_1.Overlay({
312
- container: this.gridview.element,
313
- content: group.element,
314
- height: (_a = coord === null || coord === void 0 ? void 0 : coord.height) !== null && _a !== void 0 ? _a : 300,
315
- width: (_b = coord === null || coord === void 0 ? void 0 : coord.width) !== null && _b !== void 0 ? _b : 300,
316
- left: overlayLeft,
317
- top: overlayTop,
318
- minimumInViewportWidth: this.options.floatingGroupBounds === 'boundedWithinViewport'
319
- ? undefined
320
- : (_d = (_c = this.options.floatingGroupBounds) === null || _c === void 0 ? void 0 : _c.minimumWidthWithinViewport) !== null && _d !== void 0 ? _d : DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE,
321
- minimumInViewportHeight: this.options.floatingGroupBounds === 'boundedWithinViewport'
322
- ? undefined
323
- : (_f = (_e = this.options.floatingGroupBounds) === null || _e === void 0 ? void 0 : _e.minimumHeightWithinViewport) !== null && _f !== void 0 ? _f : DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE,
324
- });
325
- var el = group.element.querySelector('.void-container');
326
- if (!el) {
327
- throw new Error('failed to find drag handle');
328
- }
329
- overlay.setupDrag(el, {
330
- inDragMode: typeof (options === null || options === void 0 ? void 0 : options.inDragMode) === 'boolean'
331
- ? options.inDragMode
332
- : false,
333
- });
334
- var floatingGroupPanel = new dockviewFloatingGroupPanel_1.DockviewFloatingGroupPanel(group, overlay);
335
- var disposable = (0, dom_1.watchElementResize)(group.element, function (entry) {
336
- var _a = entry.contentRect, width = _a.width, height = _a.height;
337
- group.layout(width, height); // let the group know it's size is changing so it can fire events to the panel
338
- });
339
- floatingGroupPanel.addDisposables(overlay.onDidChange(function () {
340
- // this is either a resize or a move
341
- // to inform the panels .layout(...) the group with it's current size
342
- // don't care about resize since the above watcher handles that
343
- group.layout(group.height, group.width);
344
- }), overlay.onDidChangeEnd(function () {
345
- _this._bufferOnDidLayoutChange.fire();
346
- }), group.onDidChange(function (event) {
347
- overlay.setBounds({
348
- height: event === null || event === void 0 ? void 0 : event.height,
349
- width: event === null || event === void 0 ? void 0 : event.width,
350
- });
351
- }), {
352
- dispose: function () {
353
- disposable.dispose();
354
- group.model.isFloating = false;
355
- (0, array_1.remove)(_this.floatingGroups, floatingGroupPanel);
356
- _this.updateWatermark();
357
- },
358
- });
359
- this.floatingGroups.push(floatingGroupPanel);
360
- this.updateWatermark();
361
- };
362
- DockviewComponent.prototype.orthogonalize = function (position) {
363
- switch (position) {
364
- case 'top':
365
- case 'bottom':
366
- if (this.gridview.orientation === splitview_1.Orientation.HORIZONTAL) {
367
- // we need to add to a vertical splitview but the current root is a horizontal splitview.
368
- // insert a vertical splitview at the root level and add the existing view as a child
369
- this.gridview.insertOrthogonalSplitviewAtRoot();
370
- }
371
- break;
372
- case 'left':
373
- case 'right':
374
- if (this.gridview.orientation === splitview_1.Orientation.VERTICAL) {
375
- // we need to add to a horizontal splitview but the current root is a vertical splitview.
376
- // insert a horiziontal splitview at the root level and add the existing view as a child
377
- this.gridview.insertOrthogonalSplitviewAtRoot();
378
- }
379
- break;
380
- default:
381
- break;
382
- }
383
- switch (position) {
384
- case 'top':
385
- case 'left':
386
- case 'center':
387
- return this.createGroupAtLocation([0]); // insert into first position
388
- case 'bottom':
389
- case 'right':
390
- return this.createGroupAtLocation([this.gridview.length]); // insert into last position
391
- default:
392
- throw new Error("unsupported position ".concat(position));
393
- }
394
- };
395
- DockviewComponent.prototype.updateOptions = function (options) {
396
- var e_1, _a;
397
- var _b, _c;
398
- var hasOrientationChanged = typeof options.orientation === 'string' &&
399
- this.gridview.orientation !== options.orientation;
400
- var hasFloatingGroupOptionsChanged = options.floatingGroupBounds !== undefined &&
401
- options.floatingGroupBounds !== this.options.floatingGroupBounds;
402
- this._options = __assign(__assign({}, this.options), options);
403
- if (hasOrientationChanged) {
404
- this.gridview.orientation = options.orientation;
405
- }
406
- if (hasFloatingGroupOptionsChanged) {
407
- try {
408
- for (var _d = __values(this.floatingGroups), _e = _d.next(); !_e.done; _e = _d.next()) {
409
- var group = _e.value;
410
- switch (this.options.floatingGroupBounds) {
411
- case 'boundedWithinViewport':
412
- group.overlay.minimumInViewportHeight = undefined;
413
- group.overlay.minimumInViewportWidth = undefined;
414
- break;
415
- case undefined:
416
- group.overlay.minimumInViewportHeight =
417
- DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE;
418
- group.overlay.minimumInViewportWidth =
419
- DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE;
420
- break;
421
- default:
422
- group.overlay.minimumInViewportHeight =
423
- (_b = this.options.floatingGroupBounds) === null || _b === void 0 ? void 0 : _b.minimumHeightWithinViewport;
424
- group.overlay.minimumInViewportWidth =
425
- (_c = this.options.floatingGroupBounds) === null || _c === void 0 ? void 0 : _c.minimumWidthWithinViewport;
426
- }
427
- group.overlay.setBounds({});
428
- }
429
- }
430
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
431
- finally {
432
- try {
433
- if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
434
- }
435
- finally { if (e_1) throw e_1.error; }
436
- }
437
- }
438
- this.layout(this.gridview.width, this.gridview.height, true);
439
- };
440
- DockviewComponent.prototype.layout = function (width, height, forceResize) {
441
- var e_2, _a;
442
- _super.prototype.layout.call(this, width, height, forceResize);
443
- if (this.floatingGroups) {
444
- try {
445
- for (var _b = __values(this.floatingGroups), _c = _b.next(); !_c.done; _c = _b.next()) {
446
- var floating = _c.value;
447
- // ensure floting groups stay within visible boundaries
448
- floating.overlay.setBounds();
449
- }
450
- }
451
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
452
- finally {
453
- try {
454
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
455
- }
456
- finally { if (e_2) throw e_2.error; }
457
- }
458
- }
459
- };
460
- DockviewComponent.prototype.focus = function () {
461
- var _a;
462
- (_a = this.activeGroup) === null || _a === void 0 ? void 0 : _a.focus();
463
- };
464
- DockviewComponent.prototype.getGroupPanel = function (id) {
465
- return this.panels.find(function (panel) { return panel.id === id; });
466
- };
467
- DockviewComponent.prototype.setActivePanel = function (panel) {
468
- this.doSetGroupActive(panel.group);
469
- panel.group.model.openPanel(panel);
470
- };
471
- DockviewComponent.prototype.moveToNext = function (options) {
472
- var _a;
473
- if (options === void 0) { options = {}; }
474
- if (!options.group) {
475
- if (!this.activeGroup) {
476
- return;
477
- }
478
- options.group = this.activeGroup;
479
- }
480
- if (options.includePanel && options.group) {
481
- if (options.group.activePanel !==
482
- options.group.panels[options.group.panels.length - 1]) {
483
- options.group.model.moveToNext({ suppressRoll: true });
484
- return;
485
- }
486
- }
487
- var location = (0, gridview_1.getGridLocation)(options.group.element);
488
- var next = (_a = this.gridview.next(location)) === null || _a === void 0 ? void 0 : _a.view;
489
- this.doSetGroupActive(next);
490
- };
491
- DockviewComponent.prototype.moveToPrevious = function (options) {
492
- var _a;
493
- if (options === void 0) { options = {}; }
494
- if (!options.group) {
495
- if (!this.activeGroup) {
496
- return;
497
- }
498
- options.group = this.activeGroup;
499
- }
500
- if (options.includePanel && options.group) {
501
- if (options.group.activePanel !== options.group.panels[0]) {
502
- options.group.model.moveToPrevious({ suppressRoll: true });
503
- return;
504
- }
505
- }
506
- var location = (0, gridview_1.getGridLocation)(options.group.element);
507
- var next = (_a = this.gridview.previous(location)) === null || _a === void 0 ? void 0 : _a.view;
508
- if (next) {
509
- this.doSetGroupActive(next);
510
- }
511
- };
512
- /**
513
- * Serialize the current state of the layout
514
- *
515
- * @returns A JSON respresentation of the layout
516
- */
517
- DockviewComponent.prototype.toJSON = function () {
518
- var _a;
519
- var data = this.gridview.serialize();
520
- var panels = this.panels.reduce(function (collection, panel) {
521
- collection[panel.id] = panel.toJSON();
522
- return collection;
523
- }, {});
524
- var floats = this.floatingGroups.map(function (floatingGroup) {
525
- return {
526
- data: floatingGroup.group.toJSON(),
527
- position: floatingGroup.overlay.toJSON(),
528
- };
529
- });
530
- var result = {
531
- grid: data,
532
- panels: panels,
533
- activeGroup: (_a = this.activeGroup) === null || _a === void 0 ? void 0 : _a.id,
534
- };
535
- if (floats.length > 0) {
536
- result.floatingGroups = floats;
537
- }
538
- return result;
539
- };
540
- DockviewComponent.prototype.fromJSON = function (data) {
541
- var e_3, _a, e_4, _b, e_5, _c, e_6, _d, e_7, _e, e_8, _f;
542
- var _this = this;
543
- var _g;
544
- this.clear();
545
- if (typeof data !== 'object' || data === null) {
546
- throw new Error('serialized layout must be a non-null object');
547
- }
548
- var grid = data.grid, panels = data.panels, activeGroup = data.activeGroup;
549
- if (grid.root.type !== 'branch' || !Array.isArray(grid.root.data)) {
550
- throw new Error('root must be of type branch');
551
- }
552
- try {
553
- // take note of the existing dimensions
554
- var width = this.width;
555
- var height = this.height;
556
- var createGroupFromSerializedState_1 = function (data) {
557
- var e_9, _a;
558
- var id = data.id, locked = data.locked, hideHeader = data.hideHeader, views = data.views, activeView = data.activeView;
559
- if (typeof id !== 'string') {
560
- throw new Error('group id must be of type string');
561
- }
562
- var group = _this.createGroup({
563
- id: id,
564
- locked: !!locked,
565
- hideHeader: !!hideHeader,
566
- });
567
- var createdPanels = [];
568
- try {
569
- for (var views_1 = __values(views), views_1_1 = views_1.next(); !views_1_1.done; views_1_1 = views_1.next()) {
570
- var child = views_1_1.value;
571
- /**
572
- * Run the deserializer step seperately since this may fail to due corrupted external state.
573
- * In running this section first we avoid firing lots of 'add' events in the event of a failure
574
- * due to a corruption of input data.
575
- */
576
- var panel = _this._deserializer.fromJSON(panels[child], group);
577
- createdPanels.push(panel);
578
- }
579
- }
580
- catch (e_9_1) { e_9 = { error: e_9_1 }; }
581
- finally {
582
- try {
583
- if (views_1_1 && !views_1_1.done && (_a = views_1.return)) _a.call(views_1);
584
- }
585
- finally { if (e_9) throw e_9.error; }
586
- }
587
- _this._onDidAddGroup.fire(group);
588
- for (var i = 0; i < views.length; i++) {
589
- var panel = createdPanels[i];
590
- var isActive = typeof activeView === 'string' &&
591
- activeView === panel.id;
592
- group.model.openPanel(panel, {
593
- skipSetPanelActive: !isActive,
594
- skipSetGroupActive: true,
595
- });
596
- }
597
- if (!group.activePanel && group.panels.length > 0) {
598
- group.model.openPanel(group.panels[group.panels.length - 1], {
599
- skipSetGroupActive: true,
600
- });
601
- }
602
- return group;
603
- };
604
- this.gridview.deserialize(grid, {
605
- fromJSON: function (node) {
606
- return createGroupFromSerializedState_1(node.data);
607
- },
608
- });
609
- this.layout(width, height, true);
610
- var serializedFloatingGroups = (_g = data.floatingGroups) !== null && _g !== void 0 ? _g : [];
611
- try {
612
- for (var serializedFloatingGroups_1 = __values(serializedFloatingGroups), serializedFloatingGroups_1_1 = serializedFloatingGroups_1.next(); !serializedFloatingGroups_1_1.done; serializedFloatingGroups_1_1 = serializedFloatingGroups_1.next()) {
613
- var serializedFloatingGroup = serializedFloatingGroups_1_1.value;
614
- var data_1 = serializedFloatingGroup.data, position = serializedFloatingGroup.position;
615
- var group = createGroupFromSerializedState_1(data_1);
616
- this.addFloatingGroup(group, {
617
- x: position.left,
618
- y: position.top,
619
- height: position.height,
620
- width: position.width,
621
- }, { skipRemoveGroup: true, inDragMode: false });
622
- }
623
- }
624
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
625
- finally {
626
- try {
627
- if (serializedFloatingGroups_1_1 && !serializedFloatingGroups_1_1.done && (_a = serializedFloatingGroups_1.return)) _a.call(serializedFloatingGroups_1);
628
- }
629
- finally { if (e_3) throw e_3.error; }
630
- }
631
- try {
632
- for (var _h = __values(this.floatingGroups), _j = _h.next(); !_j.done; _j = _h.next()) {
633
- var floatingGroup = _j.value;
634
- floatingGroup.overlay.setBounds();
635
- }
636
- }
637
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
638
- finally {
639
- try {
640
- if (_j && !_j.done && (_b = _h.return)) _b.call(_h);
641
- }
642
- finally { if (e_4) throw e_4.error; }
643
- }
644
- if (typeof activeGroup === 'string') {
645
- var panel = this.getPanel(activeGroup);
646
- if (panel) {
647
- this.doSetGroupActive(panel);
648
- }
649
- }
650
- }
651
- catch (err) {
652
- try {
653
- /**
654
- * Takes all the successfully created groups and remove all of their panels.
655
- */
656
- for (var _k = __values(this.groups), _l = _k.next(); !_l.done; _l = _k.next()) {
657
- var group = _l.value;
658
- try {
659
- for (var _m = (e_6 = void 0, __values(group.panels)), _o = _m.next(); !_o.done; _o = _m.next()) {
660
- var panel = _o.value;
661
- this.removePanel(panel, {
662
- removeEmptyGroup: false,
663
- skipDispose: false,
664
- });
665
- }
666
- }
667
- catch (e_6_1) { e_6 = { error: e_6_1 }; }
668
- finally {
669
- try {
670
- if (_o && !_o.done && (_d = _m.return)) _d.call(_m);
671
- }
672
- finally { if (e_6) throw e_6.error; }
673
- }
674
- }
675
- }
676
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
677
- finally {
678
- try {
679
- if (_l && !_l.done && (_c = _k.return)) _c.call(_k);
680
- }
681
- finally { if (e_5) throw e_5.error; }
682
- }
683
- try {
684
- /**
685
- * To remove a group we cannot call this.removeGroup(...) since this makes assumptions about
686
- * the underlying HTMLElement existing in the Gridview.
687
- */
688
- for (var _p = __values(this.groups), _q = _p.next(); !_q.done; _q = _p.next()) {
689
- var group = _q.value;
690
- group.dispose();
691
- this._groups.delete(group.id);
692
- this._onDidRemoveGroup.fire(group);
693
- }
694
- }
695
- catch (e_7_1) { e_7 = { error: e_7_1 }; }
696
- finally {
697
- try {
698
- if (_q && !_q.done && (_e = _p.return)) _e.call(_p);
699
- }
700
- finally { if (e_7) throw e_7.error; }
701
- }
702
- try {
703
- // iterate over a reassigned array since original array will be modified
704
- for (var _r = __values(__spreadArray([], __read(this.floatingGroups), false)), _s = _r.next(); !_s.done; _s = _r.next()) {
705
- var floatingGroup = _s.value;
706
- floatingGroup.dispose();
707
- }
708
- }
709
- catch (e_8_1) { e_8 = { error: e_8_1 }; }
710
- finally {
711
- try {
712
- if (_s && !_s.done && (_f = _r.return)) _f.call(_r);
713
- }
714
- finally { if (e_8) throw e_8.error; }
715
- }
716
- // fires clean-up events and clears the underlying HTML gridview.
717
- this.clear();
718
- /**
719
- * even though we have cleaned-up we still want to inform the caller of their error
720
- * and we'll do this through re-throwing the original error since afterall you would
721
- * expect trying to load a corrupted layout to result in an error and not silently fail...
722
- */
723
- throw err;
724
- }
725
- this._onDidLayoutFromJSON.fire();
726
- };
727
- DockviewComponent.prototype.clear = function () {
728
- var e_10, _a;
729
- var groups = Array.from(this._groups.values()).map(function (_) { return _.value; });
730
- var hasActiveGroup = !!this.activeGroup;
731
- var hasActivePanel = !!this.activePanel;
732
- try {
733
- for (var groups_1 = __values(groups), groups_1_1 = groups_1.next(); !groups_1_1.done; groups_1_1 = groups_1.next()) {
734
- var group = groups_1_1.value;
735
- // remove the group will automatically remove the panels
736
- this.removeGroup(group, { skipActive: true });
737
- }
738
- }
739
- catch (e_10_1) { e_10 = { error: e_10_1 }; }
740
- finally {
741
- try {
742
- if (groups_1_1 && !groups_1_1.done && (_a = groups_1.return)) _a.call(groups_1);
743
- }
744
- finally { if (e_10) throw e_10.error; }
745
- }
746
- if (hasActiveGroup) {
747
- this.doSetGroupActive(undefined);
748
- }
749
- if (hasActivePanel) {
750
- this._onDidActivePanelChange.fire(undefined);
751
- }
752
- this.gridview.clear();
753
- };
754
- DockviewComponent.prototype.closeAllGroups = function () {
755
- var e_11, _a;
756
- try {
757
- for (var _b = __values(this._groups.entries()), _c = _b.next(); !_c.done; _c = _b.next()) {
758
- var entry = _c.value;
759
- var _d = __read(entry, 2), _ = _d[0], group = _d[1];
760
- group.value.model.closeAllPanels();
761
- }
762
- }
763
- catch (e_11_1) { e_11 = { error: e_11_1 }; }
764
- finally {
765
- try {
766
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
767
- }
768
- finally { if (e_11) throw e_11.error; }
769
- }
770
- };
771
- DockviewComponent.prototype.addPanel = function (options) {
772
- var _a, _b;
773
- if (this.panels.find(function (_) { return _.id === options.id; })) {
774
- throw new Error("panel with id ".concat(options.id, " already exists"));
775
- }
776
- var referenceGroup;
777
- if (options.position && options.floating) {
778
- throw new Error('you can only provide one of: position, floating as arguments to .addPanel(...)');
779
- }
780
- if (options.position) {
781
- if ((0, options_1.isPanelOptionsWithPanel)(options.position)) {
782
- var referencePanel = typeof options.position.referencePanel === 'string'
783
- ? this.getGroupPanel(options.position.referencePanel)
784
- : options.position.referencePanel;
785
- if (!referencePanel) {
786
- throw new Error("referencePanel ".concat(options.position.referencePanel, " does not exist"));
787
- }
788
- referenceGroup = this.findGroup(referencePanel);
789
- }
790
- else if ((0, options_1.isPanelOptionsWithGroup)(options.position)) {
791
- referenceGroup =
792
- typeof options.position.referenceGroup === 'string'
793
- ? (_a = this._groups.get(options.position.referenceGroup)) === null || _a === void 0 ? void 0 : _a.value
794
- : options.position.referenceGroup;
795
- if (!referenceGroup) {
796
- throw new Error("referencePanel ".concat(options.position.referenceGroup, " does not exist"));
797
- }
798
- }
799
- else {
800
- var group = this.orthogonalize((0, droptarget_1.directionToPosition)(options.position.direction));
801
- var panel_1 = this.createPanel(options, group);
802
- group.model.openPanel(panel_1);
803
- return panel_1;
804
- }
805
- }
806
- else {
807
- referenceGroup = this.activeGroup;
808
- }
809
- var panel;
810
- if (referenceGroup) {
811
- var target = (0, baseComponentGridview_1.toTarget)(((_b = options.position) === null || _b === void 0 ? void 0 : _b.direction) || 'within');
812
- if (options.floating) {
813
- var group = this.createGroup();
814
- panel = this.createPanel(options, group);
815
- group.model.openPanel(panel);
816
- var o = typeof options.floating === 'object' &&
817
- options.floating !== null
818
- ? options.floating
819
- : {};
820
- this.addFloatingGroup(group, o, {
821
- inDragMode: false,
822
- skipRemoveGroup: true,
823
- });
824
- }
825
- else if (referenceGroup.api.isFloating || target === 'center') {
826
- panel = this.createPanel(options, referenceGroup);
827
- referenceGroup.model.openPanel(panel);
828
- }
829
- else {
830
- var location_1 = (0, gridview_1.getGridLocation)(referenceGroup.element);
831
- var relativeLocation = (0, gridview_1.getRelativeLocation)(this.gridview.orientation, location_1, target);
832
- var group = this.createGroupAtLocation(relativeLocation);
833
- panel = this.createPanel(options, group);
834
- group.model.openPanel(panel);
835
- }
836
- }
837
- else if (options.floating) {
838
- var group = this.createGroup();
839
- panel = this.createPanel(options, group);
840
- group.model.openPanel(panel);
841
- var o = typeof options.floating === 'object' &&
842
- options.floating !== null
843
- ? options.floating
844
- : {};
845
- this.addFloatingGroup(group, o, {
846
- inDragMode: false,
847
- skipRemoveGroup: true,
848
- });
849
- }
850
- else {
851
- var group = this.createGroupAtLocation();
852
- panel = this.createPanel(options, group);
853
- group.model.openPanel(panel);
854
- }
855
- return panel;
856
- };
857
- DockviewComponent.prototype.removePanel = function (panel, options) {
858
- if (options === void 0) { options = {
859
- removeEmptyGroup: true,
860
- skipDispose: false,
861
- }; }
862
- var group = panel.group;
863
- if (!group) {
864
- throw new Error("cannot remove panel ".concat(panel.id, ". it's missing a group."));
865
- }
866
- group.model.removePanel(panel);
867
- if (!options.skipDispose) {
868
- panel.dispose();
869
- }
870
- if (group.size === 0 && options.removeEmptyGroup) {
871
- this.removeGroup(group);
872
- }
873
- };
874
- DockviewComponent.prototype.createWatermarkComponent = function () {
875
- var _a;
876
- return (0, componentFactory_1.createComponent)('watermark-id', 'watermark-name', this.options.watermarkComponent
877
- ? { 'watermark-name': this.options.watermarkComponent }
878
- : {}, this.options.watermarkFrameworkComponent
879
- ? { 'watermark-name': this.options.watermarkFrameworkComponent }
880
- : {}, (_a = this.options.frameworkComponentFactory) === null || _a === void 0 ? void 0 : _a.watermark);
881
- };
882
- DockviewComponent.prototype.updateWatermark = function () {
883
- var _a, _b;
884
- if (this.groups.filter(function (x) { return !x.api.isFloating; }).length === 0) {
885
- if (!this.watermark) {
886
- this.watermark = this.createWatermarkComponent();
887
- this.watermark.init({
888
- containerApi: new component_api_1.DockviewApi(this),
889
- });
890
- var watermarkContainer = document.createElement('div');
891
- watermarkContainer.className = 'dv-watermark-container';
892
- watermarkContainer.appendChild(this.watermark.element);
893
- this.gridview.element.appendChild(watermarkContainer);
894
- }
895
- }
896
- else if (this.watermark) {
897
- this.watermark.element.parentElement.remove();
898
- (_b = (_a = this.watermark).dispose) === null || _b === void 0 ? void 0 : _b.call(_a);
899
- this.watermark = null;
900
- }
901
- };
902
- DockviewComponent.prototype.addGroup = function (options) {
903
- var _a;
904
- var group = this.createGroup();
905
- if (options) {
906
- var referenceGroup = void 0;
907
- if ((0, options_1.isGroupOptionsWithPanel)(options)) {
908
- var referencePanel = typeof options.referencePanel === 'string'
909
- ? this.panels.find(function (panel) { return panel.id === options.referencePanel; })
910
- : options.referencePanel;
911
- if (!referencePanel) {
912
- throw new Error("reference panel ".concat(options.referencePanel, " does not exist"));
913
- }
914
- referenceGroup = this.findGroup(referencePanel);
915
- if (!referenceGroup) {
916
- throw new Error("reference group for reference panel ".concat(options.referencePanel, " does not exist"));
917
- }
918
- }
919
- else if ((0, options_1.isGroupOptionsWithGroup)(options)) {
920
- referenceGroup =
921
- typeof options.referenceGroup === 'string'
922
- ? (_a = this._groups.get(options.referenceGroup)) === null || _a === void 0 ? void 0 : _a.value
923
- : options.referenceGroup;
924
- if (!referenceGroup) {
925
- throw new Error("reference group ".concat(options.referenceGroup, " does not exist"));
926
- }
927
- }
928
- else {
929
- var group_1 = this.orthogonalize((0, droptarget_1.directionToPosition)(options.direction));
930
- return group_1;
931
- }
932
- var target = (0, baseComponentGridview_1.toTarget)(options.direction || 'within');
933
- var location_2 = (0, gridview_1.getGridLocation)(referenceGroup.element);
934
- var relativeLocation = (0, gridview_1.getRelativeLocation)(this.gridview.orientation, location_2, target);
935
- this.doAddGroup(group, relativeLocation);
936
- return group;
937
- }
938
- else {
939
- this.doAddGroup(group);
940
- return group;
941
- }
942
- };
943
- DockviewComponent.prototype.removeGroup = function (group, options) {
944
- var e_12, _a;
945
- var _b;
946
- var panels = __spreadArray([], __read(group.panels), false); // reassign since group panels will mutate
947
- try {
948
- for (var panels_1 = __values(panels), panels_1_1 = panels_1.next(); !panels_1_1.done; panels_1_1 = panels_1.next()) {
949
- var panel = panels_1_1.value;
950
- this.removePanel(panel, {
951
- removeEmptyGroup: false,
952
- skipDispose: (_b = options === null || options === void 0 ? void 0 : options.skipDispose) !== null && _b !== void 0 ? _b : false,
953
- });
954
- }
955
- }
956
- catch (e_12_1) { e_12 = { error: e_12_1 }; }
957
- finally {
958
- try {
959
- if (panels_1_1 && !panels_1_1.done && (_a = panels_1.return)) _a.call(panels_1);
960
- }
961
- finally { if (e_12) throw e_12.error; }
962
- }
963
- this.doRemoveGroup(group, options);
964
- };
965
- DockviewComponent.prototype.doRemoveGroup = function (group, options) {
966
- var floatingGroup = this.floatingGroups.find(function (_) { return _.group === group; });
967
- if (floatingGroup) {
968
- if (!(options === null || options === void 0 ? void 0 : options.skipDispose)) {
969
- floatingGroup.group.dispose();
970
- this._groups.delete(group.id);
971
- // TODO: fire group removed event?
972
- }
973
- floatingGroup.dispose();
974
- return floatingGroup.group;
975
- }
976
- return _super.prototype.doRemoveGroup.call(this, group, options);
977
- };
978
- DockviewComponent.prototype.moveGroupOrPanel = function (destinationGroup, sourceGroupId, sourceItemId, destinationTarget, destinationIndex) {
979
- var _a;
980
- var sourceGroup = sourceGroupId
981
- ? (_a = this._groups.get(sourceGroupId)) === null || _a === void 0 ? void 0 : _a.value
982
- : undefined;
983
- if (sourceItemId === undefined) {
984
- if (sourceGroup) {
985
- this.moveGroup(sourceGroup, destinationGroup, destinationTarget);
986
- }
987
- return;
988
- }
989
- if (!destinationTarget || destinationTarget === 'center') {
990
- var groupItem = (sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(sourceItemId)) ||
991
- this.panels.find(function (panel) { return panel.id === sourceItemId; });
992
- if (!groupItem) {
993
- throw new Error("No panel with id ".concat(sourceItemId));
994
- }
995
- if ((sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.size) === 0) {
996
- this.doRemoveGroup(sourceGroup);
997
- }
998
- destinationGroup.model.openPanel(groupItem, {
999
- index: destinationIndex,
1000
- });
1001
- }
1002
- else {
1003
- var referenceLocation = (0, gridview_1.getGridLocation)(destinationGroup.element);
1004
- var targetLocation = (0, gridview_1.getRelativeLocation)(this.gridview.orientation, referenceLocation, destinationTarget);
1005
- if (sourceGroup && sourceGroup.size < 2) {
1006
- var _b = __read((0, array_1.tail)(targetLocation), 2), targetParentLocation = _b[0], to = _b[1];
1007
- var isFloating = this.floatingGroups.find(function (x) { return x.group === sourceGroup; });
1008
- if (!isFloating) {
1009
- var sourceLocation = (0, gridview_1.getGridLocation)(sourceGroup.element);
1010
- var _c = __read((0, array_1.tail)(sourceLocation), 2), sourceParentLocation = _c[0], from = _c[1];
1011
- if ((0, array_1.sequenceEquals)(sourceParentLocation, targetParentLocation)) {
1012
- // special case when 'swapping' two views within same grid location
1013
- // if a group has one tab - we are essentially moving the 'group'
1014
- // which is equivalent to swapping two views in this case
1015
- this.gridview.moveView(sourceParentLocation, from, to);
1016
- }
1017
- }
1018
- // source group will become empty so delete the group
1019
- var targetGroup = this.doRemoveGroup(sourceGroup, {
1020
- skipActive: true,
1021
- skipDispose: true,
1022
- });
1023
- // after deleting the group we need to re-evaulate the ref location
1024
- var updatedReferenceLocation = (0, gridview_1.getGridLocation)(destinationGroup.element);
1025
- var location_3 = (0, gridview_1.getRelativeLocation)(this.gridview.orientation, updatedReferenceLocation, destinationTarget);
1026
- this.doAddGroup(targetGroup, location_3);
1027
- }
1028
- else {
1029
- var groupItem = (sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(sourceItemId)) ||
1030
- this.panels.find(function (panel) { return panel.id === sourceItemId; });
1031
- if (!groupItem) {
1032
- throw new Error("No panel with id ".concat(sourceItemId));
1033
- }
1034
- var dropLocation = (0, gridview_1.getRelativeLocation)(this.gridview.orientation, referenceLocation, destinationTarget);
1035
- var group = this.createGroupAtLocation(dropLocation);
1036
- group.model.openPanel(groupItem);
1037
- }
1038
- }
1039
- };
1040
- DockviewComponent.prototype.moveGroup = function (sourceGroup, referenceGroup, target) {
1041
- var e_13, _a;
1042
- if (sourceGroup) {
1043
- if (!target || target === 'center') {
1044
- var activePanel = sourceGroup.activePanel;
1045
- var panels = __spreadArray([], __read(sourceGroup.panels), false).map(function (p) {
1046
- return sourceGroup.model.removePanel(p.id);
1047
- });
1048
- if ((sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.size) === 0) {
1049
- this.doRemoveGroup(sourceGroup);
1050
- }
1051
- try {
1052
- for (var panels_2 = __values(panels), panels_2_1 = panels_2.next(); !panels_2_1.done; panels_2_1 = panels_2.next()) {
1053
- var panel = panels_2_1.value;
1054
- referenceGroup.model.openPanel(panel, {
1055
- skipSetPanelActive: panel !== activePanel,
1056
- });
1057
- }
1058
- }
1059
- catch (e_13_1) { e_13 = { error: e_13_1 }; }
1060
- finally {
1061
- try {
1062
- if (panels_2_1 && !panels_2_1.done && (_a = panels_2.return)) _a.call(panels_2);
1063
- }
1064
- finally { if (e_13) throw e_13.error; }
1065
- }
1066
- }
1067
- else {
1068
- var floatingGroup = this.floatingGroups.find(function (x) { return x.group === sourceGroup; });
1069
- if (floatingGroup) {
1070
- floatingGroup.dispose();
1071
- }
1072
- else {
1073
- this.gridview.removeView((0, gridview_1.getGridLocation)(sourceGroup.element));
1074
- }
1075
- var referenceLocation = (0, gridview_1.getGridLocation)(referenceGroup.element);
1076
- var dropLocation = (0, gridview_1.getRelativeLocation)(this.gridview.orientation, referenceLocation, target);
1077
- this.gridview.addView(sourceGroup, splitview_1.Sizing.Distribute, dropLocation);
1078
- }
1079
- }
1080
- };
1081
- DockviewComponent.prototype.doSetGroupActive = function (group, skipFocus) {
1082
- var _a, _b;
1083
- var isGroupAlreadyFocused = this._activeGroup === group;
1084
- _super.prototype.doSetGroupActive.call(this, group, skipFocus);
1085
- if (!isGroupAlreadyFocused && ((_a = this._activeGroup) === null || _a === void 0 ? void 0 : _a.activePanel)) {
1086
- this._onDidActivePanelChange.fire((_b = this._activeGroup) === null || _b === void 0 ? void 0 : _b.activePanel);
1087
- }
1088
- };
1089
- DockviewComponent.prototype.createGroup = function (options) {
1090
- var _this = this;
1091
- if (!options) {
1092
- options = {};
1093
- }
1094
- var id = options === null || options === void 0 ? void 0 : options.id;
1095
- if (id && this._groups.has(options.id)) {
1096
- console.warn("Duplicate group id ".concat(options === null || options === void 0 ? void 0 : options.id, ". reassigning group id to avoid errors"));
1097
- id = undefined;
1098
- }
1099
- if (!id) {
1100
- id = this.nextGroupId.next();
1101
- while (this._groups.has(id)) {
1102
- id = this.nextGroupId.next();
1103
- }
1104
- }
1105
- var view = new dockviewGroupPanel_1.DockviewGroupPanel(this, id, options);
1106
- view.init({ params: {}, accessor: null }); // required to initialized .part and allow for correct disposal of group
1107
- if (!this._groups.has(view.id)) {
1108
- var disposable = new lifecycle_1.CompositeDisposable(view.model.onTabDragStart(function (event) {
1109
- _this._onWillDragPanel.fire(event);
1110
- }), view.model.onGroupDragStart(function (event) {
1111
- _this._onWillDragGroup.fire(event);
1112
- }), view.model.onMove(function (event) {
1113
- var groupId = event.groupId, itemId = event.itemId, target = event.target, index = event.index;
1114
- _this.moveGroupOrPanel(view, groupId, itemId, target, index);
1115
- }), view.model.onDidDrop(function (event) {
1116
- _this._onDidDrop.fire(__assign(__assign({}, event), { api: _this._api, group: view }));
1117
- }), view.model.onDidAddPanel(function (event) {
1118
- _this._onDidAddPanel.fire(event.panel);
1119
- }), view.model.onDidRemovePanel(function (event) {
1120
- _this._onDidRemovePanel.fire(event.panel);
1121
- }), view.model.onDidActivePanelChange(function (event) {
1122
- _this._onDidActivePanelChange.fire(event.panel);
1123
- }));
1124
- this._groups.set(view.id, { value: view, disposable: disposable });
1125
- }
1126
- // TODO: must be called after the above listeners have been setup,
1127
- // not an ideal pattern
1128
- view.initialize();
1129
- return view;
1130
- };
1131
- DockviewComponent.prototype.createPanel = function (options, group) {
1132
- var contentComponent = options.component;
1133
- var tabComponent = options.tabComponent || this.options.defaultTabComponent;
1134
- var view = new dockviewPanelModel_1.DockviewPanelModel(this, options.id, contentComponent, tabComponent);
1135
- var panel = new dockviewPanel_1.DockviewPanel(options.id, this, this._api, group, view);
1136
- panel.init({
1137
- title: options.title || options.id,
1138
- params: (options === null || options === void 0 ? void 0 : options.params) || {},
1139
- });
1140
- return panel;
1141
- };
1142
- DockviewComponent.prototype.createGroupAtLocation = function (location) {
1143
- if (location === void 0) { location = [0]; }
1144
- var group = this.createGroup();
1145
- this.doAddGroup(group, location);
1146
- return group;
1147
- };
1148
- DockviewComponent.prototype.findGroup = function (panel) {
1149
- var _a;
1150
- return (_a = Array.from(this._groups.values()).find(function (group) {
1151
- return group.value.model.containsPanel(panel);
1152
- })) === null || _a === void 0 ? void 0 : _a.value;
1153
- };
1154
- return DockviewComponent;
1155
- }(baseComponentGridview_1.BaseGrid));
1156
- exports.DockviewComponent = DockviewComponent;
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __assign = (this && this.__assign) || function () {
18
+ __assign = Object.assign || function(t) {
19
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
20
+ s = arguments[i];
21
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
22
+ t[p] = s[p];
23
+ }
24
+ return t;
25
+ };
26
+ return __assign.apply(this, arguments);
27
+ };
28
+ var __values = (this && this.__values) || function(o) {
29
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
30
+ if (m) return m.call(o);
31
+ if (o && typeof o.length === "number") return {
32
+ next: function () {
33
+ if (o && i >= o.length) o = void 0;
34
+ return { value: o && o[i++], done: !o };
35
+ }
36
+ };
37
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
38
+ };
39
+ var __read = (this && this.__read) || function (o, n) {
40
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
41
+ if (!m) return o;
42
+ var i = m.call(o), r, ar = [], e;
43
+ try {
44
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
45
+ }
46
+ catch (error) { e = { error: error }; }
47
+ finally {
48
+ try {
49
+ if (r && !r.done && (m = i["return"])) m.call(i);
50
+ }
51
+ finally { if (e) throw e.error; }
52
+ }
53
+ return ar;
54
+ };
55
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
56
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
57
+ if (ar || !(i in from)) {
58
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
59
+ ar[i] = from[i];
60
+ }
61
+ }
62
+ return to.concat(ar || Array.prototype.slice.call(from));
63
+ };
64
+ Object.defineProperty(exports, "__esModule", { value: true });
65
+ exports.DockviewComponent = void 0;
66
+ var gridview_1 = require("../gridview/gridview");
67
+ var droptarget_1 = require("../dnd/droptarget");
68
+ var array_1 = require("../array");
69
+ var dockviewPanel_1 = require("./dockviewPanel");
70
+ var lifecycle_1 = require("../lifecycle");
71
+ var events_1 = require("../events");
72
+ var watermark_1 = require("./components/watermark/watermark");
73
+ var types_1 = require("./types");
74
+ var math_1 = require("../math");
75
+ var deserializer_1 = require("./deserializer");
76
+ var componentFactory_1 = require("../panel/componentFactory");
77
+ var options_1 = require("./options");
78
+ var baseComponentGridview_1 = require("../gridview/baseComponentGridview");
79
+ var component_api_1 = require("../api/component.api");
80
+ var splitview_1 = require("../splitview/splitview");
81
+ var dockviewGroupPanel_1 = require("./dockviewGroupPanel");
82
+ var dockviewPanelModel_1 = require("./dockviewPanelModel");
83
+ var dataTransfer_1 = require("../dnd/dataTransfer");
84
+ var overlay_1 = require("../dnd/overlay");
85
+ var dom_1 = require("../dom");
86
+ var dockviewFloatingGroupPanel_1 = require("./dockviewFloatingGroupPanel");
87
+ var DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE = 100;
88
+ function typeValidate3(data, path) {
89
+ if (typeof data.id !== 'string') {
90
+ throw new Error("".concat(path, ".id must be a string"));
91
+ }
92
+ if (typeof data.activeView !== 'string' ||
93
+ typeof data.activeView !== 'undefined') {
94
+ throw new Error("".concat(path, ".activeView must be a string of undefined"));
95
+ }
96
+ }
97
+ function typeValidate2(data, path) {
98
+ if (typeof data.size !== 'number' && typeof data.size !== 'undefined') {
99
+ throw new Error("".concat(path, ".size must be a number or undefined"));
100
+ }
101
+ if (typeof data.visible !== 'boolean' &&
102
+ typeof data.visible !== 'undefined') {
103
+ throw new Error("".concat(path, ".visible must be a boolean or undefined"));
104
+ }
105
+ if (data.type === 'leaf') {
106
+ if (typeof data.data !== 'object' ||
107
+ data.data === null ||
108
+ Array.isArray(data.data)) {
109
+ throw new Error('object must be a non-null object');
110
+ }
111
+ typeValidate3(data.data, "".concat(path, ".data"));
112
+ }
113
+ else if (data.type === 'branch') {
114
+ if (!Array.isArray(data.data)) {
115
+ throw new Error("".concat(path, ".data must be an array"));
116
+ }
117
+ }
118
+ else {
119
+ throw new Error("".concat(path, ".type must be onew of {'branch', 'leaf'}"));
120
+ }
121
+ }
122
+ function typeValidate(data) {
123
+ if (typeof data !== 'object' || data === null) {
124
+ throw new Error('object must be a non-null object');
125
+ }
126
+ var grid = data.grid, panels = data.panels, activeGroup = data.activeGroup, floatingGroups = data.floatingGroups;
127
+ if (typeof grid !== 'object' || grid === null) {
128
+ throw new Error("'.grid' must be a non-null object");
129
+ }
130
+ if (typeof grid.height !== 'number') {
131
+ throw new Error("'.grid.height' must be a number");
132
+ }
133
+ if (typeof grid.width !== 'number') {
134
+ throw new Error("'.grid.width' must be a number");
135
+ }
136
+ if (typeof grid.root !== 'object' || grid.root === null) {
137
+ throw new Error("'.grid.root' must be a non-null object");
138
+ }
139
+ if (grid.root.type !== 'branch') {
140
+ throw new Error(".grid.root.type must be of type 'branch'");
141
+ }
142
+ if (grid.orientation !== splitview_1.Orientation.HORIZONTAL &&
143
+ grid.orientation !== splitview_1.Orientation.VERTICAL) {
144
+ throw new Error("'.grid.width' must be one of {".concat(splitview_1.Orientation.HORIZONTAL, ", ").concat(splitview_1.Orientation.VERTICAL, "}"));
145
+ }
146
+ typeValidate2(grid.root, '.grid.root');
147
+ }
148
+ var DockviewComponent = /** @class */ (function (_super) {
149
+ __extends(DockviewComponent, _super);
150
+ function DockviewComponent(options) {
151
+ var _a;
152
+ var _this = _super.call(this, {
153
+ proportionalLayout: true,
154
+ orientation: (_a = options.orientation) !== null && _a !== void 0 ? _a : splitview_1.Orientation.HORIZONTAL,
155
+ styles: options.styles,
156
+ parentElement: options.parentElement,
157
+ disableAutoResizing: options.disableAutoResizing,
158
+ }) || this;
159
+ _this.nextGroupId = (0, math_1.sequentialNumberGenerator)();
160
+ _this._deserializer = new deserializer_1.DefaultDockviewDeserialzier(_this);
161
+ _this.watermark = null;
162
+ _this._onWillDragPanel = new events_1.Emitter();
163
+ _this.onWillDragPanel = _this._onWillDragPanel.event;
164
+ _this._onWillDragGroup = new events_1.Emitter();
165
+ _this.onWillDragGroup = _this._onWillDragGroup.event;
166
+ _this._onDidDrop = new events_1.Emitter();
167
+ _this.onDidDrop = _this._onDidDrop.event;
168
+ _this._onDidRemovePanel = new events_1.Emitter();
169
+ _this.onDidRemovePanel = _this._onDidRemovePanel.event;
170
+ _this._onDidAddPanel = new events_1.Emitter();
171
+ _this.onDidAddPanel = _this._onDidAddPanel.event;
172
+ _this._onDidLayoutFromJSON = new events_1.Emitter();
173
+ _this.onDidLayoutFromJSON = _this._onDidLayoutFromJSON.event;
174
+ _this._onDidActivePanelChange = new events_1.Emitter();
175
+ _this.onDidActivePanelChange = _this._onDidActivePanelChange.event;
176
+ _this.floatingGroups = [];
177
+ (0, dom_1.toggleClass)(_this.gridview.element, 'dv-dockview', true);
178
+ _this.addDisposables(_this._onWillDragPanel, _this._onWillDragGroup, _this._onDidActivePanelChange, _this._onDidAddPanel, _this._onDidRemovePanel, _this._onDidLayoutFromJSON, _this._onDidDrop, events_1.Event.any(_this.onDidAddGroup, _this.onDidRemoveGroup)(function () {
179
+ _this.updateWatermark();
180
+ }), events_1.Event.any(_this.onDidAddPanel, _this.onDidRemovePanel, _this.onDidActivePanelChange)(function () {
181
+ _this._bufferOnDidLayoutChange.fire();
182
+ }));
183
+ _this._options = options;
184
+ if (!_this.options.components) {
185
+ _this.options.components = {};
186
+ }
187
+ if (!_this.options.frameworkComponents) {
188
+ _this.options.frameworkComponents = {};
189
+ }
190
+ if (!_this.options.frameworkTabComponents) {
191
+ _this.options.frameworkTabComponents = {};
192
+ }
193
+ if (!_this.options.tabComponents) {
194
+ _this.options.tabComponents = {};
195
+ }
196
+ if (!_this.options.watermarkComponent &&
197
+ !_this.options.watermarkFrameworkComponent) {
198
+ _this.options.watermarkComponent = watermark_1.Watermark;
199
+ }
200
+ var dropTarget = new droptarget_1.Droptarget(_this.element, {
201
+ canDisplayOverlay: function (event, position) {
202
+ var data = (0, dataTransfer_1.getPanelData)();
203
+ if (data) {
204
+ if (data.viewId !== _this.id) {
205
+ return false;
206
+ }
207
+ if (position === 'center') {
208
+ // center drop target is only allowed if there are no panels in the grid
209
+ // floating panels are allowed
210
+ return _this.gridview.length === 0;
211
+ }
212
+ return true;
213
+ }
214
+ if (_this.options.showDndOverlay) {
215
+ if (position === 'center' && _this.gridview.length !== 0) {
216
+ /**
217
+ * for external events only show the four-corner drag overlays, disable
218
+ * the center position so that external drag events can fall through to the group
219
+ * and panel drop target handlers
220
+ */
221
+ return false;
222
+ }
223
+ return _this.options.showDndOverlay({
224
+ nativeEvent: event,
225
+ position: position,
226
+ target: types_1.DockviewDropTargets.Edge,
227
+ getData: dataTransfer_1.getPanelData,
228
+ });
229
+ }
230
+ return false;
231
+ },
232
+ acceptedTargetZones: ['top', 'bottom', 'left', 'right', 'center'],
233
+ overlayModel: {
234
+ activationSize: { type: 'pixels', value: 10 },
235
+ size: { type: 'pixels', value: 20 },
236
+ },
237
+ });
238
+ _this.addDisposables(dropTarget.onDrop(function (event) {
239
+ var _a;
240
+ var data = (0, dataTransfer_1.getPanelData)();
241
+ if (data) {
242
+ _this.moveGroupOrPanel(_this.orthogonalize(event.position), data.groupId, (_a = data.panelId) !== null && _a !== void 0 ? _a : undefined, 'center');
243
+ }
244
+ else {
245
+ _this._onDidDrop.fire(__assign(__assign({}, event), { api: _this._api, group: null, getData: dataTransfer_1.getPanelData }));
246
+ }
247
+ }), dropTarget);
248
+ _this._api = new component_api_1.DockviewApi(_this);
249
+ _this.updateWatermark();
250
+ return _this;
251
+ }
252
+ Object.defineProperty(DockviewComponent.prototype, "orientation", {
253
+ get: function () {
254
+ return this.gridview.orientation;
255
+ },
256
+ enumerable: false,
257
+ configurable: true
258
+ });
259
+ Object.defineProperty(DockviewComponent.prototype, "totalPanels", {
260
+ get: function () {
261
+ return this.panels.length;
262
+ },
263
+ enumerable: false,
264
+ configurable: true
265
+ });
266
+ Object.defineProperty(DockviewComponent.prototype, "panels", {
267
+ get: function () {
268
+ return this.groups.flatMap(function (group) { return group.panels; });
269
+ },
270
+ enumerable: false,
271
+ configurable: true
272
+ });
273
+ Object.defineProperty(DockviewComponent.prototype, "options", {
274
+ get: function () {
275
+ return this._options;
276
+ },
277
+ enumerable: false,
278
+ configurable: true
279
+ });
280
+ Object.defineProperty(DockviewComponent.prototype, "activePanel", {
281
+ get: function () {
282
+ var activeGroup = this.activeGroup;
283
+ if (!activeGroup) {
284
+ return undefined;
285
+ }
286
+ return activeGroup.activePanel;
287
+ },
288
+ enumerable: false,
289
+ configurable: true
290
+ });
291
+ DockviewComponent.prototype.addFloatingGroup = function (item, coord, options) {
292
+ var _this = this;
293
+ var _a, _b, _c, _d, _e, _f;
294
+ var group;
295
+ if (item instanceof dockviewPanel_1.DockviewPanel) {
296
+ group = this.createGroup();
297
+ this.removePanel(item, {
298
+ removeEmptyGroup: true,
299
+ skipDispose: true,
300
+ });
301
+ group.model.openPanel(item);
302
+ }
303
+ else {
304
+ group = item;
305
+ var skip = typeof (options === null || options === void 0 ? void 0 : options.skipRemoveGroup) === 'boolean' &&
306
+ options.skipRemoveGroup;
307
+ if (!skip) {
308
+ this.doRemoveGroup(item, { skipDispose: true });
309
+ }
310
+ }
311
+ group.model.isFloating = true;
312
+ var overlayLeft = typeof (coord === null || coord === void 0 ? void 0 : coord.x) === 'number' ? Math.max(coord.x, 0) : 100;
313
+ var overlayTop = typeof (coord === null || coord === void 0 ? void 0 : coord.y) === 'number' ? Math.max(coord.y, 0) : 100;
314
+ var overlay = new overlay_1.Overlay({
315
+ container: this.gridview.element,
316
+ content: group.element,
317
+ height: (_a = coord === null || coord === void 0 ? void 0 : coord.height) !== null && _a !== void 0 ? _a : 300,
318
+ width: (_b = coord === null || coord === void 0 ? void 0 : coord.width) !== null && _b !== void 0 ? _b : 300,
319
+ left: overlayLeft,
320
+ top: overlayTop,
321
+ minimumInViewportWidth: this.options.floatingGroupBounds === 'boundedWithinViewport'
322
+ ? undefined
323
+ : (_d = (_c = this.options.floatingGroupBounds) === null || _c === void 0 ? void 0 : _c.minimumWidthWithinViewport) !== null && _d !== void 0 ? _d : DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE,
324
+ minimumInViewportHeight: this.options.floatingGroupBounds === 'boundedWithinViewport'
325
+ ? undefined
326
+ : (_f = (_e = this.options.floatingGroupBounds) === null || _e === void 0 ? void 0 : _e.minimumHeightWithinViewport) !== null && _f !== void 0 ? _f : DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE,
327
+ });
328
+ var el = group.element.querySelector('.void-container');
329
+ if (!el) {
330
+ throw new Error('failed to find drag handle');
331
+ }
332
+ overlay.setupDrag(el, {
333
+ inDragMode: typeof (options === null || options === void 0 ? void 0 : options.inDragMode) === 'boolean'
334
+ ? options.inDragMode
335
+ : false,
336
+ });
337
+ var floatingGroupPanel = new dockviewFloatingGroupPanel_1.DockviewFloatingGroupPanel(group, overlay);
338
+ var disposable = (0, dom_1.watchElementResize)(group.element, function (entry) {
339
+ var _a = entry.contentRect, width = _a.width, height = _a.height;
340
+ group.layout(width, height); // let the group know it's size is changing so it can fire events to the panel
341
+ });
342
+ floatingGroupPanel.addDisposables(overlay.onDidChange(function () {
343
+ // this is either a resize or a move
344
+ // to inform the panels .layout(...) the group with it's current size
345
+ // don't care about resize since the above watcher handles that
346
+ group.layout(group.height, group.width);
347
+ }), overlay.onDidChangeEnd(function () {
348
+ _this._bufferOnDidLayoutChange.fire();
349
+ }), group.onDidChange(function (event) {
350
+ overlay.setBounds({
351
+ height: event === null || event === void 0 ? void 0 : event.height,
352
+ width: event === null || event === void 0 ? void 0 : event.width,
353
+ });
354
+ }), {
355
+ dispose: function () {
356
+ disposable.dispose();
357
+ group.model.isFloating = false;
358
+ (0, array_1.remove)(_this.floatingGroups, floatingGroupPanel);
359
+ _this.updateWatermark();
360
+ },
361
+ });
362
+ this.floatingGroups.push(floatingGroupPanel);
363
+ this.updateWatermark();
364
+ };
365
+ DockviewComponent.prototype.orthogonalize = function (position) {
366
+ switch (position) {
367
+ case 'top':
368
+ case 'bottom':
369
+ if (this.gridview.orientation === splitview_1.Orientation.HORIZONTAL) {
370
+ // we need to add to a vertical splitview but the current root is a horizontal splitview.
371
+ // insert a vertical splitview at the root level and add the existing view as a child
372
+ this.gridview.insertOrthogonalSplitviewAtRoot();
373
+ }
374
+ break;
375
+ case 'left':
376
+ case 'right':
377
+ if (this.gridview.orientation === splitview_1.Orientation.VERTICAL) {
378
+ // we need to add to a horizontal splitview but the current root is a vertical splitview.
379
+ // insert a horiziontal splitview at the root level and add the existing view as a child
380
+ this.gridview.insertOrthogonalSplitviewAtRoot();
381
+ }
382
+ break;
383
+ default:
384
+ break;
385
+ }
386
+ switch (position) {
387
+ case 'top':
388
+ case 'left':
389
+ case 'center':
390
+ return this.createGroupAtLocation([0]); // insert into first position
391
+ case 'bottom':
392
+ case 'right':
393
+ return this.createGroupAtLocation([this.gridview.length]); // insert into last position
394
+ default:
395
+ throw new Error("unsupported position ".concat(position));
396
+ }
397
+ };
398
+ DockviewComponent.prototype.updateOptions = function (options) {
399
+ var e_1, _a;
400
+ var _b, _c;
401
+ var hasOrientationChanged = typeof options.orientation === 'string' &&
402
+ this.gridview.orientation !== options.orientation;
403
+ var hasFloatingGroupOptionsChanged = options.floatingGroupBounds !== undefined &&
404
+ options.floatingGroupBounds !== this.options.floatingGroupBounds;
405
+ this._options = __assign(__assign({}, this.options), options);
406
+ if (hasOrientationChanged) {
407
+ this.gridview.orientation = options.orientation;
408
+ }
409
+ if (hasFloatingGroupOptionsChanged) {
410
+ try {
411
+ for (var _d = __values(this.floatingGroups), _e = _d.next(); !_e.done; _e = _d.next()) {
412
+ var group = _e.value;
413
+ switch (this.options.floatingGroupBounds) {
414
+ case 'boundedWithinViewport':
415
+ group.overlay.minimumInViewportHeight = undefined;
416
+ group.overlay.minimumInViewportWidth = undefined;
417
+ break;
418
+ case undefined:
419
+ group.overlay.minimumInViewportHeight =
420
+ DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE;
421
+ group.overlay.minimumInViewportWidth =
422
+ DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE;
423
+ break;
424
+ default:
425
+ group.overlay.minimumInViewportHeight =
426
+ (_b = this.options.floatingGroupBounds) === null || _b === void 0 ? void 0 : _b.minimumHeightWithinViewport;
427
+ group.overlay.minimumInViewportWidth =
428
+ (_c = this.options.floatingGroupBounds) === null || _c === void 0 ? void 0 : _c.minimumWidthWithinViewport;
429
+ }
430
+ group.overlay.setBounds({});
431
+ }
432
+ }
433
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
434
+ finally {
435
+ try {
436
+ if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
437
+ }
438
+ finally { if (e_1) throw e_1.error; }
439
+ }
440
+ }
441
+ this.layout(this.gridview.width, this.gridview.height, true);
442
+ };
443
+ DockviewComponent.prototype.layout = function (width, height, forceResize) {
444
+ var e_2, _a;
445
+ _super.prototype.layout.call(this, width, height, forceResize);
446
+ if (this.floatingGroups) {
447
+ try {
448
+ for (var _b = __values(this.floatingGroups), _c = _b.next(); !_c.done; _c = _b.next()) {
449
+ var floating = _c.value;
450
+ // ensure floting groups stay within visible boundaries
451
+ floating.overlay.setBounds();
452
+ }
453
+ }
454
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
455
+ finally {
456
+ try {
457
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
458
+ }
459
+ finally { if (e_2) throw e_2.error; }
460
+ }
461
+ }
462
+ };
463
+ DockviewComponent.prototype.focus = function () {
464
+ var _a;
465
+ (_a = this.activeGroup) === null || _a === void 0 ? void 0 : _a.focus();
466
+ };
467
+ DockviewComponent.prototype.getGroupPanel = function (id) {
468
+ return this.panels.find(function (panel) { return panel.id === id; });
469
+ };
470
+ DockviewComponent.prototype.setActivePanel = function (panel) {
471
+ this.doSetGroupActive(panel.group);
472
+ panel.group.model.openPanel(panel);
473
+ };
474
+ DockviewComponent.prototype.moveToNext = function (options) {
475
+ var _a;
476
+ if (options === void 0) { options = {}; }
477
+ if (!options.group) {
478
+ if (!this.activeGroup) {
479
+ return;
480
+ }
481
+ options.group = this.activeGroup;
482
+ }
483
+ if (options.includePanel && options.group) {
484
+ if (options.group.activePanel !==
485
+ options.group.panels[options.group.panels.length - 1]) {
486
+ options.group.model.moveToNext({ suppressRoll: true });
487
+ return;
488
+ }
489
+ }
490
+ var location = (0, gridview_1.getGridLocation)(options.group.element);
491
+ var next = (_a = this.gridview.next(location)) === null || _a === void 0 ? void 0 : _a.view;
492
+ this.doSetGroupAndPanelActive(next);
493
+ };
494
+ DockviewComponent.prototype.moveToPrevious = function (options) {
495
+ var _a;
496
+ if (options === void 0) { options = {}; }
497
+ if (!options.group) {
498
+ if (!this.activeGroup) {
499
+ return;
500
+ }
501
+ options.group = this.activeGroup;
502
+ }
503
+ if (options.includePanel && options.group) {
504
+ if (options.group.activePanel !== options.group.panels[0]) {
505
+ options.group.model.moveToPrevious({ suppressRoll: true });
506
+ return;
507
+ }
508
+ }
509
+ var location = (0, gridview_1.getGridLocation)(options.group.element);
510
+ var next = (_a = this.gridview.previous(location)) === null || _a === void 0 ? void 0 : _a.view;
511
+ if (next) {
512
+ this.doSetGroupAndPanelActive(next);
513
+ }
514
+ };
515
+ /**
516
+ * Serialize the current state of the layout
517
+ *
518
+ * @returns A JSON respresentation of the layout
519
+ */
520
+ DockviewComponent.prototype.toJSON = function () {
521
+ var _a;
522
+ var data = this.gridview.serialize();
523
+ var panels = this.panels.reduce(function (collection, panel) {
524
+ collection[panel.id] = panel.toJSON();
525
+ return collection;
526
+ }, {});
527
+ var floats = this.floatingGroups.map(function (floatingGroup) {
528
+ return {
529
+ data: floatingGroup.group.toJSON(),
530
+ position: floatingGroup.overlay.toJSON(),
531
+ };
532
+ });
533
+ var result = {
534
+ grid: data,
535
+ panels: panels,
536
+ activeGroup: (_a = this.activeGroup) === null || _a === void 0 ? void 0 : _a.id,
537
+ };
538
+ if (floats.length > 0) {
539
+ result.floatingGroups = floats;
540
+ }
541
+ return result;
542
+ };
543
+ DockviewComponent.prototype.fromJSON = function (data) {
544
+ var e_3, _a, e_4, _b, e_5, _c, e_6, _d, e_7, _e, e_8, _f;
545
+ var _this = this;
546
+ var _g;
547
+ this.clear();
548
+ if (typeof data !== 'object' || data === null) {
549
+ throw new Error('serialized layout must be a non-null object');
550
+ }
551
+ var grid = data.grid, panels = data.panels, activeGroup = data.activeGroup;
552
+ if (grid.root.type !== 'branch' || !Array.isArray(grid.root.data)) {
553
+ throw new Error('root must be of type branch');
554
+ }
555
+ try {
556
+ // take note of the existing dimensions
557
+ var width = this.width;
558
+ var height = this.height;
559
+ var createGroupFromSerializedState_1 = function (data) {
560
+ var e_9, _a;
561
+ var id = data.id, locked = data.locked, hideHeader = data.hideHeader, views = data.views, activeView = data.activeView;
562
+ if (typeof id !== 'string') {
563
+ throw new Error('group id must be of type string');
564
+ }
565
+ var group = _this.createGroup({
566
+ id: id,
567
+ locked: !!locked,
568
+ hideHeader: !!hideHeader,
569
+ });
570
+ var createdPanels = [];
571
+ try {
572
+ for (var views_1 = __values(views), views_1_1 = views_1.next(); !views_1_1.done; views_1_1 = views_1.next()) {
573
+ var child = views_1_1.value;
574
+ /**
575
+ * Run the deserializer step seperately since this may fail to due corrupted external state.
576
+ * In running this section first we avoid firing lots of 'add' events in the event of a failure
577
+ * due to a corruption of input data.
578
+ */
579
+ var panel = _this._deserializer.fromJSON(panels[child], group);
580
+ createdPanels.push(panel);
581
+ }
582
+ }
583
+ catch (e_9_1) { e_9 = { error: e_9_1 }; }
584
+ finally {
585
+ try {
586
+ if (views_1_1 && !views_1_1.done && (_a = views_1.return)) _a.call(views_1);
587
+ }
588
+ finally { if (e_9) throw e_9.error; }
589
+ }
590
+ _this._onDidAddGroup.fire(group);
591
+ for (var i = 0; i < views.length; i++) {
592
+ var panel = createdPanels[i];
593
+ var isActive = typeof activeView === 'string' &&
594
+ activeView === panel.id;
595
+ group.model.openPanel(panel, {
596
+ skipSetPanelActive: !isActive,
597
+ skipSetGroupActive: true,
598
+ });
599
+ }
600
+ if (!group.activePanel && group.panels.length > 0) {
601
+ group.model.openPanel(group.panels[group.panels.length - 1], {
602
+ skipSetGroupActive: true,
603
+ });
604
+ }
605
+ return group;
606
+ };
607
+ this.gridview.deserialize(grid, {
608
+ fromJSON: function (node) {
609
+ return createGroupFromSerializedState_1(node.data);
610
+ },
611
+ });
612
+ this.layout(width, height, true);
613
+ var serializedFloatingGroups = (_g = data.floatingGroups) !== null && _g !== void 0 ? _g : [];
614
+ try {
615
+ for (var serializedFloatingGroups_1 = __values(serializedFloatingGroups), serializedFloatingGroups_1_1 = serializedFloatingGroups_1.next(); !serializedFloatingGroups_1_1.done; serializedFloatingGroups_1_1 = serializedFloatingGroups_1.next()) {
616
+ var serializedFloatingGroup = serializedFloatingGroups_1_1.value;
617
+ var data_1 = serializedFloatingGroup.data, position = serializedFloatingGroup.position;
618
+ var group = createGroupFromSerializedState_1(data_1);
619
+ this.addFloatingGroup(group, {
620
+ x: position.left,
621
+ y: position.top,
622
+ height: position.height,
623
+ width: position.width,
624
+ }, { skipRemoveGroup: true, inDragMode: false });
625
+ }
626
+ }
627
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
628
+ finally {
629
+ try {
630
+ if (serializedFloatingGroups_1_1 && !serializedFloatingGroups_1_1.done && (_a = serializedFloatingGroups_1.return)) _a.call(serializedFloatingGroups_1);
631
+ }
632
+ finally { if (e_3) throw e_3.error; }
633
+ }
634
+ try {
635
+ for (var _h = __values(this.floatingGroups), _j = _h.next(); !_j.done; _j = _h.next()) {
636
+ var floatingGroup = _j.value;
637
+ floatingGroup.overlay.setBounds();
638
+ }
639
+ }
640
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
641
+ finally {
642
+ try {
643
+ if (_j && !_j.done && (_b = _h.return)) _b.call(_h);
644
+ }
645
+ finally { if (e_4) throw e_4.error; }
646
+ }
647
+ if (typeof activeGroup === 'string') {
648
+ var panel = this.getPanel(activeGroup);
649
+ if (panel) {
650
+ this.doSetGroupAndPanelActive(panel);
651
+ }
652
+ }
653
+ }
654
+ catch (err) {
655
+ try {
656
+ /**
657
+ * Takes all the successfully created groups and remove all of their panels.
658
+ */
659
+ for (var _k = __values(this.groups), _l = _k.next(); !_l.done; _l = _k.next()) {
660
+ var group = _l.value;
661
+ try {
662
+ for (var _m = (e_6 = void 0, __values(group.panels)), _o = _m.next(); !_o.done; _o = _m.next()) {
663
+ var panel = _o.value;
664
+ this.removePanel(panel, {
665
+ removeEmptyGroup: false,
666
+ skipDispose: false,
667
+ });
668
+ }
669
+ }
670
+ catch (e_6_1) { e_6 = { error: e_6_1 }; }
671
+ finally {
672
+ try {
673
+ if (_o && !_o.done && (_d = _m.return)) _d.call(_m);
674
+ }
675
+ finally { if (e_6) throw e_6.error; }
676
+ }
677
+ }
678
+ }
679
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
680
+ finally {
681
+ try {
682
+ if (_l && !_l.done && (_c = _k.return)) _c.call(_k);
683
+ }
684
+ finally { if (e_5) throw e_5.error; }
685
+ }
686
+ try {
687
+ /**
688
+ * To remove a group we cannot call this.removeGroup(...) since this makes assumptions about
689
+ * the underlying HTMLElement existing in the Gridview.
690
+ */
691
+ for (var _p = __values(this.groups), _q = _p.next(); !_q.done; _q = _p.next()) {
692
+ var group = _q.value;
693
+ group.dispose();
694
+ this._groups.delete(group.id);
695
+ this._onDidRemoveGroup.fire(group);
696
+ }
697
+ }
698
+ catch (e_7_1) { e_7 = { error: e_7_1 }; }
699
+ finally {
700
+ try {
701
+ if (_q && !_q.done && (_e = _p.return)) _e.call(_p);
702
+ }
703
+ finally { if (e_7) throw e_7.error; }
704
+ }
705
+ try {
706
+ // iterate over a reassigned array since original array will be modified
707
+ for (var _r = __values(__spreadArray([], __read(this.floatingGroups), false)), _s = _r.next(); !_s.done; _s = _r.next()) {
708
+ var floatingGroup = _s.value;
709
+ floatingGroup.dispose();
710
+ }
711
+ }
712
+ catch (e_8_1) { e_8 = { error: e_8_1 }; }
713
+ finally {
714
+ try {
715
+ if (_s && !_s.done && (_f = _r.return)) _f.call(_r);
716
+ }
717
+ finally { if (e_8) throw e_8.error; }
718
+ }
719
+ // fires clean-up events and clears the underlying HTML gridview.
720
+ this.clear();
721
+ /**
722
+ * even though we have cleaned-up we still want to inform the caller of their error
723
+ * and we'll do this through re-throwing the original error since afterall you would
724
+ * expect trying to load a corrupted layout to result in an error and not silently fail...
725
+ */
726
+ throw err;
727
+ }
728
+ this._onDidLayoutFromJSON.fire();
729
+ };
730
+ DockviewComponent.prototype.clear = function () {
731
+ var e_10, _a;
732
+ var groups = Array.from(this._groups.values()).map(function (_) { return _.value; });
733
+ var hasActiveGroup = !!this.activeGroup;
734
+ var hasActivePanel = !!this.activePanel;
735
+ try {
736
+ for (var groups_1 = __values(groups), groups_1_1 = groups_1.next(); !groups_1_1.done; groups_1_1 = groups_1.next()) {
737
+ var group = groups_1_1.value;
738
+ // remove the group will automatically remove the panels
739
+ this.removeGroup(group, { skipActive: true });
740
+ }
741
+ }
742
+ catch (e_10_1) { e_10 = { error: e_10_1 }; }
743
+ finally {
744
+ try {
745
+ if (groups_1_1 && !groups_1_1.done && (_a = groups_1.return)) _a.call(groups_1);
746
+ }
747
+ finally { if (e_10) throw e_10.error; }
748
+ }
749
+ if (hasActiveGroup) {
750
+ this.doSetGroupAndPanelActive(undefined);
751
+ }
752
+ if (hasActivePanel) {
753
+ this._onDidActivePanelChange.fire(undefined);
754
+ }
755
+ this.gridview.clear();
756
+ };
757
+ DockviewComponent.prototype.closeAllGroups = function () {
758
+ var e_11, _a;
759
+ try {
760
+ for (var _b = __values(this._groups.entries()), _c = _b.next(); !_c.done; _c = _b.next()) {
761
+ var entry = _c.value;
762
+ var _d = __read(entry, 2), _ = _d[0], group = _d[1];
763
+ group.value.model.closeAllPanels();
764
+ }
765
+ }
766
+ catch (e_11_1) { e_11 = { error: e_11_1 }; }
767
+ finally {
768
+ try {
769
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
770
+ }
771
+ finally { if (e_11) throw e_11.error; }
772
+ }
773
+ };
774
+ DockviewComponent.prototype.addPanel = function (options) {
775
+ var _a, _b;
776
+ if (this.panels.find(function (_) { return _.id === options.id; })) {
777
+ throw new Error("panel with id ".concat(options.id, " already exists"));
778
+ }
779
+ var referenceGroup;
780
+ if (options.position && options.floating) {
781
+ throw new Error('you can only provide one of: position, floating as arguments to .addPanel(...)');
782
+ }
783
+ if (options.position) {
784
+ if ((0, options_1.isPanelOptionsWithPanel)(options.position)) {
785
+ var referencePanel = typeof options.position.referencePanel === 'string'
786
+ ? this.getGroupPanel(options.position.referencePanel)
787
+ : options.position.referencePanel;
788
+ if (!referencePanel) {
789
+ throw new Error("referencePanel ".concat(options.position.referencePanel, " does not exist"));
790
+ }
791
+ referenceGroup = this.findGroup(referencePanel);
792
+ }
793
+ else if ((0, options_1.isPanelOptionsWithGroup)(options.position)) {
794
+ referenceGroup =
795
+ typeof options.position.referenceGroup === 'string'
796
+ ? (_a = this._groups.get(options.position.referenceGroup)) === null || _a === void 0 ? void 0 : _a.value
797
+ : options.position.referenceGroup;
798
+ if (!referenceGroup) {
799
+ throw new Error("referencePanel ".concat(options.position.referenceGroup, " does not exist"));
800
+ }
801
+ }
802
+ else {
803
+ var group = this.orthogonalize((0, droptarget_1.directionToPosition)(options.position.direction));
804
+ var panel_1 = this.createPanel(options, group);
805
+ group.model.openPanel(panel_1);
806
+ return panel_1;
807
+ }
808
+ }
809
+ else {
810
+ referenceGroup = this.activeGroup;
811
+ }
812
+ var panel;
813
+ if (referenceGroup) {
814
+ var target = (0, baseComponentGridview_1.toTarget)(((_b = options.position) === null || _b === void 0 ? void 0 : _b.direction) || 'within');
815
+ if (options.floating) {
816
+ var group = this.createGroup();
817
+ var o = typeof options.floating === 'object' &&
818
+ options.floating !== null
819
+ ? options.floating
820
+ : {};
821
+ this.addFloatingGroup(group, o, {
822
+ inDragMode: false,
823
+ skipRemoveGroup: true,
824
+ });
825
+ this._onDidAddGroup.fire(group);
826
+ panel = this.createPanel(options, group);
827
+ group.model.openPanel(panel);
828
+ this.doSetGroupAndPanelActive(group);
829
+ }
830
+ else if (referenceGroup.api.isFloating || target === 'center') {
831
+ panel = this.createPanel(options, referenceGroup);
832
+ referenceGroup.model.openPanel(panel);
833
+ }
834
+ else {
835
+ var location_1 = (0, gridview_1.getGridLocation)(referenceGroup.element);
836
+ var relativeLocation = (0, gridview_1.getRelativeLocation)(this.gridview.orientation, location_1, target);
837
+ var group = this.createGroupAtLocation(relativeLocation);
838
+ panel = this.createPanel(options, group);
839
+ group.model.openPanel(panel);
840
+ }
841
+ }
842
+ else if (options.floating) {
843
+ var group = this.createGroup();
844
+ var o = typeof options.floating === 'object' &&
845
+ options.floating !== null
846
+ ? options.floating
847
+ : {};
848
+ this.addFloatingGroup(group, o, {
849
+ inDragMode: false,
850
+ skipRemoveGroup: true,
851
+ });
852
+ this._onDidAddGroup.fire(group);
853
+ panel = this.createPanel(options, group);
854
+ group.model.openPanel(panel);
855
+ this.doSetGroupAndPanelActive(group);
856
+ }
857
+ else {
858
+ var group = this.createGroupAtLocation();
859
+ panel = this.createPanel(options, group);
860
+ group.model.openPanel(panel);
861
+ }
862
+ return panel;
863
+ };
864
+ DockviewComponent.prototype.removePanel = function (panel, options) {
865
+ if (options === void 0) { options = {
866
+ removeEmptyGroup: true,
867
+ skipDispose: false,
868
+ }; }
869
+ var group = panel.group;
870
+ if (!group) {
871
+ throw new Error("cannot remove panel ".concat(panel.id, ". it's missing a group."));
872
+ }
873
+ group.model.removePanel(panel);
874
+ if (!options.skipDispose) {
875
+ panel.dispose();
876
+ }
877
+ if (group.size === 0 && options.removeEmptyGroup) {
878
+ this.removeGroup(group);
879
+ }
880
+ };
881
+ DockviewComponent.prototype.createWatermarkComponent = function () {
882
+ var _a;
883
+ return (0, componentFactory_1.createComponent)('watermark-id', 'watermark-name', this.options.watermarkComponent
884
+ ? { 'watermark-name': this.options.watermarkComponent }
885
+ : {}, this.options.watermarkFrameworkComponent
886
+ ? { 'watermark-name': this.options.watermarkFrameworkComponent }
887
+ : {}, (_a = this.options.frameworkComponentFactory) === null || _a === void 0 ? void 0 : _a.watermark);
888
+ };
889
+ DockviewComponent.prototype.updateWatermark = function () {
890
+ var _a, _b;
891
+ if (this.groups.filter(function (x) { return !x.api.isFloating; }).length === 0) {
892
+ if (!this.watermark) {
893
+ this.watermark = this.createWatermarkComponent();
894
+ this.watermark.init({
895
+ containerApi: new component_api_1.DockviewApi(this),
896
+ });
897
+ var watermarkContainer = document.createElement('div');
898
+ watermarkContainer.className = 'dv-watermark-container';
899
+ watermarkContainer.appendChild(this.watermark.element);
900
+ this.gridview.element.appendChild(watermarkContainer);
901
+ }
902
+ }
903
+ else if (this.watermark) {
904
+ this.watermark.element.parentElement.remove();
905
+ (_b = (_a = this.watermark).dispose) === null || _b === void 0 ? void 0 : _b.call(_a);
906
+ this.watermark = null;
907
+ }
908
+ };
909
+ DockviewComponent.prototype.addGroup = function (options) {
910
+ var _a;
911
+ var group = this.createGroup();
912
+ if (options) {
913
+ var referenceGroup = void 0;
914
+ if ((0, options_1.isGroupOptionsWithPanel)(options)) {
915
+ var referencePanel = typeof options.referencePanel === 'string'
916
+ ? this.panels.find(function (panel) { return panel.id === options.referencePanel; })
917
+ : options.referencePanel;
918
+ if (!referencePanel) {
919
+ throw new Error("reference panel ".concat(options.referencePanel, " does not exist"));
920
+ }
921
+ referenceGroup = this.findGroup(referencePanel);
922
+ if (!referenceGroup) {
923
+ throw new Error("reference group for reference panel ".concat(options.referencePanel, " does not exist"));
924
+ }
925
+ }
926
+ else if ((0, options_1.isGroupOptionsWithGroup)(options)) {
927
+ referenceGroup =
928
+ typeof options.referenceGroup === 'string'
929
+ ? (_a = this._groups.get(options.referenceGroup)) === null || _a === void 0 ? void 0 : _a.value
930
+ : options.referenceGroup;
931
+ if (!referenceGroup) {
932
+ throw new Error("reference group ".concat(options.referenceGroup, " does not exist"));
933
+ }
934
+ }
935
+ else {
936
+ var group_1 = this.orthogonalize((0, droptarget_1.directionToPosition)(options.direction));
937
+ return group_1;
938
+ }
939
+ var target = (0, baseComponentGridview_1.toTarget)(options.direction || 'within');
940
+ var location_2 = (0, gridview_1.getGridLocation)(referenceGroup.element);
941
+ var relativeLocation = (0, gridview_1.getRelativeLocation)(this.gridview.orientation, location_2, target);
942
+ this.doAddGroup(group, relativeLocation);
943
+ return group;
944
+ }
945
+ else {
946
+ this.doAddGroup(group);
947
+ return group;
948
+ }
949
+ };
950
+ DockviewComponent.prototype.removeGroup = function (group, options) {
951
+ var e_12, _a;
952
+ var _b;
953
+ var panels = __spreadArray([], __read(group.panels), false); // reassign since group panels will mutate
954
+ try {
955
+ for (var panels_1 = __values(panels), panels_1_1 = panels_1.next(); !panels_1_1.done; panels_1_1 = panels_1.next()) {
956
+ var panel = panels_1_1.value;
957
+ this.removePanel(panel, {
958
+ removeEmptyGroup: false,
959
+ skipDispose: (_b = options === null || options === void 0 ? void 0 : options.skipDispose) !== null && _b !== void 0 ? _b : false,
960
+ });
961
+ }
962
+ }
963
+ catch (e_12_1) { e_12 = { error: e_12_1 }; }
964
+ finally {
965
+ try {
966
+ if (panels_1_1 && !panels_1_1.done && (_a = panels_1.return)) _a.call(panels_1);
967
+ }
968
+ finally { if (e_12) throw e_12.error; }
969
+ }
970
+ var activePanel = this.activePanel;
971
+ this.doRemoveGroup(group, options);
972
+ if (this.activePanel !== activePanel) {
973
+ this._onDidActivePanelChange.fire(this.activePanel);
974
+ }
975
+ };
976
+ DockviewComponent.prototype.doRemoveGroup = function (group, options) {
977
+ var floatingGroup = this.floatingGroups.find(function (_) { return _.group === group; });
978
+ if (floatingGroup) {
979
+ if (!(options === null || options === void 0 ? void 0 : options.skipDispose)) {
980
+ floatingGroup.group.dispose();
981
+ this._groups.delete(group.id);
982
+ this._onDidRemoveGroup.fire(group);
983
+ }
984
+ floatingGroup.dispose();
985
+ if (!(options === null || options === void 0 ? void 0 : options.skipActive) && this._activeGroup === group) {
986
+ var groups = Array.from(this._groups.values());
987
+ this.doSetGroupActive(groups.length > 0 ? groups[0].value : undefined);
988
+ }
989
+ return floatingGroup.group;
990
+ }
991
+ return _super.prototype.doRemoveGroup.call(this, group, options);
992
+ };
993
+ DockviewComponent.prototype.moveGroupOrPanel = function (destinationGroup, sourceGroupId, sourceItemId, destinationTarget, destinationIndex) {
994
+ var _a, _b, _c;
995
+ var sourceGroup = sourceGroupId
996
+ ? (_a = this._groups.get(sourceGroupId)) === null || _a === void 0 ? void 0 : _a.value
997
+ : undefined;
998
+ if (sourceItemId === undefined) {
999
+ if (sourceGroup) {
1000
+ this.moveGroup(sourceGroup, destinationGroup, destinationTarget);
1001
+ }
1002
+ return;
1003
+ }
1004
+ if (!destinationTarget || destinationTarget === 'center') {
1005
+ var groupItem = (_b = sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(sourceItemId)) !== null && _b !== void 0 ? _b : this.panels.find(function (panel) { return panel.id === sourceItemId; });
1006
+ if (!groupItem) {
1007
+ throw new Error("No panel with id ".concat(sourceItemId));
1008
+ }
1009
+ if ((sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.size) === 0) {
1010
+ this.doRemoveGroup(sourceGroup);
1011
+ }
1012
+ destinationGroup.model.openPanel(groupItem, {
1013
+ index: destinationIndex,
1014
+ });
1015
+ }
1016
+ else {
1017
+ var referenceLocation = (0, gridview_1.getGridLocation)(destinationGroup.element);
1018
+ var targetLocation = (0, gridview_1.getRelativeLocation)(this.gridview.orientation, referenceLocation, destinationTarget);
1019
+ if (sourceGroup && sourceGroup.size < 2) {
1020
+ var _d = __read((0, array_1.tail)(targetLocation), 2), targetParentLocation = _d[0], to = _d[1];
1021
+ var isFloating = this.floatingGroups.find(function (x) { return x.group === sourceGroup; });
1022
+ if (!isFloating) {
1023
+ var sourceLocation = (0, gridview_1.getGridLocation)(sourceGroup.element);
1024
+ var _e = __read((0, array_1.tail)(sourceLocation), 2), sourceParentLocation = _e[0], from = _e[1];
1025
+ if ((0, array_1.sequenceEquals)(sourceParentLocation, targetParentLocation)) {
1026
+ // special case when 'swapping' two views within same grid location
1027
+ // if a group has one tab - we are essentially moving the 'group'
1028
+ // which is equivalent to swapping two views in this case
1029
+ this.gridview.moveView(sourceParentLocation, from, to);
1030
+ }
1031
+ }
1032
+ // source group will become empty so delete the group
1033
+ var targetGroup = this.doRemoveGroup(sourceGroup, {
1034
+ skipActive: true,
1035
+ skipDispose: true,
1036
+ });
1037
+ // after deleting the group we need to re-evaulate the ref location
1038
+ var updatedReferenceLocation = (0, gridview_1.getGridLocation)(destinationGroup.element);
1039
+ var location_3 = (0, gridview_1.getRelativeLocation)(this.gridview.orientation, updatedReferenceLocation, destinationTarget);
1040
+ this.doAddGroup(targetGroup, location_3);
1041
+ }
1042
+ else {
1043
+ var groupItem = (_c = sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(sourceItemId)) !== null && _c !== void 0 ? _c : this.panels.find(function (panel) { return panel.id === sourceItemId; });
1044
+ if (!groupItem) {
1045
+ throw new Error("No panel with id ".concat(sourceItemId));
1046
+ }
1047
+ var dropLocation = (0, gridview_1.getRelativeLocation)(this.gridview.orientation, referenceLocation, destinationTarget);
1048
+ var group = this.createGroupAtLocation(dropLocation);
1049
+ group.model.openPanel(groupItem);
1050
+ }
1051
+ }
1052
+ };
1053
+ DockviewComponent.prototype.moveGroup = function (sourceGroup, referenceGroup, target) {
1054
+ var e_13, _a;
1055
+ if (sourceGroup) {
1056
+ if (!target || target === 'center') {
1057
+ var activePanel = sourceGroup.activePanel;
1058
+ var panels = __spreadArray([], __read(sourceGroup.panels), false).map(function (p) {
1059
+ return sourceGroup.model.removePanel(p.id);
1060
+ });
1061
+ if ((sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.size) === 0) {
1062
+ this.doRemoveGroup(sourceGroup);
1063
+ }
1064
+ try {
1065
+ for (var panels_2 = __values(panels), panels_2_1 = panels_2.next(); !panels_2_1.done; panels_2_1 = panels_2.next()) {
1066
+ var panel = panels_2_1.value;
1067
+ referenceGroup.model.openPanel(panel, {
1068
+ skipSetPanelActive: panel !== activePanel,
1069
+ });
1070
+ }
1071
+ }
1072
+ catch (e_13_1) { e_13 = { error: e_13_1 }; }
1073
+ finally {
1074
+ try {
1075
+ if (panels_2_1 && !panels_2_1.done && (_a = panels_2.return)) _a.call(panels_2);
1076
+ }
1077
+ finally { if (e_13) throw e_13.error; }
1078
+ }
1079
+ }
1080
+ else {
1081
+ var floatingGroup = this.floatingGroups.find(function (x) { return x.group === sourceGroup; });
1082
+ if (floatingGroup) {
1083
+ floatingGroup.dispose();
1084
+ }
1085
+ else {
1086
+ this.gridview.removeView((0, gridview_1.getGridLocation)(sourceGroup.element));
1087
+ }
1088
+ var referenceLocation = (0, gridview_1.getGridLocation)(referenceGroup.element);
1089
+ var dropLocation = (0, gridview_1.getRelativeLocation)(this.gridview.orientation, referenceLocation, target);
1090
+ this.gridview.addView(sourceGroup, splitview_1.Sizing.Distribute, dropLocation);
1091
+ }
1092
+ }
1093
+ };
1094
+ DockviewComponent.prototype.doSetGroupAndPanelActive = function (group, skipFocus) {
1095
+ var _a, _b;
1096
+ var activePanel = this.activePanel;
1097
+ _super.prototype.doSetGroupActive.call(this, group, skipFocus);
1098
+ if (((_a = this._activeGroup) === null || _a === void 0 ? void 0 : _a.activePanel) !== activePanel) {
1099
+ this._onDidActivePanelChange.fire((_b = this._activeGroup) === null || _b === void 0 ? void 0 : _b.activePanel);
1100
+ }
1101
+ };
1102
+ DockviewComponent.prototype.createGroup = function (options) {
1103
+ var _this = this;
1104
+ if (!options) {
1105
+ options = {};
1106
+ }
1107
+ var id = options === null || options === void 0 ? void 0 : options.id;
1108
+ if (id && this._groups.has(options.id)) {
1109
+ console.warn("Duplicate group id ".concat(options === null || options === void 0 ? void 0 : options.id, ". reassigning group id to avoid errors"));
1110
+ id = undefined;
1111
+ }
1112
+ if (!id) {
1113
+ id = this.nextGroupId.next();
1114
+ while (this._groups.has(id)) {
1115
+ id = this.nextGroupId.next();
1116
+ }
1117
+ }
1118
+ var view = new dockviewGroupPanel_1.DockviewGroupPanel(this, id, options);
1119
+ view.init({ params: {}, accessor: null }); // required to initialized .part and allow for correct disposal of group
1120
+ if (!this._groups.has(view.id)) {
1121
+ var disposable = new lifecycle_1.CompositeDisposable(view.model.onTabDragStart(function (event) {
1122
+ _this._onWillDragPanel.fire(event);
1123
+ }), view.model.onGroupDragStart(function (event) {
1124
+ _this._onWillDragGroup.fire(event);
1125
+ }), view.model.onMove(function (event) {
1126
+ var groupId = event.groupId, itemId = event.itemId, target = event.target, index = event.index;
1127
+ _this.moveGroupOrPanel(view, groupId, itemId, target, index);
1128
+ }), view.model.onDidDrop(function (event) {
1129
+ _this._onDidDrop.fire(__assign(__assign({}, event), { api: _this._api, group: view }));
1130
+ }), view.model.onDidAddPanel(function (event) {
1131
+ _this._onDidAddPanel.fire(event.panel);
1132
+ }), view.model.onDidRemovePanel(function (event) {
1133
+ _this._onDidRemovePanel.fire(event.panel);
1134
+ }), view.model.onDidActivePanelChange(function (event) {
1135
+ _this._onDidActivePanelChange.fire(event.panel);
1136
+ }));
1137
+ this._groups.set(view.id, { value: view, disposable: disposable });
1138
+ }
1139
+ // TODO: must be called after the above listeners have been setup,
1140
+ // not an ideal pattern
1141
+ view.initialize();
1142
+ return view;
1143
+ };
1144
+ DockviewComponent.prototype.createPanel = function (options, group) {
1145
+ var _a, _b, _c;
1146
+ var contentComponent = options.component;
1147
+ var tabComponent = (_a = options.tabComponent) !== null && _a !== void 0 ? _a : this.options.defaultTabComponent;
1148
+ var view = new dockviewPanelModel_1.DockviewPanelModel(this, options.id, contentComponent, tabComponent);
1149
+ var panel = new dockviewPanel_1.DockviewPanel(options.id, this, this._api, group, view);
1150
+ panel.init({
1151
+ title: (_b = options.title) !== null && _b !== void 0 ? _b : options.id,
1152
+ params: (_c = options === null || options === void 0 ? void 0 : options.params) !== null && _c !== void 0 ? _c : {},
1153
+ });
1154
+ return panel;
1155
+ };
1156
+ DockviewComponent.prototype.createGroupAtLocation = function (location) {
1157
+ if (location === void 0) { location = [0]; }
1158
+ var group = this.createGroup();
1159
+ this.doAddGroup(group, location);
1160
+ return group;
1161
+ };
1162
+ DockviewComponent.prototype.findGroup = function (panel) {
1163
+ var _a;
1164
+ return (_a = Array.from(this._groups.values()).find(function (group) {
1165
+ return group.value.model.containsPanel(panel);
1166
+ })) === null || _a === void 0 ? void 0 : _a.value;
1167
+ };
1168
+ return DockviewComponent;
1169
+ }(baseComponentGridview_1.BaseGrid));
1170
+ exports.DockviewComponent = DockviewComponent;
1157
1171
  //# sourceMappingURL=dockviewComponent.js.map