dockview-core 1.8.4 → 1.9.0

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