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