dockview 1.5.0 → 1.5.2

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 (339) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +52 -52
  3. package/dist/cjs/actionbar/actionsContainer.d.ts +7 -7
  4. package/dist/cjs/actionbar/actionsContainer.js +26 -26
  5. package/dist/cjs/api/component.api.d.ts +144 -144
  6. package/dist/cjs/api/component.api.js +571 -571
  7. package/dist/cjs/api/gridviewPanelApi.d.ts +36 -36
  8. package/dist/cjs/api/gridviewPanelApi.js +47 -47
  9. package/dist/cjs/api/groupPanelApi.d.ts +34 -41
  10. package/dist/cjs/api/groupPanelApi.js +85 -96
  11. package/dist/cjs/api/groupPanelApi.js.map +1 -1
  12. package/dist/cjs/api/panelApi.d.ts +81 -81
  13. package/dist/cjs/api/panelApi.js +121 -121
  14. package/dist/cjs/api/paneviewPanelApi.d.ts +26 -26
  15. package/dist/cjs/api/paneviewPanelApi.js +57 -57
  16. package/dist/cjs/api/splitviewPanelApi.d.ts +32 -32
  17. package/dist/cjs/api/splitviewPanelApi.js +47 -47
  18. package/dist/cjs/array.d.ts +13 -13
  19. package/dist/cjs/array.js +77 -77
  20. package/dist/cjs/dnd/abstractDragHandler.d.ts +11 -11
  21. package/dist/cjs/dnd/abstractDragHandler.js +115 -115
  22. package/dist/cjs/dnd/dataTransfer.d.ts +31 -31
  23. package/dist/cjs/dnd/dataTransfer.js +100 -100
  24. package/dist/cjs/dnd/dnd.d.ts +27 -27
  25. package/dist/cjs/dnd/dnd.js +64 -64
  26. package/dist/cjs/dnd/droptarget.d.ts +37 -37
  27. package/dist/cjs/dnd/droptarget.js +201 -201
  28. package/dist/cjs/dockview/components/tab/defaultTab.d.ts +27 -27
  29. package/dist/cjs/dockview/components/tab/defaultTab.js +121 -126
  30. package/dist/cjs/dockview/components/tab/defaultTab.js.map +1 -1
  31. package/dist/cjs/dockview/components/watermark/watermark.d.ts +20 -20
  32. package/dist/cjs/dockview/components/watermark/watermark.js +101 -101
  33. package/dist/cjs/dockview/defaultGroupPanelView.d.ts +29 -29
  34. package/dist/cjs/dockview/defaultGroupPanelView.js +68 -68
  35. package/dist/cjs/dockview/deserializer.d.ts +5 -5
  36. package/dist/cjs/dockview/deserializer.js +2 -2
  37. package/dist/cjs/dockview/dockviewComponent.d.ts +125 -130
  38. package/dist/cjs/dockview/dockviewComponent.js +614 -629
  39. package/dist/cjs/dockview/dockviewComponent.js.map +1 -1
  40. package/dist/cjs/dockview/dockviewGroupPanel.d.ts +31 -33
  41. package/dist/cjs/dockview/dockviewGroupPanel.js +156 -175
  42. package/dist/cjs/dockview/dockviewGroupPanel.js.map +1 -1
  43. package/dist/cjs/dockview/options.d.ts +88 -89
  44. package/dist/cjs/dockview/options.js +2 -2
  45. package/dist/cjs/dom.d.ts +14 -14
  46. package/dist/cjs/dom.js +182 -182
  47. package/dist/cjs/events.d.ts +30 -30
  48. package/dist/cjs/events.js +129 -129
  49. package/dist/cjs/gridview/baseComponentGridview.d.ts +87 -87
  50. package/dist/cjs/gridview/baseComponentGridview.js +279 -279
  51. package/dist/cjs/gridview/basePanelView.d.ts +43 -43
  52. package/dist/cjs/gridview/basePanelView.js +123 -123
  53. package/dist/cjs/gridview/branchNode.d.ts +49 -46
  54. package/dist/cjs/gridview/branchNode.js +342 -342
  55. package/dist/cjs/gridview/branchNode.js.map +1 -1
  56. package/dist/cjs/gridview/gridview.d.ts +126 -123
  57. package/dist/cjs/gridview/gridview.js +479 -479
  58. package/dist/cjs/gridview/gridview.js.map +1 -1
  59. package/dist/cjs/gridview/gridviewComponent.d.ts +85 -85
  60. package/dist/cjs/gridview/gridviewComponent.js +325 -325
  61. package/dist/cjs/gridview/gridviewPanel.d.ts +60 -60
  62. package/dist/cjs/gridview/gridviewPanel.js +202 -202
  63. package/dist/cjs/gridview/leafNode.d.ts +34 -31
  64. package/dist/cjs/gridview/leafNode.js +170 -165
  65. package/dist/cjs/gridview/leafNode.js.map +1 -1
  66. package/dist/cjs/gridview/options.d.ts +18 -18
  67. package/dist/cjs/gridview/options.js +2 -2
  68. package/dist/cjs/gridview/types.d.ts +3 -3
  69. package/dist/cjs/gridview/types.js +2 -2
  70. package/dist/cjs/groupview/dnd.d.ts +5 -5
  71. package/dist/cjs/groupview/dnd.js +9 -9
  72. package/dist/cjs/groupview/groupPanel.d.ts +32 -35
  73. package/dist/cjs/groupview/groupPanel.js +2 -2
  74. package/dist/cjs/groupview/groupview.d.ts +177 -177
  75. package/dist/cjs/groupview/groupview.js +589 -589
  76. package/dist/cjs/groupview/groupviewPanel.d.ts +35 -35
  77. package/dist/cjs/groupview/groupviewPanel.js +128 -128
  78. package/dist/cjs/groupview/panel/content.d.ts +30 -30
  79. package/dist/cjs/groupview/panel/content.js +100 -100
  80. package/dist/cjs/groupview/tab.d.ts +41 -42
  81. package/dist/cjs/groupview/tab.js +120 -126
  82. package/dist/cjs/groupview/tab.js.map +1 -1
  83. package/dist/cjs/groupview/titlebar/tabsContainer.d.ts +68 -68
  84. package/dist/cjs/groupview/titlebar/tabsContainer.js +258 -270
  85. package/dist/cjs/groupview/titlebar/tabsContainer.js.map +1 -1
  86. package/dist/cjs/groupview/types.d.ts +52 -53
  87. package/dist/cjs/groupview/types.js +2 -2
  88. package/dist/cjs/hostedContainer.d.ts +23 -23
  89. package/dist/cjs/hostedContainer.js +73 -73
  90. package/dist/cjs/index.d.ts +30 -30
  91. package/dist/cjs/index.js +46 -46
  92. package/dist/cjs/index.js.map +1 -1
  93. package/dist/cjs/lifecycle.d.ts +22 -22
  94. package/dist/cjs/lifecycle.js +88 -88
  95. package/dist/cjs/math.d.ts +4 -4
  96. package/dist/cjs/math.js +15 -15
  97. package/dist/cjs/panel/componentFactory.d.ts +8 -8
  98. package/dist/cjs/panel/componentFactory.js +30 -30
  99. package/dist/cjs/panel/types.d.ts +33 -33
  100. package/dist/cjs/panel/types.js +2 -2
  101. package/dist/cjs/paneview/defaultPaneviewHeader.d.ts +21 -21
  102. package/dist/cjs/paneview/defaultPaneviewHeader.js +90 -90
  103. package/dist/cjs/paneview/draggablePaneviewPanel.d.ts +19 -19
  104. package/dist/cjs/paneview/draggablePaneviewPanel.js +129 -129
  105. package/dist/cjs/paneview/options.d.ts +27 -27
  106. package/dist/cjs/paneview/options.js +2 -2
  107. package/dist/cjs/paneview/paneview.d.ts +40 -40
  108. package/dist/cjs/paneview/paneview.js +201 -201
  109. package/dist/cjs/paneview/paneviewComponent.d.ts +129 -129
  110. package/dist/cjs/paneview/paneviewComponent.js +394 -394
  111. package/dist/cjs/paneview/paneviewPanel.d.ts +92 -89
  112. package/dist/cjs/paneview/paneviewPanel.js +274 -274
  113. package/dist/cjs/paneview/paneviewPanel.js.map +1 -1
  114. package/dist/cjs/react/deserializer.d.ts +9 -9
  115. package/dist/cjs/react/deserializer.js +43 -45
  116. package/dist/cjs/react/deserializer.js.map +1 -1
  117. package/dist/cjs/react/dockview/defaultTab.d.ts +4 -4
  118. package/dist/cjs/react/dockview/defaultTab.js +72 -72
  119. package/dist/cjs/react/dockview/defaultTab.js.map +1 -1
  120. package/dist/cjs/react/dockview/dockview.d.ts +34 -35
  121. package/dist/cjs/react/dockview/dockview.js +212 -227
  122. package/dist/cjs/react/dockview/dockview.js.map +1 -1
  123. package/dist/cjs/react/dockview/groupControlsRenderer.d.ts +43 -43
  124. package/dist/cjs/react/dockview/groupControlsRenderer.js +86 -86
  125. package/dist/cjs/react/dockview/reactContentPart.d.ts +30 -30
  126. package/dist/cjs/react/dockview/reactContentPart.js +58 -58
  127. package/dist/cjs/react/dockview/reactHeaderPart.d.ts +26 -26
  128. package/dist/cjs/react/dockview/reactHeaderPart.js +55 -55
  129. package/dist/cjs/react/dockview/reactWatermarkPart.d.ts +29 -29
  130. package/dist/cjs/react/dockview/reactWatermarkPart.js +65 -65
  131. package/dist/cjs/react/dockview/v2/reactContentRenderer.d.ts +29 -29
  132. package/dist/cjs/react/dockview/v2/reactContentRenderer.js +87 -87
  133. package/dist/cjs/react/dockview/v2/reactGroupPanelView.d.ts +7 -7
  134. package/dist/cjs/react/dockview/v2/reactGroupPanelView.js +34 -34
  135. package/dist/cjs/react/dockview/v2/webviewContentRenderer.d.ts +18 -18
  136. package/dist/cjs/react/dockview/v2/webviewContentRenderer.js +45 -45
  137. package/dist/cjs/react/gridview/gridview.d.ts +24 -24
  138. package/dist/cjs/react/gridview/gridview.js +112 -112
  139. package/dist/cjs/react/gridview/view.d.ts +11 -11
  140. package/dist/cjs/react/gridview/view.js +40 -40
  141. package/dist/cjs/react/index.d.ts +9 -9
  142. package/dist/cjs/react/index.js +23 -23
  143. package/dist/cjs/react/paneview/paneview.d.ts +30 -30
  144. package/dist/cjs/react/paneview/paneview.js +155 -155
  145. package/dist/cjs/react/paneview/view.d.ts +20 -20
  146. package/dist/cjs/react/paneview/view.js +44 -44
  147. package/dist/cjs/react/react.d.ts +36 -36
  148. package/dist/cjs/react/react.js +194 -194
  149. package/dist/cjs/react/splitview/splitview.d.ts +24 -24
  150. package/dist/cjs/react/splitview/splitview.js +108 -108
  151. package/dist/cjs/react/splitview/view.d.ts +10 -10
  152. package/dist/cjs/react/splitview/view.js +40 -40
  153. package/dist/cjs/react/svg.d.ts +3 -3
  154. package/dist/cjs/react/svg.js +35 -35
  155. package/dist/cjs/react/types.d.ts +7 -7
  156. package/dist/cjs/react/types.js +2 -2
  157. package/dist/cjs/splitview/core/options.d.ts +26 -26
  158. package/dist/cjs/splitview/core/options.js +2 -2
  159. package/dist/cjs/splitview/core/splitview.d.ts +127 -124
  160. package/dist/cjs/splitview/core/splitview.js +908 -908
  161. package/dist/cjs/splitview/core/splitview.js.map +1 -1
  162. package/dist/cjs/splitview/core/viewItem.d.ts +25 -25
  163. package/dist/cjs/splitview/core/viewItem.js +124 -124
  164. package/dist/cjs/splitview/splitviewComponent.d.ts +101 -101
  165. package/dist/cjs/splitview/splitviewComponent.js +373 -373
  166. package/dist/cjs/splitview/splitviewPanel.d.ts +45 -42
  167. package/dist/cjs/splitview/splitviewPanel.js +178 -178
  168. package/dist/cjs/splitview/splitviewPanel.js.map +1 -1
  169. package/dist/cjs/svg.d.ts +3 -3
  170. package/dist/cjs/svg.js +43 -43
  171. package/dist/cjs/types.d.ts +7 -7
  172. package/dist/cjs/types.js +2 -2
  173. package/dist/dockview.amd.js +6737 -6797
  174. package/dist/dockview.amd.min.js +2 -2
  175. package/dist/dockview.amd.min.noStyle.js +2 -2
  176. package/dist/dockview.amd.noStyle.js +6743 -6803
  177. package/dist/dockview.cjs.js +6737 -6797
  178. package/dist/dockview.esm.js +6731 -6791
  179. package/dist/dockview.esm.min.js +2 -2
  180. package/dist/dockview.js +6737 -6797
  181. package/dist/dockview.min.js +2 -2
  182. package/dist/dockview.min.noStyle.js +2 -2
  183. package/dist/dockview.noStyle.js +6743 -6803
  184. package/dist/esm/actionbar/actionsContainer.d.ts +7 -7
  185. package/dist/esm/actionbar/actionsContainer.js +17 -17
  186. package/dist/esm/api/component.api.d.ts +144 -144
  187. package/dist/esm/api/component.api.js +326 -326
  188. package/dist/esm/api/gridviewPanelApi.d.ts +36 -36
  189. package/dist/esm/api/gridviewPanelApi.js +25 -25
  190. package/dist/esm/api/groupPanelApi.d.ts +34 -41
  191. package/dist/esm/api/groupPanelApi.js +50 -57
  192. package/dist/esm/api/panelApi.d.ts +81 -81
  193. package/dist/esm/api/panelApi.js +79 -79
  194. package/dist/esm/api/paneviewPanelApi.d.ts +26 -26
  195. package/dist/esm/api/paneviewPanelApi.js +27 -27
  196. package/dist/esm/api/splitviewPanelApi.d.ts +32 -32
  197. package/dist/esm/api/splitviewPanelApi.js +25 -25
  198. package/dist/esm/array.d.ts +13 -13
  199. package/dist/esm/array.js +67 -67
  200. package/dist/esm/dnd/abstractDragHandler.d.ts +11 -11
  201. package/dist/esm/dnd/abstractDragHandler.js +37 -37
  202. package/dist/esm/dnd/dataTransfer.d.ts +31 -31
  203. package/dist/esm/dnd/dataTransfer.js +69 -69
  204. package/dist/esm/dnd/dnd.d.ts +27 -27
  205. package/dist/esm/dnd/dnd.js +41 -41
  206. package/dist/esm/dnd/droptarget.d.ts +37 -37
  207. package/dist/esm/dnd/droptarget.js +167 -167
  208. package/dist/esm/dockview/components/tab/defaultTab.d.ts +27 -27
  209. package/dist/esm/dockview/components/tab/defaultTab.js +79 -84
  210. package/dist/esm/dockview/components/watermark/watermark.d.ts +20 -20
  211. package/dist/esm/dockview/components/watermark/watermark.js +70 -70
  212. package/dist/esm/dockview/defaultGroupPanelView.d.ts +29 -29
  213. package/dist/esm/dockview/defaultGroupPanelView.js +44 -44
  214. package/dist/esm/dockview/deserializer.d.ts +5 -5
  215. package/dist/esm/dockview/deserializer.js +1 -1
  216. package/dist/esm/dockview/dockviewComponent.d.ts +125 -130
  217. package/dist/esm/dockview/dockviewComponent.js +468 -483
  218. package/dist/esm/dockview/dockviewGroupPanel.d.ts +31 -33
  219. package/dist/esm/dockview/dockviewGroupPanel.js +107 -122
  220. package/dist/esm/dockview/options.d.ts +88 -89
  221. package/dist/esm/dockview/options.js +1 -1
  222. package/dist/esm/dom.d.ts +14 -14
  223. package/dist/esm/dom.js +113 -113
  224. package/dist/esm/events.d.ts +30 -30
  225. package/dist/esm/events.js +88 -88
  226. package/dist/esm/gridview/baseComponentGridview.d.ts +87 -87
  227. package/dist/esm/gridview/baseComponentGridview.js +189 -189
  228. package/dist/esm/gridview/basePanelView.d.ts +43 -43
  229. package/dist/esm/gridview/basePanelView.js +74 -74
  230. package/dist/esm/gridview/branchNode.d.ts +49 -46
  231. package/dist/esm/gridview/branchNode.js +218 -218
  232. package/dist/esm/gridview/gridview.d.ts +126 -123
  233. package/dist/esm/gridview/gridview.js +397 -397
  234. package/dist/esm/gridview/gridviewComponent.d.ts +85 -85
  235. package/dist/esm/gridview/gridviewComponent.js +238 -238
  236. package/dist/esm/gridview/gridviewPanel.d.ts +60 -60
  237. package/dist/esm/gridview/gridviewPanel.js +138 -138
  238. package/dist/esm/gridview/leafNode.d.ts +34 -31
  239. package/dist/esm/gridview/leafNode.js +103 -98
  240. package/dist/esm/gridview/options.d.ts +18 -18
  241. package/dist/esm/gridview/options.js +1 -1
  242. package/dist/esm/gridview/types.d.ts +3 -3
  243. package/dist/esm/gridview/types.js +1 -1
  244. package/dist/esm/groupview/dnd.d.ts +5 -5
  245. package/dist/esm/groupview/dnd.js +6 -6
  246. package/dist/esm/groupview/groupPanel.d.ts +32 -35
  247. package/dist/esm/groupview/groupPanel.js +1 -1
  248. package/dist/esm/groupview/groupview.d.ts +177 -177
  249. package/dist/esm/groupview/groupview.js +444 -444
  250. package/dist/esm/groupview/groupviewPanel.d.ts +35 -35
  251. package/dist/esm/groupview/groupviewPanel.js +61 -61
  252. package/dist/esm/groupview/panel/content.d.ts +30 -30
  253. package/dist/esm/groupview/panel/content.js +73 -73
  254. package/dist/esm/groupview/tab.d.ts +41 -42
  255. package/dist/esm/groupview/tab.js +90 -96
  256. package/dist/esm/groupview/titlebar/tabsContainer.d.ts +68 -68
  257. package/dist/esm/groupview/titlebar/tabsContainer.js +190 -191
  258. package/dist/esm/groupview/types.d.ts +52 -53
  259. package/dist/esm/groupview/types.js +1 -1
  260. package/dist/esm/hostedContainer.d.ts +23 -23
  261. package/dist/esm/hostedContainer.js +63 -63
  262. package/dist/esm/index.d.ts +30 -30
  263. package/dist/esm/index.js +23 -23
  264. package/dist/esm/lifecycle.d.ts +22 -22
  265. package/dist/esm/lifecycle.js +39 -39
  266. package/dist/esm/math.d.ts +4 -4
  267. package/dist/esm/math.js +10 -10
  268. package/dist/esm/panel/componentFactory.d.ts +8 -8
  269. package/dist/esm/panel/componentFactory.js +24 -24
  270. package/dist/esm/panel/types.d.ts +33 -33
  271. package/dist/esm/panel/types.js +1 -1
  272. package/dist/esm/paneview/defaultPaneviewHeader.d.ts +21 -21
  273. package/dist/esm/paneview/defaultPaneviewHeader.js +63 -63
  274. package/dist/esm/paneview/draggablePaneviewPanel.d.ts +19 -19
  275. package/dist/esm/paneview/draggablePaneviewPanel.js +90 -90
  276. package/dist/esm/paneview/options.d.ts +27 -27
  277. package/dist/esm/paneview/options.js +1 -1
  278. package/dist/esm/paneview/paneview.d.ts +40 -40
  279. package/dist/esm/paneview/paneview.js +145 -145
  280. package/dist/esm/paneview/paneviewComponent.d.ts +129 -129
  281. package/dist/esm/paneview/paneviewComponent.js +270 -270
  282. package/dist/esm/paneview/paneviewPanel.d.ts +92 -89
  283. package/dist/esm/paneview/paneviewPanel.js +191 -191
  284. package/dist/esm/react/deserializer.d.ts +9 -9
  285. package/dist/esm/react/deserializer.js +38 -40
  286. package/dist/esm/react/dockview/defaultTab.d.ts +4 -4
  287. package/dist/esm/react/dockview/defaultTab.js +34 -34
  288. package/dist/esm/react/dockview/dockview.d.ts +34 -35
  289. package/dist/esm/react/dockview/dockview.js +157 -172
  290. package/dist/esm/react/dockview/groupControlsRenderer.d.ts +43 -43
  291. package/dist/esm/react/dockview/groupControlsRenderer.js +68 -68
  292. package/dist/esm/react/dockview/reactContentPart.d.ts +30 -30
  293. package/dist/esm/react/dockview/reactContentPart.js +49 -49
  294. package/dist/esm/react/dockview/reactHeaderPart.d.ts +26 -26
  295. package/dist/esm/react/dockview/reactHeaderPart.js +46 -46
  296. package/dist/esm/react/dockview/reactWatermarkPart.d.ts +29 -29
  297. package/dist/esm/react/dockview/reactWatermarkPart.js +55 -55
  298. package/dist/esm/react/dockview/v2/reactContentRenderer.d.ts +29 -29
  299. package/dist/esm/react/dockview/v2/reactContentRenderer.js +69 -69
  300. package/dist/esm/react/dockview/v2/reactGroupPanelView.d.ts +7 -7
  301. package/dist/esm/react/dockview/v2/reactGroupPanelView.js +12 -12
  302. package/dist/esm/react/dockview/v2/webviewContentRenderer.d.ts +18 -18
  303. package/dist/esm/react/dockview/v2/webviewContentRenderer.js +36 -36
  304. package/dist/esm/react/gridview/gridview.d.ts +24 -24
  305. package/dist/esm/react/gridview/gridview.js +70 -70
  306. package/dist/esm/react/gridview/view.d.ts +11 -11
  307. package/dist/esm/react/gridview/view.js +18 -18
  308. package/dist/esm/react/index.d.ts +9 -9
  309. package/dist/esm/react/index.js +7 -7
  310. package/dist/esm/react/paneview/paneview.d.ts +30 -30
  311. package/dist/esm/react/paneview/paneview.js +100 -100
  312. package/dist/esm/react/paneview/view.d.ts +20 -20
  313. package/dist/esm/react/paneview/view.js +35 -35
  314. package/dist/esm/react/react.d.ts +36 -36
  315. package/dist/esm/react/react.js +125 -125
  316. package/dist/esm/react/splitview/splitview.d.ts +24 -24
  317. package/dist/esm/react/splitview/splitview.js +66 -66
  318. package/dist/esm/react/splitview/view.d.ts +10 -10
  319. package/dist/esm/react/splitview/view.js +18 -18
  320. package/dist/esm/react/svg.d.ts +3 -3
  321. package/dist/esm/react/svg.js +7 -7
  322. package/dist/esm/react/types.d.ts +7 -7
  323. package/dist/esm/react/types.js +1 -1
  324. package/dist/esm/splitview/core/options.d.ts +26 -26
  325. package/dist/esm/splitview/core/options.js +1 -1
  326. package/dist/esm/splitview/core/splitview.d.ts +127 -124
  327. package/dist/esm/splitview/core/splitview.js +689 -689
  328. package/dist/esm/splitview/core/viewItem.d.ts +25 -25
  329. package/dist/esm/splitview/core/viewItem.js +79 -79
  330. package/dist/esm/splitview/splitviewComponent.d.ts +101 -101
  331. package/dist/esm/splitview/splitviewComponent.js +249 -249
  332. package/dist/esm/splitview/splitviewPanel.d.ts +45 -42
  333. package/dist/esm/splitview/splitviewPanel.js +107 -107
  334. package/dist/esm/svg.d.ts +3 -3
  335. package/dist/esm/svg.js +31 -31
  336. package/dist/esm/types.d.ts +7 -7
  337. package/dist/esm/types.js +1 -1
  338. package/dist/styles/dockview.css +0 -3
  339. package/package.json +2 -2
@@ -1,630 +1,615 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- var __assign = (this && this.__assign) || function () {
18
- __assign = Object.assign || function(t) {
19
- for (var s, i = 1, n = arguments.length; i < n; i++) {
20
- s = arguments[i];
21
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
22
- t[p] = s[p];
23
- }
24
- return t;
25
- };
26
- return __assign.apply(this, arguments);
27
- };
28
- var __values = (this && this.__values) || function(o) {
29
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
30
- if (m) return m.call(o);
31
- if (o && typeof o.length === "number") return {
32
- next: function () {
33
- if (o && i >= o.length) o = void 0;
34
- return { value: o && o[i++], done: !o };
35
- }
36
- };
37
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
38
- };
39
- var __read = (this && this.__read) || function (o, n) {
40
- var m = typeof Symbol === "function" && o[Symbol.iterator];
41
- if (!m) return o;
42
- var i = m.call(o), r, ar = [], e;
43
- try {
44
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
45
- }
46
- catch (error) { e = { error: error }; }
47
- finally {
48
- try {
49
- if (r && !r.done && (m = i["return"])) m.call(i);
50
- }
51
- finally { if (e) throw e.error; }
52
- }
53
- return ar;
54
- };
55
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
56
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
57
- if (ar || !(i in from)) {
58
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
59
- ar[i] = from[i];
60
- }
61
- }
62
- return to.concat(ar || Array.prototype.slice.call(from));
63
- };
64
- Object.defineProperty(exports, "__esModule", { value: true });
65
- exports.DockviewComponent = void 0;
66
- var gridview_1 = require("../gridview/gridview");
67
- var droptarget_1 = require("../dnd/droptarget");
68
- var array_1 = require("../array");
69
- var dockviewGroupPanel_1 = require("./dockviewGroupPanel");
70
- var lifecycle_1 = require("../lifecycle");
71
- var events_1 = require("../events");
72
- var watermark_1 = require("./components/watermark/watermark");
73
- var math_1 = require("../math");
74
- var componentFactory_1 = require("../panel/componentFactory");
75
- var baseComponentGridview_1 = require("../gridview/baseComponentGridview");
76
- var component_api_1 = require("../api/component.api");
77
- var tab_1 = require("../groupview/tab");
78
- var splitview_1 = require("../splitview/core/splitview");
79
- var defaultTab_1 = require("./components/tab/defaultTab");
80
- var groupviewPanel_1 = require("../groupview/groupviewPanel");
81
- var defaultGroupPanelView_1 = require("./defaultGroupPanelView");
82
- var nextGroupId = (0, math_1.sequentialNumberGenerator)();
83
- var DockviewComponent = /** @class */ (function (_super) {
84
- __extends(DockviewComponent, _super);
85
- function DockviewComponent(element, options) {
86
- var _this = _super.call(this, element, {
87
- proportionalLayout: true,
88
- orientation: options.orientation || splitview_1.Orientation.HORIZONTAL,
89
- styles: options.styles,
90
- }) || this;
91
- _this._onTabContextMenu = new events_1.Emitter();
92
- _this.onTabContextMenu = _this._onTabContextMenu.event;
93
- _this._onDidDrop = new events_1.Emitter();
94
- _this.onDidDrop = _this._onDidDrop.event;
95
- _this._onDidRemovePanel = new events_1.Emitter();
96
- _this.onDidRemovePanel = _this._onDidRemovePanel.event;
97
- _this._onDidAddPanel = new events_1.Emitter();
98
- _this.onDidAddPanel = _this._onDidAddPanel.event;
99
- _this._onDidLayoutFromJSON = new events_1.Emitter();
100
- _this.onDidLayoutFromJSON = _this._onDidLayoutFromJSON.event;
101
- _this._onDidActivePanelChange = new events_1.Emitter();
102
- _this.onDidActivePanelChange = _this._onDidActivePanelChange.event;
103
- _this.addDisposables(_this._onTabContextMenu, _this._onDidDrop, events_1.Event.any(_this.onDidAddPanel, _this.onDidRemovePanel, _this.onDidActivePanelChange)(function () {
104
- _this._bufferOnDidLayoutChange.fire();
105
- }));
106
- _this._options = options;
107
- if (!_this.options.components) {
108
- _this.options.components = {};
109
- }
110
- if (!_this.options.frameworkComponents) {
111
- _this.options.frameworkComponents = {};
112
- }
113
- if (!_this.options.frameworkTabComponents) {
114
- _this.options.frameworkTabComponents = {};
115
- }
116
- if (!_this.options.tabComponents) {
117
- _this.options.tabComponents = {};
118
- }
119
- if (!_this.options.watermarkComponent &&
120
- !_this.options.watermarkFrameworkComponent) {
121
- _this.options.watermarkComponent = watermark_1.Watermark;
122
- }
123
- _this._api = new component_api_1.DockviewApi(_this);
124
- return _this;
125
- }
126
- Object.defineProperty(DockviewComponent.prototype, "totalPanels", {
127
- get: function () {
128
- return this.panels.length;
129
- },
130
- enumerable: false,
131
- configurable: true
132
- });
133
- Object.defineProperty(DockviewComponent.prototype, "panels", {
134
- get: function () {
135
- return this.groups.flatMap(function (group) { return group.panels; });
136
- },
137
- enumerable: false,
138
- configurable: true
139
- });
140
- Object.defineProperty(DockviewComponent.prototype, "deserializer", {
141
- get: function () {
142
- return this._deserializer;
143
- },
144
- set: function (value) {
145
- this._deserializer = value;
146
- },
147
- enumerable: false,
148
- configurable: true
149
- });
150
- Object.defineProperty(DockviewComponent.prototype, "options", {
151
- get: function () {
152
- return this._options;
153
- },
154
- enumerable: false,
155
- configurable: true
156
- });
157
- Object.defineProperty(DockviewComponent.prototype, "activePanel", {
158
- get: function () {
159
- var activeGroup = this.activeGroup;
160
- if (!activeGroup) {
161
- return undefined;
162
- }
163
- return activeGroup.activePanel;
164
- },
165
- enumerable: false,
166
- configurable: true
167
- });
168
- Object.defineProperty(DockviewComponent.prototype, "tabHeight", {
169
- get: function () {
170
- return this.options.tabHeight;
171
- },
172
- set: function (height) {
173
- this.options.tabHeight = height;
174
- this._groups.forEach(function (value) {
175
- value.value.model.header.height = height;
176
- });
177
- },
178
- enumerable: false,
179
- configurable: true
180
- });
181
- DockviewComponent.prototype.updateOptions = function (options) {
182
- var hasOrientationChanged = typeof options.orientation === 'string' &&
183
- this.gridview.orientation !== options.orientation;
184
- this._options = __assign(__assign({}, this.options), options);
185
- if (hasOrientationChanged) {
186
- this.gridview.orientation = options.orientation;
187
- }
188
- this.layout(this.gridview.width, this.gridview.height, true);
189
- };
190
- DockviewComponent.prototype.focus = function () {
191
- var _a;
192
- (_a = this.activeGroup) === null || _a === void 0 ? void 0 : _a.focus();
193
- };
194
- DockviewComponent.prototype.getGroupPanel = function (id) {
195
- return this.panels.find(function (panel) { return panel.id === id; });
196
- };
197
- DockviewComponent.prototype.setActivePanel = function (panel) {
198
- this.doSetGroupActive(panel.group);
199
- panel.group.model.openPanel(panel);
200
- };
201
- DockviewComponent.prototype.moveToNext = function (options) {
202
- var _a;
203
- if (options === void 0) { options = {}; }
204
- if (!options.group) {
205
- if (!this.activeGroup) {
206
- return;
207
- }
208
- options.group = this.activeGroup;
209
- }
210
- if (options.includePanel && options.group) {
211
- if (options.group.activePanel !==
212
- options.group.panels[options.group.panels.length - 1]) {
213
- options.group.model.moveToNext({ suppressRoll: true });
214
- return;
215
- }
216
- }
217
- var location = (0, gridview_1.getGridLocation)(options.group.element);
218
- var next = (_a = this.gridview.next(location)) === null || _a === void 0 ? void 0 : _a.view;
219
- this.doSetGroupActive(next);
220
- };
221
- DockviewComponent.prototype.moveToPrevious = function (options) {
222
- var _a;
223
- if (options === void 0) { options = {}; }
224
- if (!options.group) {
225
- if (!this.activeGroup) {
226
- return;
227
- }
228
- options.group = this.activeGroup;
229
- }
230
- if (options.includePanel && options.group) {
231
- if (options.group.activePanel !==
232
- options.group.panels[0]) {
233
- options.group.model.moveToPrevious({ suppressRoll: true });
234
- return;
235
- }
236
- }
237
- var location = (0, gridview_1.getGridLocation)(options.group.element);
238
- var next = (_a = this.gridview.previous(location)) === null || _a === void 0 ? void 0 : _a.view;
239
- if (next) {
240
- this.doSetGroupActive(next);
241
- }
242
- };
243
- /**
244
- * Serialize the current state of the layout
245
- *
246
- * @returns A JSON respresentation of the layout
247
- */
248
- DockviewComponent.prototype.toJSON = function () {
249
- var _a;
250
- var data = this.gridview.serialize();
251
- var panels = this.panels.reduce(function (collection, panel) {
252
- collection[panel.id] = panel.toJSON();
253
- return collection;
254
- }, {});
255
- return {
256
- grid: data,
257
- panels: panels,
258
- activeGroup: (_a = this.activeGroup) === null || _a === void 0 ? void 0 : _a.id,
259
- options: { tabHeight: this.tabHeight },
260
- };
261
- };
262
- DockviewComponent.prototype.fromJSON = function (data) {
263
- var _this = this;
264
- this.clear();
265
- if (!this.deserializer) {
266
- throw new Error('invalid deserializer');
267
- }
268
- var grid = data.grid, panels = data.panels, options = data.options, activeGroup = data.activeGroup;
269
- if (typeof (options === null || options === void 0 ? void 0 : options.tabHeight) === 'number') {
270
- this.tabHeight = options.tabHeight;
271
- }
272
- if (!this.deserializer) {
273
- throw new Error('no deserializer provided');
274
- }
275
- this.gridview.deserialize(grid, {
276
- fromJSON: function (node) {
277
- var e_1, _a;
278
- var _b = node.data, id = _b.id, locked = _b.locked, hideHeader = _b.hideHeader, views = _b.views, activeView = _b.activeView;
279
- var group = _this.createGroup({
280
- id: id,
281
- locked: !!locked,
282
- hideHeader: !!hideHeader,
283
- });
284
- _this._onDidAddGroup.fire(group);
285
- try {
286
- for (var views_1 = __values(views), views_1_1 = views_1.next(); !views_1_1.done; views_1_1 = views_1.next()) {
287
- var child = views_1_1.value;
288
- var panel = _this.deserializer.fromJSON(panels[child], group);
289
- var isActive = typeof activeView === 'string' && activeView === panel.id;
290
- group.model.openPanel(panel, {
291
- skipSetPanelActive: !isActive,
292
- skipSetGroupActive: true
293
- });
294
- }
295
- }
296
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
297
- finally {
298
- try {
299
- if (views_1_1 && !views_1_1.done && (_a = views_1.return)) _a.call(views_1);
300
- }
301
- finally { if (e_1) throw e_1.error; }
302
- }
303
- if (!group.activePanel && group.panels.length > 0) {
304
- group.model.openPanel(group.panels[group.panels.length - 1], {
305
- skipSetGroupActive: true
306
- });
307
- }
308
- return group;
309
- }
310
- });
311
- if (typeof activeGroup === 'string') {
312
- var panel = this.getPanel(activeGroup);
313
- if (panel) {
314
- this.doSetGroupActive(panel);
315
- }
316
- }
317
- this.gridview.layout(this.width, this.height);
318
- this._onDidLayoutFromJSON.fire();
319
- };
320
- DockviewComponent.prototype.clear = function () {
321
- var e_2, _a;
322
- var groups = Array.from(this._groups.values()).map(function (_) { return _.value; });
323
- var hasActiveGroup = !!this.activeGroup;
324
- var hasActivePanel = !!this.activePanel;
325
- try {
326
- for (var groups_1 = __values(groups), groups_1_1 = groups_1.next(); !groups_1_1.done; groups_1_1 = groups_1.next()) {
327
- var group = groups_1_1.value;
328
- // remove the group will automatically remove the panels
329
- this.removeGroup(group, true);
330
- }
331
- }
332
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
333
- finally {
334
- try {
335
- if (groups_1_1 && !groups_1_1.done && (_a = groups_1.return)) _a.call(groups_1);
336
- }
337
- finally { if (e_2) throw e_2.error; }
338
- }
339
- if (hasActiveGroup) {
340
- this.doSetGroupActive(undefined);
341
- }
342
- if (hasActivePanel) {
343
- this._onDidActivePanelChange.fire(undefined);
344
- }
345
- this.gridview.clear();
346
- };
347
- DockviewComponent.prototype.closeAllGroups = function () {
348
- var e_3, _a;
349
- try {
350
- for (var _b = __values(this._groups.entries()), _c = _b.next(); !_c.done; _c = _b.next()) {
351
- var entry = _c.value;
352
- var _d = __read(entry, 2), _1 = _d[0], group = _d[1];
353
- group.value.model.closeAllPanels();
354
- }
355
- }
356
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
357
- finally {
358
- try {
359
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
360
- }
361
- finally { if (e_3) throw e_3.error; }
362
- }
363
- };
364
- DockviewComponent.prototype.fireMouseEvent = function (event) {
365
- if (event.kind === tab_1.MouseEventKind.CONTEXT_MENU) {
366
- if (event.tab && event.panel) {
367
- this._onTabContextMenu.fire({
368
- event: event.event,
369
- api: this._api,
370
- panel: event.panel,
371
- });
372
- }
373
- }
374
- };
375
- DockviewComponent.prototype.addPanel = function (options) {
376
- var _a, _b;
377
- if (this.panels.find(function (_) { return _.id === options.id; })) {
378
- throw new Error("panel with id ".concat(options.id, " already exists"));
379
- }
380
- var referenceGroup;
381
- if ((_a = options.position) === null || _a === void 0 ? void 0 : _a.referencePanel) {
382
- var referencePanel = this.getGroupPanel(options.position.referencePanel);
383
- if (!referencePanel) {
384
- throw new Error("referencePanel ".concat(options.position.referencePanel, " does not exist"));
385
- }
386
- referenceGroup = this.findGroup(referencePanel);
387
- }
388
- else {
389
- referenceGroup = this.activeGroup;
390
- }
391
- var panel;
392
- if (referenceGroup) {
393
- var target = (0, baseComponentGridview_1.toTarget)(((_b = options.position) === null || _b === void 0 ? void 0 : _b.direction) || 'within');
394
- if (target === droptarget_1.Position.Center) {
395
- panel = this.createPanel(options, referenceGroup);
396
- referenceGroup.model.openPanel(panel);
397
- }
398
- else {
399
- var location_1 = (0, gridview_1.getGridLocation)(referenceGroup.element);
400
- var relativeLocation = (0, gridview_1.getRelativeLocation)(this.gridview.orientation, location_1, target);
401
- var group = this.createGroupAtLocation(relativeLocation);
402
- panel = this.createPanel(options, group);
403
- group.model.openPanel(panel);
404
- }
405
- }
406
- else {
407
- var group = this.createGroupAtLocation();
408
- panel = this.createPanel(options, group);
409
- group.model.openPanel(panel);
410
- }
411
- return panel;
412
- };
413
- DockviewComponent.prototype.removePanel = function (panel, options) {
414
- if (options === void 0) { options = {
415
- removeEmptyGroup: true,
416
- skipDispose: false,
417
- }; }
418
- var group = panel.group;
419
- if (!group) {
420
- throw new Error("cannot remove panel ".concat(panel.id, ". it's missing a group."));
421
- }
422
- group.model.removePanel(panel);
423
- panel.dispose();
424
- var retainGroupForWatermark = this.size === 1;
425
- if (!retainGroupForWatermark &&
426
- group.size === 0 &&
427
- options.removeEmptyGroup) {
428
- this.removeGroup(group);
429
- }
430
- };
431
- DockviewComponent.prototype.createWatermarkComponent = function () {
432
- var _a;
433
- return (0, componentFactory_1.createComponent)('watermark-id', 'watermark-name', this.options.watermarkComponent
434
- ? { 'watermark-name': this.options.watermarkComponent }
435
- : {}, this.options.watermarkFrameworkComponent
436
- ? { 'watermark-name': this.options.watermarkFrameworkComponent }
437
- : {}, (_a = this.options.frameworkComponentFactory) === null || _a === void 0 ? void 0 : _a.watermark);
438
- };
439
- DockviewComponent.prototype.addEmptyGroup = function (options) {
440
- var group = this.createGroup();
441
- if (options) {
442
- var referencePanel = this.panels.find(function (panel) { return panel.id === options.referencePanel; });
443
- if (!referencePanel) {
444
- throw new Error("reference panel ".concat(options.referencePanel, " does not exist"));
445
- }
446
- var referenceGroup = this.findGroup(referencePanel);
447
- if (!referenceGroup) {
448
- throw new Error("reference group for reference panel ".concat(options.referencePanel, " does not exist"));
449
- }
450
- var target = (0, baseComponentGridview_1.toTarget)(options.direction || 'within');
451
- var location_2 = (0, gridview_1.getGridLocation)(referenceGroup.element);
452
- var relativeLocation = (0, gridview_1.getRelativeLocation)(this.gridview.orientation, location_2, target);
453
- this.doAddGroup(group, relativeLocation);
454
- }
455
- else {
456
- this.doAddGroup(group);
457
- }
458
- };
459
- DockviewComponent.prototype.removeGroup = function (group, skipActive) {
460
- var e_4, _a;
461
- if (skipActive === void 0) { skipActive = false; }
462
- var panels = __spreadArray([], __read(group.panels), false); // reassign since group panels will mutate
463
- try {
464
- for (var panels_1 = __values(panels), panels_1_1 = panels_1.next(); !panels_1_1.done; panels_1_1 = panels_1.next()) {
465
- var panel = panels_1_1.value;
466
- this.removePanel(panel, {
467
- removeEmptyGroup: false,
468
- skipDispose: false,
469
- });
470
- }
471
- }
472
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
473
- finally {
474
- try {
475
- if (panels_1_1 && !panels_1_1.done && (_a = panels_1.return)) _a.call(panels_1);
476
- }
477
- finally { if (e_4) throw e_4.error; }
478
- }
479
- _super.prototype.doRemoveGroup.call(this, group, { skipActive: skipActive });
480
- };
481
- DockviewComponent.prototype.moveGroupOrPanel = function (referenceGroup, groupId, itemId, target, index) {
482
- var _a;
483
- var sourceGroup = groupId
484
- ? (_a = this._groups.get(groupId)) === null || _a === void 0 ? void 0 : _a.value
485
- : undefined;
486
- if (!target || target === droptarget_1.Position.Center) {
487
- var groupItem = (sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(itemId)) ||
488
- this.panels.find(function (panel) { return panel.id === itemId; });
489
- if (!groupItem) {
490
- throw new Error("No panel with id ".concat(itemId));
491
- }
492
- if ((sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.size) === 0) {
493
- this.doRemoveGroup(sourceGroup);
494
- }
495
- referenceGroup.model.openPanel(groupItem, { index: index });
496
- }
497
- else {
498
- var referenceLocation = (0, gridview_1.getGridLocation)(referenceGroup.element);
499
- var targetLocation = (0, gridview_1.getRelativeLocation)(this.gridview.orientation, referenceLocation, target);
500
- if (sourceGroup && sourceGroup.size < 2) {
501
- var _b = __read((0, array_1.tail)(targetLocation), 2), targetParentLocation = _b[0], to = _b[1];
502
- var sourceLocation = (0, gridview_1.getGridLocation)(sourceGroup.element);
503
- var _c = __read((0, array_1.tail)(sourceLocation), 2), sourceParentLocation = _c[0], from = _c[1];
504
- if ((0, array_1.sequenceEquals)(sourceParentLocation, targetParentLocation)) {
505
- // special case when 'swapping' two views within same grid location
506
- // if a group has one tab - we are essentially moving the 'group'
507
- // which is equivalent to swapping two views in this case
508
- this.gridview.moveView(sourceParentLocation, from, to);
509
- }
510
- else {
511
- // source group will become empty so delete the group
512
- var targetGroup = this.doRemoveGroup(sourceGroup, {
513
- skipActive: true,
514
- skipDispose: true,
515
- });
516
- // after deleting the group we need to re-evaulate the ref location
517
- var updatedReferenceLocation = (0, gridview_1.getGridLocation)(referenceGroup.element);
518
- var location_3 = (0, gridview_1.getRelativeLocation)(this.gridview.orientation, updatedReferenceLocation, target);
519
- this.doAddGroup(targetGroup, location_3);
520
- }
521
- }
522
- else {
523
- var groupItem = (sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(itemId)) ||
524
- this.panels.find(function (panel) { return panel.id === itemId; });
525
- if (!groupItem) {
526
- throw new Error("No panel with id ".concat(itemId));
527
- }
528
- var dropLocation = (0, gridview_1.getRelativeLocation)(this.gridview.orientation, referenceLocation, target);
529
- var group = this.createGroupAtLocation(dropLocation);
530
- group.model.openPanel(groupItem);
531
- }
532
- }
533
- };
534
- DockviewComponent.prototype.doSetGroupActive = function (group, skipFocus) {
535
- var _a, _b;
536
- var isGroupAlreadyFocused = this._activeGroup === group;
537
- _super.prototype.doSetGroupActive.call(this, group, skipFocus);
538
- if (!isGroupAlreadyFocused && ((_a = this._activeGroup) === null || _a === void 0 ? void 0 : _a.activePanel)) {
539
- this._onDidActivePanelChange.fire((_b = this._activeGroup) === null || _b === void 0 ? void 0 : _b.activePanel);
540
- }
541
- };
542
- DockviewComponent.prototype.createGroup = function (options) {
543
- var _this = this;
544
- if (!options) {
545
- options = { tabHeight: this.tabHeight };
546
- }
547
- if (typeof options.tabHeight !== 'number') {
548
- options.tabHeight = this.tabHeight;
549
- }
550
- var id = options === null || options === void 0 ? void 0 : options.id;
551
- if (id && this._groups.has(options.id)) {
552
- console.warn("Duplicate group id ".concat(options === null || options === void 0 ? void 0 : options.id, ". reassigning group id to avoid errors"));
553
- id = undefined;
554
- }
555
- if (!id) {
556
- id = nextGroupId.next();
557
- while (this._groups.has(id)) {
558
- id = nextGroupId.next();
559
- }
560
- }
561
- var view = new groupviewPanel_1.GroupPanel(this, id, options);
562
- view.init({ params: {}, accessor: null }); // required to initialized .part and allow for correct disposal of group
563
- if (!this._groups.has(view.id)) {
564
- var disposable = new lifecycle_1.CompositeDisposable(view.model.onMove(function (event) {
565
- var groupId = event.groupId, itemId = event.itemId, target = event.target, index = event.index;
566
- _this.moveGroupOrPanel(view, groupId, itemId, target, index);
567
- }), view.model.onDidDrop(function (event) {
568
- _this._onDidDrop.fire(__assign(__assign({}, event), { api: _this._api, group: view }));
569
- }), view.model.onDidAddPanel(function (event) {
570
- _this._onDidAddPanel.fire(event.panel);
571
- }), view.model.onDidRemovePanel(function (event) {
572
- _this._onDidRemovePanel.fire(event.panel);
573
- }), view.model.onDidActivePanelChange(function (event) {
574
- _this._onDidActivePanelChange.fire(event.panel);
575
- }));
576
- this._groups.set(view.id, { value: view, disposable: disposable });
577
- }
578
- // TODO: must be called after the above listeners have been setup,
579
- // not an ideal pattern
580
- view.initialize();
581
- if (typeof this.options.tabHeight === 'number') {
582
- view.model.header.height = this.options.tabHeight;
583
- }
584
- return view;
585
- };
586
- DockviewComponent.prototype.createPanel = function (options, group) {
587
- var view = new defaultGroupPanelView_1.DefaultGroupPanelView({
588
- content: this.createContentComponent(options.id, options.component),
589
- tab: this.createTabComponent(options.id, options.tabComponent || this.options.defaultTabComponent),
590
- });
591
- var panel = new dockviewGroupPanel_1.DockviewGroupPanel(options.id, this, this._api, group);
592
- panel.init({
593
- view: view,
594
- title: options.title || options.id,
595
- suppressClosable: options === null || options === void 0 ? void 0 : options.suppressClosable,
596
- params: (options === null || options === void 0 ? void 0 : options.params) || {},
597
- });
598
- return panel;
599
- };
600
- DockviewComponent.prototype.createContentComponent = function (id, componentName) {
601
- var _a;
602
- return (0, componentFactory_1.createComponent)(id, componentName, this.options.components || {}, this.options.frameworkComponents, (_a = this.options.frameworkComponentFactory) === null || _a === void 0 ? void 0 : _a.content);
603
- };
604
- DockviewComponent.prototype.createTabComponent = function (id, componentName) {
605
- var _a;
606
- return (0, componentFactory_1.createComponent)(id, componentName, this.options.tabComponents || {}, this.options.frameworkTabComponents, (_a = this.options.frameworkComponentFactory) === null || _a === void 0 ? void 0 : _a.tab, function () { return new defaultTab_1.DefaultTab(); });
607
- };
608
- DockviewComponent.prototype.createGroupAtLocation = function (location) {
609
- if (location === void 0) { location = [0]; }
610
- var group = this.createGroup();
611
- this.doAddGroup(group, location);
612
- return group;
613
- };
614
- DockviewComponent.prototype.findGroup = function (panel) {
615
- var _a;
616
- return (_a = Array.from(this._groups.values()).find(function (group) {
617
- return group.value.model.containsPanel(panel);
618
- })) === null || _a === void 0 ? void 0 : _a.value;
619
- };
620
- DockviewComponent.prototype.dispose = function () {
621
- _super.prototype.dispose.call(this);
622
- this._onDidActivePanelChange.dispose();
623
- this._onDidAddPanel.dispose();
624
- this._onDidRemovePanel.dispose();
625
- this._onDidLayoutFromJSON.dispose();
626
- };
627
- return DockviewComponent;
628
- }(baseComponentGridview_1.BaseGrid));
629
- exports.DockviewComponent = DockviewComponent;
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __assign = (this && this.__assign) || function () {
18
+ __assign = Object.assign || function(t) {
19
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
20
+ s = arguments[i];
21
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
22
+ t[p] = s[p];
23
+ }
24
+ return t;
25
+ };
26
+ return __assign.apply(this, arguments);
27
+ };
28
+ var __values = (this && this.__values) || function(o) {
29
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
30
+ if (m) return m.call(o);
31
+ if (o && typeof o.length === "number") return {
32
+ next: function () {
33
+ if (o && i >= o.length) o = void 0;
34
+ return { value: o && o[i++], done: !o };
35
+ }
36
+ };
37
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
38
+ };
39
+ var __read = (this && this.__read) || function (o, n) {
40
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
41
+ if (!m) return o;
42
+ var i = m.call(o), r, ar = [], e;
43
+ try {
44
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
45
+ }
46
+ catch (error) { e = { error: error }; }
47
+ finally {
48
+ try {
49
+ if (r && !r.done && (m = i["return"])) m.call(i);
50
+ }
51
+ finally { if (e) throw e.error; }
52
+ }
53
+ return ar;
54
+ };
55
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
56
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
57
+ if (ar || !(i in from)) {
58
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
59
+ ar[i] = from[i];
60
+ }
61
+ }
62
+ return to.concat(ar || Array.prototype.slice.call(from));
63
+ };
64
+ Object.defineProperty(exports, "__esModule", { value: true });
65
+ exports.DockviewComponent = void 0;
66
+ var gridview_1 = require("../gridview/gridview");
67
+ var droptarget_1 = require("../dnd/droptarget");
68
+ var array_1 = require("../array");
69
+ var dockviewGroupPanel_1 = require("./dockviewGroupPanel");
70
+ var lifecycle_1 = require("../lifecycle");
71
+ var events_1 = require("../events");
72
+ var watermark_1 = require("./components/watermark/watermark");
73
+ var math_1 = require("../math");
74
+ var componentFactory_1 = require("../panel/componentFactory");
75
+ var baseComponentGridview_1 = require("../gridview/baseComponentGridview");
76
+ var component_api_1 = require("../api/component.api");
77
+ var splitview_1 = require("../splitview/core/splitview");
78
+ var defaultTab_1 = require("./components/tab/defaultTab");
79
+ var groupviewPanel_1 = require("../groupview/groupviewPanel");
80
+ var defaultGroupPanelView_1 = require("./defaultGroupPanelView");
81
+ var nextGroupId = (0, math_1.sequentialNumberGenerator)();
82
+ var DockviewComponent = /** @class */ (function (_super) {
83
+ __extends(DockviewComponent, _super);
84
+ function DockviewComponent(element, options) {
85
+ var _this = _super.call(this, element, {
86
+ proportionalLayout: true,
87
+ orientation: options.orientation || splitview_1.Orientation.HORIZONTAL,
88
+ styles: options.styles,
89
+ }) || this;
90
+ _this._onDidDrop = new events_1.Emitter();
91
+ _this.onDidDrop = _this._onDidDrop.event;
92
+ _this._onDidRemovePanel = new events_1.Emitter();
93
+ _this.onDidRemovePanel = _this._onDidRemovePanel.event;
94
+ _this._onDidAddPanel = new events_1.Emitter();
95
+ _this.onDidAddPanel = _this._onDidAddPanel.event;
96
+ _this._onDidLayoutFromJSON = new events_1.Emitter();
97
+ _this.onDidLayoutFromJSON = _this._onDidLayoutFromJSON.event;
98
+ _this._onDidActivePanelChange = new events_1.Emitter();
99
+ _this.onDidActivePanelChange = _this._onDidActivePanelChange.event;
100
+ _this.addDisposables(_this._onDidDrop, events_1.Event.any(_this.onDidAddPanel, _this.onDidRemovePanel, _this.onDidActivePanelChange)(function () {
101
+ _this._bufferOnDidLayoutChange.fire();
102
+ }));
103
+ _this._options = options;
104
+ if (!_this.options.components) {
105
+ _this.options.components = {};
106
+ }
107
+ if (!_this.options.frameworkComponents) {
108
+ _this.options.frameworkComponents = {};
109
+ }
110
+ if (!_this.options.frameworkTabComponents) {
111
+ _this.options.frameworkTabComponents = {};
112
+ }
113
+ if (!_this.options.tabComponents) {
114
+ _this.options.tabComponents = {};
115
+ }
116
+ if (!_this.options.watermarkComponent &&
117
+ !_this.options.watermarkFrameworkComponent) {
118
+ _this.options.watermarkComponent = watermark_1.Watermark;
119
+ }
120
+ _this._api = new component_api_1.DockviewApi(_this);
121
+ return _this;
122
+ }
123
+ Object.defineProperty(DockviewComponent.prototype, "totalPanels", {
124
+ get: function () {
125
+ return this.panels.length;
126
+ },
127
+ enumerable: false,
128
+ configurable: true
129
+ });
130
+ Object.defineProperty(DockviewComponent.prototype, "panels", {
131
+ get: function () {
132
+ return this.groups.flatMap(function (group) { return group.panels; });
133
+ },
134
+ enumerable: false,
135
+ configurable: true
136
+ });
137
+ Object.defineProperty(DockviewComponent.prototype, "deserializer", {
138
+ get: function () {
139
+ return this._deserializer;
140
+ },
141
+ set: function (value) {
142
+ this._deserializer = value;
143
+ },
144
+ enumerable: false,
145
+ configurable: true
146
+ });
147
+ Object.defineProperty(DockviewComponent.prototype, "options", {
148
+ get: function () {
149
+ return this._options;
150
+ },
151
+ enumerable: false,
152
+ configurable: true
153
+ });
154
+ Object.defineProperty(DockviewComponent.prototype, "activePanel", {
155
+ get: function () {
156
+ var activeGroup = this.activeGroup;
157
+ if (!activeGroup) {
158
+ return undefined;
159
+ }
160
+ return activeGroup.activePanel;
161
+ },
162
+ enumerable: false,
163
+ configurable: true
164
+ });
165
+ Object.defineProperty(DockviewComponent.prototype, "tabHeight", {
166
+ get: function () {
167
+ return this.options.tabHeight;
168
+ },
169
+ set: function (height) {
170
+ this.options.tabHeight = height;
171
+ this._groups.forEach(function (value) {
172
+ value.value.model.header.height = height;
173
+ });
174
+ },
175
+ enumerable: false,
176
+ configurable: true
177
+ });
178
+ DockviewComponent.prototype.updateOptions = function (options) {
179
+ var hasOrientationChanged = typeof options.orientation === 'string' &&
180
+ this.gridview.orientation !== options.orientation;
181
+ this._options = __assign(__assign({}, this.options), options);
182
+ if (hasOrientationChanged) {
183
+ this.gridview.orientation = options.orientation;
184
+ }
185
+ this.layout(this.gridview.width, this.gridview.height, true);
186
+ };
187
+ DockviewComponent.prototype.focus = function () {
188
+ var _a;
189
+ (_a = this.activeGroup) === null || _a === void 0 ? void 0 : _a.focus();
190
+ };
191
+ DockviewComponent.prototype.getGroupPanel = function (id) {
192
+ return this.panels.find(function (panel) { return panel.id === id; });
193
+ };
194
+ DockviewComponent.prototype.setActivePanel = function (panel) {
195
+ this.doSetGroupActive(panel.group);
196
+ panel.group.model.openPanel(panel);
197
+ };
198
+ DockviewComponent.prototype.moveToNext = function (options) {
199
+ var _a;
200
+ if (options === void 0) { options = {}; }
201
+ if (!options.group) {
202
+ if (!this.activeGroup) {
203
+ return;
204
+ }
205
+ options.group = this.activeGroup;
206
+ }
207
+ if (options.includePanel && options.group) {
208
+ if (options.group.activePanel !==
209
+ options.group.panels[options.group.panels.length - 1]) {
210
+ options.group.model.moveToNext({ suppressRoll: true });
211
+ return;
212
+ }
213
+ }
214
+ var location = (0, gridview_1.getGridLocation)(options.group.element);
215
+ var next = (_a = this.gridview.next(location)) === null || _a === void 0 ? void 0 : _a.view;
216
+ this.doSetGroupActive(next);
217
+ };
218
+ DockviewComponent.prototype.moveToPrevious = function (options) {
219
+ var _a;
220
+ if (options === void 0) { options = {}; }
221
+ if (!options.group) {
222
+ if (!this.activeGroup) {
223
+ return;
224
+ }
225
+ options.group = this.activeGroup;
226
+ }
227
+ if (options.includePanel && options.group) {
228
+ if (options.group.activePanel !==
229
+ options.group.panels[0]) {
230
+ options.group.model.moveToPrevious({ suppressRoll: true });
231
+ return;
232
+ }
233
+ }
234
+ var location = (0, gridview_1.getGridLocation)(options.group.element);
235
+ var next = (_a = this.gridview.previous(location)) === null || _a === void 0 ? void 0 : _a.view;
236
+ if (next) {
237
+ this.doSetGroupActive(next);
238
+ }
239
+ };
240
+ /**
241
+ * Serialize the current state of the layout
242
+ *
243
+ * @returns A JSON respresentation of the layout
244
+ */
245
+ DockviewComponent.prototype.toJSON = function () {
246
+ var _a;
247
+ var data = this.gridview.serialize();
248
+ var panels = this.panels.reduce(function (collection, panel) {
249
+ collection[panel.id] = panel.toJSON();
250
+ return collection;
251
+ }, {});
252
+ return {
253
+ grid: data,
254
+ panels: panels,
255
+ activeGroup: (_a = this.activeGroup) === null || _a === void 0 ? void 0 : _a.id,
256
+ options: { tabHeight: this.tabHeight },
257
+ };
258
+ };
259
+ DockviewComponent.prototype.fromJSON = function (data) {
260
+ var _this = this;
261
+ this.clear();
262
+ if (!this.deserializer) {
263
+ throw new Error('invalid deserializer');
264
+ }
265
+ var grid = data.grid, panels = data.panels, options = data.options, activeGroup = data.activeGroup;
266
+ if (typeof (options === null || options === void 0 ? void 0 : options.tabHeight) === 'number') {
267
+ this.tabHeight = options.tabHeight;
268
+ }
269
+ if (!this.deserializer) {
270
+ throw new Error('no deserializer provided');
271
+ }
272
+ this.gridview.deserialize(grid, {
273
+ fromJSON: function (node) {
274
+ var e_1, _a;
275
+ var _b = node.data, id = _b.id, locked = _b.locked, hideHeader = _b.hideHeader, views = _b.views, activeView = _b.activeView;
276
+ var group = _this.createGroup({
277
+ id: id,
278
+ locked: !!locked,
279
+ hideHeader: !!hideHeader,
280
+ });
281
+ _this._onDidAddGroup.fire(group);
282
+ try {
283
+ for (var views_1 = __values(views), views_1_1 = views_1.next(); !views_1_1.done; views_1_1 = views_1.next()) {
284
+ var child = views_1_1.value;
285
+ var panel = _this.deserializer.fromJSON(panels[child], group);
286
+ var isActive = typeof activeView === 'string' && activeView === panel.id;
287
+ group.model.openPanel(panel, {
288
+ skipSetPanelActive: !isActive,
289
+ skipSetGroupActive: true
290
+ });
291
+ }
292
+ }
293
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
294
+ finally {
295
+ try {
296
+ if (views_1_1 && !views_1_1.done && (_a = views_1.return)) _a.call(views_1);
297
+ }
298
+ finally { if (e_1) throw e_1.error; }
299
+ }
300
+ if (!group.activePanel && group.panels.length > 0) {
301
+ group.model.openPanel(group.panels[group.panels.length - 1], {
302
+ skipSetGroupActive: true
303
+ });
304
+ }
305
+ return group;
306
+ }
307
+ });
308
+ if (typeof activeGroup === 'string') {
309
+ var panel = this.getPanel(activeGroup);
310
+ if (panel) {
311
+ this.doSetGroupActive(panel);
312
+ }
313
+ }
314
+ this.gridview.layout(this.width, this.height);
315
+ this._onDidLayoutFromJSON.fire();
316
+ };
317
+ DockviewComponent.prototype.clear = function () {
318
+ var e_2, _a;
319
+ var groups = Array.from(this._groups.values()).map(function (_) { return _.value; });
320
+ var hasActiveGroup = !!this.activeGroup;
321
+ var hasActivePanel = !!this.activePanel;
322
+ try {
323
+ for (var groups_1 = __values(groups), groups_1_1 = groups_1.next(); !groups_1_1.done; groups_1_1 = groups_1.next()) {
324
+ var group = groups_1_1.value;
325
+ // remove the group will automatically remove the panels
326
+ this.removeGroup(group, true);
327
+ }
328
+ }
329
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
330
+ finally {
331
+ try {
332
+ if (groups_1_1 && !groups_1_1.done && (_a = groups_1.return)) _a.call(groups_1);
333
+ }
334
+ finally { if (e_2) throw e_2.error; }
335
+ }
336
+ if (hasActiveGroup) {
337
+ this.doSetGroupActive(undefined);
338
+ }
339
+ if (hasActivePanel) {
340
+ this._onDidActivePanelChange.fire(undefined);
341
+ }
342
+ this.gridview.clear();
343
+ };
344
+ DockviewComponent.prototype.closeAllGroups = function () {
345
+ var e_3, _a;
346
+ try {
347
+ for (var _b = __values(this._groups.entries()), _c = _b.next(); !_c.done; _c = _b.next()) {
348
+ var entry = _c.value;
349
+ var _d = __read(entry, 2), _1 = _d[0], group = _d[1];
350
+ group.value.model.closeAllPanels();
351
+ }
352
+ }
353
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
354
+ finally {
355
+ try {
356
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
357
+ }
358
+ finally { if (e_3) throw e_3.error; }
359
+ }
360
+ };
361
+ DockviewComponent.prototype.addPanel = function (options) {
362
+ var _a, _b;
363
+ if (this.panels.find(function (_) { return _.id === options.id; })) {
364
+ throw new Error("panel with id ".concat(options.id, " already exists"));
365
+ }
366
+ var referenceGroup;
367
+ if ((_a = options.position) === null || _a === void 0 ? void 0 : _a.referencePanel) {
368
+ var referencePanel = this.getGroupPanel(options.position.referencePanel);
369
+ if (!referencePanel) {
370
+ throw new Error("referencePanel ".concat(options.position.referencePanel, " does not exist"));
371
+ }
372
+ referenceGroup = this.findGroup(referencePanel);
373
+ }
374
+ else {
375
+ referenceGroup = this.activeGroup;
376
+ }
377
+ var panel;
378
+ if (referenceGroup) {
379
+ var target = (0, baseComponentGridview_1.toTarget)(((_b = options.position) === null || _b === void 0 ? void 0 : _b.direction) || 'within');
380
+ if (target === droptarget_1.Position.Center) {
381
+ panel = this.createPanel(options, referenceGroup);
382
+ referenceGroup.model.openPanel(panel);
383
+ }
384
+ else {
385
+ var location_1 = (0, gridview_1.getGridLocation)(referenceGroup.element);
386
+ var relativeLocation = (0, gridview_1.getRelativeLocation)(this.gridview.orientation, location_1, target);
387
+ var group = this.createGroupAtLocation(relativeLocation);
388
+ panel = this.createPanel(options, group);
389
+ group.model.openPanel(panel);
390
+ }
391
+ }
392
+ else {
393
+ var group = this.createGroupAtLocation();
394
+ panel = this.createPanel(options, group);
395
+ group.model.openPanel(panel);
396
+ }
397
+ return panel;
398
+ };
399
+ DockviewComponent.prototype.removePanel = function (panel, options) {
400
+ if (options === void 0) { options = {
401
+ removeEmptyGroup: true,
402
+ skipDispose: false,
403
+ }; }
404
+ var group = panel.group;
405
+ if (!group) {
406
+ throw new Error("cannot remove panel ".concat(panel.id, ". it's missing a group."));
407
+ }
408
+ group.model.removePanel(panel);
409
+ panel.dispose();
410
+ var retainGroupForWatermark = this.size === 1;
411
+ if (!retainGroupForWatermark &&
412
+ group.size === 0 &&
413
+ options.removeEmptyGroup) {
414
+ this.removeGroup(group);
415
+ }
416
+ };
417
+ DockviewComponent.prototype.createWatermarkComponent = function () {
418
+ var _a;
419
+ return (0, componentFactory_1.createComponent)('watermark-id', 'watermark-name', this.options.watermarkComponent
420
+ ? { 'watermark-name': this.options.watermarkComponent }
421
+ : {}, this.options.watermarkFrameworkComponent
422
+ ? { 'watermark-name': this.options.watermarkFrameworkComponent }
423
+ : {}, (_a = this.options.frameworkComponentFactory) === null || _a === void 0 ? void 0 : _a.watermark);
424
+ };
425
+ DockviewComponent.prototype.addEmptyGroup = function (options) {
426
+ var group = this.createGroup();
427
+ if (options) {
428
+ var referencePanel = this.panels.find(function (panel) { return panel.id === options.referencePanel; });
429
+ if (!referencePanel) {
430
+ throw new Error("reference panel ".concat(options.referencePanel, " does not exist"));
431
+ }
432
+ var referenceGroup = this.findGroup(referencePanel);
433
+ if (!referenceGroup) {
434
+ throw new Error("reference group for reference panel ".concat(options.referencePanel, " does not exist"));
435
+ }
436
+ var target = (0, baseComponentGridview_1.toTarget)(options.direction || 'within');
437
+ var location_2 = (0, gridview_1.getGridLocation)(referenceGroup.element);
438
+ var relativeLocation = (0, gridview_1.getRelativeLocation)(this.gridview.orientation, location_2, target);
439
+ this.doAddGroup(group, relativeLocation);
440
+ }
441
+ else {
442
+ this.doAddGroup(group);
443
+ }
444
+ };
445
+ DockviewComponent.prototype.removeGroup = function (group, skipActive) {
446
+ var e_4, _a;
447
+ if (skipActive === void 0) { skipActive = false; }
448
+ var panels = __spreadArray([], __read(group.panels), false); // reassign since group panels will mutate
449
+ try {
450
+ for (var panels_1 = __values(panels), panels_1_1 = panels_1.next(); !panels_1_1.done; panels_1_1 = panels_1.next()) {
451
+ var panel = panels_1_1.value;
452
+ this.removePanel(panel, {
453
+ removeEmptyGroup: false,
454
+ skipDispose: false,
455
+ });
456
+ }
457
+ }
458
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
459
+ finally {
460
+ try {
461
+ if (panels_1_1 && !panels_1_1.done && (_a = panels_1.return)) _a.call(panels_1);
462
+ }
463
+ finally { if (e_4) throw e_4.error; }
464
+ }
465
+ _super.prototype.doRemoveGroup.call(this, group, { skipActive: skipActive });
466
+ };
467
+ DockviewComponent.prototype.moveGroupOrPanel = function (referenceGroup, groupId, itemId, target, index) {
468
+ var _a;
469
+ var sourceGroup = groupId
470
+ ? (_a = this._groups.get(groupId)) === null || _a === void 0 ? void 0 : _a.value
471
+ : undefined;
472
+ if (!target || target === droptarget_1.Position.Center) {
473
+ var groupItem = (sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(itemId)) ||
474
+ this.panels.find(function (panel) { return panel.id === itemId; });
475
+ if (!groupItem) {
476
+ throw new Error("No panel with id ".concat(itemId));
477
+ }
478
+ if ((sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.size) === 0) {
479
+ this.doRemoveGroup(sourceGroup);
480
+ }
481
+ referenceGroup.model.openPanel(groupItem, { index: index });
482
+ }
483
+ else {
484
+ var referenceLocation = (0, gridview_1.getGridLocation)(referenceGroup.element);
485
+ var targetLocation = (0, gridview_1.getRelativeLocation)(this.gridview.orientation, referenceLocation, target);
486
+ if (sourceGroup && sourceGroup.size < 2) {
487
+ var _b = __read((0, array_1.tail)(targetLocation), 2), targetParentLocation = _b[0], to = _b[1];
488
+ var sourceLocation = (0, gridview_1.getGridLocation)(sourceGroup.element);
489
+ var _c = __read((0, array_1.tail)(sourceLocation), 2), sourceParentLocation = _c[0], from = _c[1];
490
+ if ((0, array_1.sequenceEquals)(sourceParentLocation, targetParentLocation)) {
491
+ // special case when 'swapping' two views within same grid location
492
+ // if a group has one tab - we are essentially moving the 'group'
493
+ // which is equivalent to swapping two views in this case
494
+ this.gridview.moveView(sourceParentLocation, from, to);
495
+ }
496
+ else {
497
+ // source group will become empty so delete the group
498
+ var targetGroup = this.doRemoveGroup(sourceGroup, {
499
+ skipActive: true,
500
+ skipDispose: true,
501
+ });
502
+ // after deleting the group we need to re-evaulate the ref location
503
+ var updatedReferenceLocation = (0, gridview_1.getGridLocation)(referenceGroup.element);
504
+ var location_3 = (0, gridview_1.getRelativeLocation)(this.gridview.orientation, updatedReferenceLocation, target);
505
+ this.doAddGroup(targetGroup, location_3);
506
+ }
507
+ }
508
+ else {
509
+ var groupItem = (sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(itemId)) ||
510
+ this.panels.find(function (panel) { return panel.id === itemId; });
511
+ if (!groupItem) {
512
+ throw new Error("No panel with id ".concat(itemId));
513
+ }
514
+ var dropLocation = (0, gridview_1.getRelativeLocation)(this.gridview.orientation, referenceLocation, target);
515
+ var group = this.createGroupAtLocation(dropLocation);
516
+ group.model.openPanel(groupItem);
517
+ }
518
+ }
519
+ };
520
+ DockviewComponent.prototype.doSetGroupActive = function (group, skipFocus) {
521
+ var _a, _b;
522
+ var isGroupAlreadyFocused = this._activeGroup === group;
523
+ _super.prototype.doSetGroupActive.call(this, group, skipFocus);
524
+ if (!isGroupAlreadyFocused && ((_a = this._activeGroup) === null || _a === void 0 ? void 0 : _a.activePanel)) {
525
+ this._onDidActivePanelChange.fire((_b = this._activeGroup) === null || _b === void 0 ? void 0 : _b.activePanel);
526
+ }
527
+ };
528
+ DockviewComponent.prototype.createGroup = function (options) {
529
+ var _this = this;
530
+ if (!options) {
531
+ options = { tabHeight: this.tabHeight };
532
+ }
533
+ if (typeof options.tabHeight !== 'number') {
534
+ options.tabHeight = this.tabHeight;
535
+ }
536
+ var id = options === null || options === void 0 ? void 0 : options.id;
537
+ if (id && this._groups.has(options.id)) {
538
+ console.warn("Duplicate group id ".concat(options === null || options === void 0 ? void 0 : options.id, ". reassigning group id to avoid errors"));
539
+ id = undefined;
540
+ }
541
+ if (!id) {
542
+ id = nextGroupId.next();
543
+ while (this._groups.has(id)) {
544
+ id = nextGroupId.next();
545
+ }
546
+ }
547
+ var view = new groupviewPanel_1.GroupPanel(this, id, options);
548
+ view.init({ params: {}, accessor: null }); // required to initialized .part and allow for correct disposal of group
549
+ if (!this._groups.has(view.id)) {
550
+ var disposable = new lifecycle_1.CompositeDisposable(view.model.onMove(function (event) {
551
+ var groupId = event.groupId, itemId = event.itemId, target = event.target, index = event.index;
552
+ _this.moveGroupOrPanel(view, groupId, itemId, target, index);
553
+ }), view.model.onDidDrop(function (event) {
554
+ _this._onDidDrop.fire(__assign(__assign({}, event), { api: _this._api, group: view }));
555
+ }), view.model.onDidAddPanel(function (event) {
556
+ _this._onDidAddPanel.fire(event.panel);
557
+ }), view.model.onDidRemovePanel(function (event) {
558
+ _this._onDidRemovePanel.fire(event.panel);
559
+ }), view.model.onDidActivePanelChange(function (event) {
560
+ _this._onDidActivePanelChange.fire(event.panel);
561
+ }));
562
+ this._groups.set(view.id, { value: view, disposable: disposable });
563
+ }
564
+ // TODO: must be called after the above listeners have been setup,
565
+ // not an ideal pattern
566
+ view.initialize();
567
+ if (typeof this.options.tabHeight === 'number') {
568
+ view.model.header.height = this.options.tabHeight;
569
+ }
570
+ return view;
571
+ };
572
+ DockviewComponent.prototype.createPanel = function (options, group) {
573
+ var view = new defaultGroupPanelView_1.DefaultGroupPanelView({
574
+ content: this.createContentComponent(options.id, options.component),
575
+ tab: this.createTabComponent(options.id, options.tabComponent || this.options.defaultTabComponent),
576
+ });
577
+ var panel = new dockviewGroupPanel_1.DockviewGroupPanel(options.id, this, this._api, group);
578
+ panel.init({
579
+ view: view,
580
+ title: options.title || options.id,
581
+ params: (options === null || options === void 0 ? void 0 : options.params) || {},
582
+ });
583
+ return panel;
584
+ };
585
+ DockviewComponent.prototype.createContentComponent = function (id, componentName) {
586
+ var _a;
587
+ return (0, componentFactory_1.createComponent)(id, componentName, this.options.components || {}, this.options.frameworkComponents, (_a = this.options.frameworkComponentFactory) === null || _a === void 0 ? void 0 : _a.content);
588
+ };
589
+ DockviewComponent.prototype.createTabComponent = function (id, componentName) {
590
+ var _a;
591
+ return (0, componentFactory_1.createComponent)(id, componentName, this.options.tabComponents || {}, this.options.frameworkTabComponents, (_a = this.options.frameworkComponentFactory) === null || _a === void 0 ? void 0 : _a.tab, function () { return new defaultTab_1.DefaultTab(); });
592
+ };
593
+ DockviewComponent.prototype.createGroupAtLocation = function (location) {
594
+ if (location === void 0) { location = [0]; }
595
+ var group = this.createGroup();
596
+ this.doAddGroup(group, location);
597
+ return group;
598
+ };
599
+ DockviewComponent.prototype.findGroup = function (panel) {
600
+ var _a;
601
+ return (_a = Array.from(this._groups.values()).find(function (group) {
602
+ return group.value.model.containsPanel(panel);
603
+ })) === null || _a === void 0 ? void 0 : _a.value;
604
+ };
605
+ DockviewComponent.prototype.dispose = function () {
606
+ _super.prototype.dispose.call(this);
607
+ this._onDidActivePanelChange.dispose();
608
+ this._onDidAddPanel.dispose();
609
+ this._onDidRemovePanel.dispose();
610
+ this._onDidLayoutFromJSON.dispose();
611
+ };
612
+ return DockviewComponent;
613
+ }(baseComponentGridview_1.BaseGrid));
614
+ exports.DockviewComponent = DockviewComponent;
630
615
  //# sourceMappingURL=dockviewComponent.js.map