dockview 1.5.1 → 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 (329) 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 -34
  10. package/dist/cjs/api/groupPanelApi.js +85 -85
  11. package/dist/cjs/api/panelApi.d.ts +81 -81
  12. package/dist/cjs/api/panelApi.js +121 -121
  13. package/dist/cjs/api/paneviewPanelApi.d.ts +26 -26
  14. package/dist/cjs/api/paneviewPanelApi.js +57 -57
  15. package/dist/cjs/api/splitviewPanelApi.d.ts +32 -32
  16. package/dist/cjs/api/splitviewPanelApi.js +47 -47
  17. package/dist/cjs/array.d.ts +13 -13
  18. package/dist/cjs/array.js +77 -77
  19. package/dist/cjs/dnd/abstractDragHandler.d.ts +11 -11
  20. package/dist/cjs/dnd/abstractDragHandler.js +115 -115
  21. package/dist/cjs/dnd/dataTransfer.d.ts +31 -31
  22. package/dist/cjs/dnd/dataTransfer.js +100 -100
  23. package/dist/cjs/dnd/dnd.d.ts +27 -27
  24. package/dist/cjs/dnd/dnd.js +64 -64
  25. package/dist/cjs/dnd/droptarget.d.ts +37 -37
  26. package/dist/cjs/dnd/droptarget.js +201 -201
  27. package/dist/cjs/dockview/components/tab/defaultTab.d.ts +27 -27
  28. package/dist/cjs/dockview/components/tab/defaultTab.js +121 -121
  29. package/dist/cjs/dockview/components/watermark/watermark.d.ts +20 -20
  30. package/dist/cjs/dockview/components/watermark/watermark.js +101 -101
  31. package/dist/cjs/dockview/defaultGroupPanelView.d.ts +29 -29
  32. package/dist/cjs/dockview/defaultGroupPanelView.js +68 -68
  33. package/dist/cjs/dockview/deserializer.d.ts +5 -5
  34. package/dist/cjs/dockview/deserializer.js +2 -2
  35. package/dist/cjs/dockview/dockviewComponent.d.ts +125 -125
  36. package/dist/cjs/dockview/dockviewComponent.js +614 -614
  37. package/dist/cjs/dockview/dockviewComponent.js.map +1 -1
  38. package/dist/cjs/dockview/dockviewGroupPanel.d.ts +31 -31
  39. package/dist/cjs/dockview/dockviewGroupPanel.js +156 -156
  40. package/dist/cjs/dockview/options.d.ts +88 -88
  41. package/dist/cjs/dockview/options.js +2 -2
  42. package/dist/cjs/dom.d.ts +14 -14
  43. package/dist/cjs/dom.js +182 -182
  44. package/dist/cjs/events.d.ts +30 -30
  45. package/dist/cjs/events.js +129 -129
  46. package/dist/cjs/gridview/baseComponentGridview.d.ts +87 -87
  47. package/dist/cjs/gridview/baseComponentGridview.js +279 -279
  48. package/dist/cjs/gridview/basePanelView.d.ts +43 -43
  49. package/dist/cjs/gridview/basePanelView.js +123 -123
  50. package/dist/cjs/gridview/branchNode.d.ts +49 -46
  51. package/dist/cjs/gridview/branchNode.js +342 -342
  52. package/dist/cjs/gridview/branchNode.js.map +1 -1
  53. package/dist/cjs/gridview/gridview.d.ts +126 -123
  54. package/dist/cjs/gridview/gridview.js +479 -479
  55. package/dist/cjs/gridview/gridview.js.map +1 -1
  56. package/dist/cjs/gridview/gridviewComponent.d.ts +85 -85
  57. package/dist/cjs/gridview/gridviewComponent.js +325 -325
  58. package/dist/cjs/gridview/gridviewPanel.d.ts +60 -60
  59. package/dist/cjs/gridview/gridviewPanel.js +202 -202
  60. package/dist/cjs/gridview/leafNode.d.ts +34 -31
  61. package/dist/cjs/gridview/leafNode.js +170 -165
  62. package/dist/cjs/gridview/leafNode.js.map +1 -1
  63. package/dist/cjs/gridview/options.d.ts +18 -18
  64. package/dist/cjs/gridview/options.js +2 -2
  65. package/dist/cjs/gridview/types.d.ts +3 -3
  66. package/dist/cjs/gridview/types.js +2 -2
  67. package/dist/cjs/groupview/dnd.d.ts +5 -5
  68. package/dist/cjs/groupview/dnd.js +9 -9
  69. package/dist/cjs/groupview/groupPanel.d.ts +32 -32
  70. package/dist/cjs/groupview/groupPanel.js +2 -2
  71. package/dist/cjs/groupview/groupview.d.ts +177 -177
  72. package/dist/cjs/groupview/groupview.js +589 -589
  73. package/dist/cjs/groupview/groupviewPanel.d.ts +35 -35
  74. package/dist/cjs/groupview/groupviewPanel.js +128 -128
  75. package/dist/cjs/groupview/panel/content.d.ts +30 -30
  76. package/dist/cjs/groupview/panel/content.js +100 -100
  77. package/dist/cjs/groupview/tab.d.ts +41 -41
  78. package/dist/cjs/groupview/tab.js +120 -120
  79. package/dist/cjs/groupview/titlebar/tabsContainer.d.ts +68 -68
  80. package/dist/cjs/groupview/titlebar/tabsContainer.js +258 -258
  81. package/dist/cjs/groupview/types.d.ts +52 -52
  82. package/dist/cjs/groupview/types.js +2 -2
  83. package/dist/cjs/hostedContainer.d.ts +23 -23
  84. package/dist/cjs/hostedContainer.js +73 -73
  85. package/dist/cjs/index.d.ts +30 -30
  86. package/dist/cjs/index.js +46 -46
  87. package/dist/cjs/lifecycle.d.ts +22 -22
  88. package/dist/cjs/lifecycle.js +88 -88
  89. package/dist/cjs/math.d.ts +4 -4
  90. package/dist/cjs/math.js +15 -15
  91. package/dist/cjs/panel/componentFactory.d.ts +8 -8
  92. package/dist/cjs/panel/componentFactory.js +30 -30
  93. package/dist/cjs/panel/types.d.ts +33 -33
  94. package/dist/cjs/panel/types.js +2 -2
  95. package/dist/cjs/paneview/defaultPaneviewHeader.d.ts +21 -21
  96. package/dist/cjs/paneview/defaultPaneviewHeader.js +90 -90
  97. package/dist/cjs/paneview/draggablePaneviewPanel.d.ts +19 -19
  98. package/dist/cjs/paneview/draggablePaneviewPanel.js +129 -129
  99. package/dist/cjs/paneview/options.d.ts +27 -27
  100. package/dist/cjs/paneview/options.js +2 -2
  101. package/dist/cjs/paneview/paneview.d.ts +40 -40
  102. package/dist/cjs/paneview/paneview.js +201 -201
  103. package/dist/cjs/paneview/paneviewComponent.d.ts +129 -129
  104. package/dist/cjs/paneview/paneviewComponent.js +394 -394
  105. package/dist/cjs/paneview/paneviewPanel.d.ts +92 -89
  106. package/dist/cjs/paneview/paneviewPanel.js +274 -274
  107. package/dist/cjs/paneview/paneviewPanel.js.map +1 -1
  108. package/dist/cjs/react/deserializer.d.ts +9 -9
  109. package/dist/cjs/react/deserializer.js +43 -43
  110. package/dist/cjs/react/dockview/defaultTab.d.ts +4 -4
  111. package/dist/cjs/react/dockview/defaultTab.js +72 -72
  112. package/dist/cjs/react/dockview/dockview.d.ts +34 -34
  113. package/dist/cjs/react/dockview/dockview.js +212 -212
  114. package/dist/cjs/react/dockview/groupControlsRenderer.d.ts +43 -43
  115. package/dist/cjs/react/dockview/groupControlsRenderer.js +86 -86
  116. package/dist/cjs/react/dockview/reactContentPart.d.ts +30 -30
  117. package/dist/cjs/react/dockview/reactContentPart.js +58 -58
  118. package/dist/cjs/react/dockview/reactHeaderPart.d.ts +26 -26
  119. package/dist/cjs/react/dockview/reactHeaderPart.js +55 -55
  120. package/dist/cjs/react/dockview/reactWatermarkPart.d.ts +29 -29
  121. package/dist/cjs/react/dockview/reactWatermarkPart.js +65 -65
  122. package/dist/cjs/react/dockview/v2/reactContentRenderer.d.ts +29 -29
  123. package/dist/cjs/react/dockview/v2/reactContentRenderer.js +87 -87
  124. package/dist/cjs/react/dockview/v2/reactGroupPanelView.d.ts +7 -7
  125. package/dist/cjs/react/dockview/v2/reactGroupPanelView.js +34 -34
  126. package/dist/cjs/react/dockview/v2/webviewContentRenderer.d.ts +18 -18
  127. package/dist/cjs/react/dockview/v2/webviewContentRenderer.js +45 -45
  128. package/dist/cjs/react/gridview/gridview.d.ts +24 -24
  129. package/dist/cjs/react/gridview/gridview.js +112 -112
  130. package/dist/cjs/react/gridview/view.d.ts +11 -11
  131. package/dist/cjs/react/gridview/view.js +40 -40
  132. package/dist/cjs/react/index.d.ts +9 -9
  133. package/dist/cjs/react/index.js +23 -23
  134. package/dist/cjs/react/paneview/paneview.d.ts +30 -30
  135. package/dist/cjs/react/paneview/paneview.js +155 -155
  136. package/dist/cjs/react/paneview/view.d.ts +20 -20
  137. package/dist/cjs/react/paneview/view.js +44 -44
  138. package/dist/cjs/react/react.d.ts +36 -36
  139. package/dist/cjs/react/react.js +194 -194
  140. package/dist/cjs/react/splitview/splitview.d.ts +24 -24
  141. package/dist/cjs/react/splitview/splitview.js +108 -108
  142. package/dist/cjs/react/splitview/view.d.ts +10 -10
  143. package/dist/cjs/react/splitview/view.js +40 -40
  144. package/dist/cjs/react/svg.d.ts +3 -3
  145. package/dist/cjs/react/svg.js +35 -35
  146. package/dist/cjs/react/types.d.ts +7 -7
  147. package/dist/cjs/react/types.js +2 -2
  148. package/dist/cjs/splitview/core/options.d.ts +26 -26
  149. package/dist/cjs/splitview/core/options.js +2 -2
  150. package/dist/cjs/splitview/core/splitview.d.ts +127 -124
  151. package/dist/cjs/splitview/core/splitview.js +908 -908
  152. package/dist/cjs/splitview/core/splitview.js.map +1 -1
  153. package/dist/cjs/splitview/core/viewItem.d.ts +25 -25
  154. package/dist/cjs/splitview/core/viewItem.js +124 -124
  155. package/dist/cjs/splitview/splitviewComponent.d.ts +101 -101
  156. package/dist/cjs/splitview/splitviewComponent.js +373 -373
  157. package/dist/cjs/splitview/splitviewPanel.d.ts +45 -42
  158. package/dist/cjs/splitview/splitviewPanel.js +178 -178
  159. package/dist/cjs/splitview/splitviewPanel.js.map +1 -1
  160. package/dist/cjs/svg.d.ts +3 -3
  161. package/dist/cjs/svg.js +43 -43
  162. package/dist/cjs/types.d.ts +7 -7
  163. package/dist/cjs/types.js +2 -2
  164. package/dist/dockview.amd.js +6737 -6732
  165. package/dist/dockview.amd.min.js +2 -2
  166. package/dist/dockview.amd.min.noStyle.js +2 -2
  167. package/dist/dockview.amd.noStyle.js +6743 -6738
  168. package/dist/dockview.cjs.js +6736 -6731
  169. package/dist/dockview.esm.js +6731 -6726
  170. package/dist/dockview.esm.min.js +2 -2
  171. package/dist/dockview.js +6737 -6732
  172. package/dist/dockview.min.js +2 -2
  173. package/dist/dockview.min.noStyle.js +2 -2
  174. package/dist/dockview.noStyle.js +6743 -6738
  175. package/dist/esm/actionbar/actionsContainer.d.ts +7 -7
  176. package/dist/esm/actionbar/actionsContainer.js +17 -17
  177. package/dist/esm/api/component.api.d.ts +144 -144
  178. package/dist/esm/api/component.api.js +326 -326
  179. package/dist/esm/api/gridviewPanelApi.d.ts +36 -36
  180. package/dist/esm/api/gridviewPanelApi.js +25 -25
  181. package/dist/esm/api/groupPanelApi.d.ts +34 -34
  182. package/dist/esm/api/groupPanelApi.js +50 -50
  183. package/dist/esm/api/panelApi.d.ts +81 -81
  184. package/dist/esm/api/panelApi.js +79 -79
  185. package/dist/esm/api/paneviewPanelApi.d.ts +26 -26
  186. package/dist/esm/api/paneviewPanelApi.js +27 -27
  187. package/dist/esm/api/splitviewPanelApi.d.ts +32 -32
  188. package/dist/esm/api/splitviewPanelApi.js +25 -25
  189. package/dist/esm/array.d.ts +13 -13
  190. package/dist/esm/array.js +67 -67
  191. package/dist/esm/dnd/abstractDragHandler.d.ts +11 -11
  192. package/dist/esm/dnd/abstractDragHandler.js +37 -37
  193. package/dist/esm/dnd/dataTransfer.d.ts +31 -31
  194. package/dist/esm/dnd/dataTransfer.js +69 -69
  195. package/dist/esm/dnd/dnd.d.ts +27 -27
  196. package/dist/esm/dnd/dnd.js +41 -41
  197. package/dist/esm/dnd/droptarget.d.ts +37 -37
  198. package/dist/esm/dnd/droptarget.js +167 -167
  199. package/dist/esm/dockview/components/tab/defaultTab.d.ts +27 -27
  200. package/dist/esm/dockview/components/tab/defaultTab.js +79 -79
  201. package/dist/esm/dockview/components/watermark/watermark.d.ts +20 -20
  202. package/dist/esm/dockview/components/watermark/watermark.js +70 -70
  203. package/dist/esm/dockview/defaultGroupPanelView.d.ts +29 -29
  204. package/dist/esm/dockview/defaultGroupPanelView.js +44 -44
  205. package/dist/esm/dockview/deserializer.d.ts +5 -5
  206. package/dist/esm/dockview/deserializer.js +1 -1
  207. package/dist/esm/dockview/dockviewComponent.d.ts +125 -125
  208. package/dist/esm/dockview/dockviewComponent.js +468 -468
  209. package/dist/esm/dockview/dockviewGroupPanel.d.ts +31 -31
  210. package/dist/esm/dockview/dockviewGroupPanel.js +107 -107
  211. package/dist/esm/dockview/options.d.ts +88 -88
  212. package/dist/esm/dockview/options.js +1 -1
  213. package/dist/esm/dom.d.ts +14 -14
  214. package/dist/esm/dom.js +113 -113
  215. package/dist/esm/events.d.ts +30 -30
  216. package/dist/esm/events.js +88 -88
  217. package/dist/esm/gridview/baseComponentGridview.d.ts +87 -87
  218. package/dist/esm/gridview/baseComponentGridview.js +189 -189
  219. package/dist/esm/gridview/basePanelView.d.ts +43 -43
  220. package/dist/esm/gridview/basePanelView.js +74 -74
  221. package/dist/esm/gridview/branchNode.d.ts +49 -46
  222. package/dist/esm/gridview/branchNode.js +218 -218
  223. package/dist/esm/gridview/gridview.d.ts +126 -123
  224. package/dist/esm/gridview/gridview.js +397 -397
  225. package/dist/esm/gridview/gridviewComponent.d.ts +85 -85
  226. package/dist/esm/gridview/gridviewComponent.js +238 -238
  227. package/dist/esm/gridview/gridviewPanel.d.ts +60 -60
  228. package/dist/esm/gridview/gridviewPanel.js +138 -138
  229. package/dist/esm/gridview/leafNode.d.ts +34 -31
  230. package/dist/esm/gridview/leafNode.js +103 -98
  231. package/dist/esm/gridview/options.d.ts +18 -18
  232. package/dist/esm/gridview/options.js +1 -1
  233. package/dist/esm/gridview/types.d.ts +3 -3
  234. package/dist/esm/gridview/types.js +1 -1
  235. package/dist/esm/groupview/dnd.d.ts +5 -5
  236. package/dist/esm/groupview/dnd.js +6 -6
  237. package/dist/esm/groupview/groupPanel.d.ts +32 -32
  238. package/dist/esm/groupview/groupPanel.js +1 -1
  239. package/dist/esm/groupview/groupview.d.ts +177 -177
  240. package/dist/esm/groupview/groupview.js +444 -444
  241. package/dist/esm/groupview/groupviewPanel.d.ts +35 -35
  242. package/dist/esm/groupview/groupviewPanel.js +61 -61
  243. package/dist/esm/groupview/panel/content.d.ts +30 -30
  244. package/dist/esm/groupview/panel/content.js +73 -73
  245. package/dist/esm/groupview/tab.d.ts +41 -41
  246. package/dist/esm/groupview/tab.js +90 -90
  247. package/dist/esm/groupview/titlebar/tabsContainer.d.ts +68 -68
  248. package/dist/esm/groupview/titlebar/tabsContainer.js +190 -190
  249. package/dist/esm/groupview/types.d.ts +52 -52
  250. package/dist/esm/groupview/types.js +1 -1
  251. package/dist/esm/hostedContainer.d.ts +23 -23
  252. package/dist/esm/hostedContainer.js +63 -63
  253. package/dist/esm/index.d.ts +30 -30
  254. package/dist/esm/index.js +23 -23
  255. package/dist/esm/lifecycle.d.ts +22 -22
  256. package/dist/esm/lifecycle.js +39 -39
  257. package/dist/esm/math.d.ts +4 -4
  258. package/dist/esm/math.js +10 -10
  259. package/dist/esm/panel/componentFactory.d.ts +8 -8
  260. package/dist/esm/panel/componentFactory.js +24 -24
  261. package/dist/esm/panel/types.d.ts +33 -33
  262. package/dist/esm/panel/types.js +1 -1
  263. package/dist/esm/paneview/defaultPaneviewHeader.d.ts +21 -21
  264. package/dist/esm/paneview/defaultPaneviewHeader.js +63 -63
  265. package/dist/esm/paneview/draggablePaneviewPanel.d.ts +19 -19
  266. package/dist/esm/paneview/draggablePaneviewPanel.js +90 -90
  267. package/dist/esm/paneview/options.d.ts +27 -27
  268. package/dist/esm/paneview/options.js +1 -1
  269. package/dist/esm/paneview/paneview.d.ts +40 -40
  270. package/dist/esm/paneview/paneview.js +145 -145
  271. package/dist/esm/paneview/paneviewComponent.d.ts +129 -129
  272. package/dist/esm/paneview/paneviewComponent.js +270 -270
  273. package/dist/esm/paneview/paneviewPanel.d.ts +92 -89
  274. package/dist/esm/paneview/paneviewPanel.js +191 -191
  275. package/dist/esm/react/deserializer.d.ts +9 -9
  276. package/dist/esm/react/deserializer.js +38 -38
  277. package/dist/esm/react/dockview/defaultTab.d.ts +4 -4
  278. package/dist/esm/react/dockview/defaultTab.js +34 -34
  279. package/dist/esm/react/dockview/dockview.d.ts +34 -34
  280. package/dist/esm/react/dockview/dockview.js +157 -157
  281. package/dist/esm/react/dockview/groupControlsRenderer.d.ts +43 -43
  282. package/dist/esm/react/dockview/groupControlsRenderer.js +68 -68
  283. package/dist/esm/react/dockview/reactContentPart.d.ts +30 -30
  284. package/dist/esm/react/dockview/reactContentPart.js +49 -49
  285. package/dist/esm/react/dockview/reactHeaderPart.d.ts +26 -26
  286. package/dist/esm/react/dockview/reactHeaderPart.js +46 -46
  287. package/dist/esm/react/dockview/reactWatermarkPart.d.ts +29 -29
  288. package/dist/esm/react/dockview/reactWatermarkPart.js +55 -55
  289. package/dist/esm/react/dockview/v2/reactContentRenderer.d.ts +29 -29
  290. package/dist/esm/react/dockview/v2/reactContentRenderer.js +69 -69
  291. package/dist/esm/react/dockview/v2/reactGroupPanelView.d.ts +7 -7
  292. package/dist/esm/react/dockview/v2/reactGroupPanelView.js +12 -12
  293. package/dist/esm/react/dockview/v2/webviewContentRenderer.d.ts +18 -18
  294. package/dist/esm/react/dockview/v2/webviewContentRenderer.js +36 -36
  295. package/dist/esm/react/gridview/gridview.d.ts +24 -24
  296. package/dist/esm/react/gridview/gridview.js +70 -70
  297. package/dist/esm/react/gridview/view.d.ts +11 -11
  298. package/dist/esm/react/gridview/view.js +18 -18
  299. package/dist/esm/react/index.d.ts +9 -9
  300. package/dist/esm/react/index.js +7 -7
  301. package/dist/esm/react/paneview/paneview.d.ts +30 -30
  302. package/dist/esm/react/paneview/paneview.js +100 -100
  303. package/dist/esm/react/paneview/view.d.ts +20 -20
  304. package/dist/esm/react/paneview/view.js +35 -35
  305. package/dist/esm/react/react.d.ts +36 -36
  306. package/dist/esm/react/react.js +125 -125
  307. package/dist/esm/react/splitview/splitview.d.ts +24 -24
  308. package/dist/esm/react/splitview/splitview.js +66 -66
  309. package/dist/esm/react/splitview/view.d.ts +10 -10
  310. package/dist/esm/react/splitview/view.js +18 -18
  311. package/dist/esm/react/svg.d.ts +3 -3
  312. package/dist/esm/react/svg.js +7 -7
  313. package/dist/esm/react/types.d.ts +7 -7
  314. package/dist/esm/react/types.js +1 -1
  315. package/dist/esm/splitview/core/options.d.ts +26 -26
  316. package/dist/esm/splitview/core/options.js +1 -1
  317. package/dist/esm/splitview/core/splitview.d.ts +127 -124
  318. package/dist/esm/splitview/core/splitview.js +689 -689
  319. package/dist/esm/splitview/core/viewItem.d.ts +25 -25
  320. package/dist/esm/splitview/core/viewItem.js +79 -79
  321. package/dist/esm/splitview/splitviewComponent.d.ts +101 -101
  322. package/dist/esm/splitview/splitviewComponent.js +249 -249
  323. package/dist/esm/splitview/splitviewPanel.d.ts +45 -42
  324. package/dist/esm/splitview/splitviewPanel.js +107 -107
  325. package/dist/esm/svg.d.ts +3 -3
  326. package/dist/esm/svg.js +31 -31
  327. package/dist/esm/types.d.ts +7 -7
  328. package/dist/esm/types.js +1 -1
  329. package/package.json +2 -2
@@ -1,615 +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 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;
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;
615
615
  //# sourceMappingURL=dockviewComponent.js.map