dockview-core 7.0.4 → 8.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (380) hide show
  1. package/LICENCE.md +21 -0
  2. package/README.md +17 -86
  3. package/dist/cjs/api/component.api.d.ts +100 -9
  4. package/dist/cjs/api/dockviewGroupPanelApi.d.ts +45 -1
  5. package/dist/cjs/api/dockviewPanelApi.d.ts +21 -0
  6. package/dist/cjs/dismissableLayer.d.ts +57 -0
  7. package/dist/cjs/dnd/backend.d.ts +2 -2
  8. package/dist/cjs/dnd/dataTransfer.d.ts +1 -0
  9. package/dist/cjs/dnd/dropTargetAnchorContainer.d.ts +12 -0
  10. package/dist/cjs/dnd/droptarget.d.ts +94 -0
  11. package/dist/cjs/dnd/ghost.d.ts +1 -0
  12. package/dist/cjs/dnd/pointer/longPress.d.ts +2 -2
  13. package/dist/cjs/dnd/pointer/pointerDragController.d.ts +5 -2
  14. package/dist/cjs/dnd/pointer/pointerDragSource.d.ts +1 -1
  15. package/dist/cjs/dnd/pointer/pointerDropTarget.d.ts +30 -1
  16. package/dist/cjs/dnd/pointer/pointerGhost.d.ts +1 -1
  17. package/dist/cjs/dockview/accessibilityMessages.d.ts +6 -0
  18. package/dist/cjs/dockview/advancedDnDService.d.ts +31 -0
  19. package/dist/cjs/dockview/components/panel/content.d.ts +1 -1
  20. package/dist/cjs/dockview/components/tab/defaultTab.d.ts +2 -0
  21. package/dist/cjs/dockview/components/tab/tab.d.ts +2 -0
  22. package/dist/cjs/dockview/components/titlebar/floatingTitleBar.d.ts +2 -2
  23. package/dist/cjs/dockview/components/titlebar/groupDragSource.d.ts +1 -1
  24. package/dist/cjs/dockview/components/titlebar/tabGroupChip.d.ts +1 -1
  25. package/dist/cjs/dockview/components/titlebar/tabGroupIndicator.d.ts +73 -2
  26. package/dist/cjs/dockview/components/titlebar/tabGroups.d.ts +1 -1
  27. package/dist/cjs/dockview/components/titlebar/tabReorderController.d.ts +295 -0
  28. package/dist/cjs/dockview/components/titlebar/tabs.d.ts +120 -50
  29. package/dist/cjs/dockview/components/titlebar/tabsContainer.d.ts +48 -0
  30. package/dist/cjs/dockview/dndCapabilities.d.ts +1 -1
  31. package/dist/cjs/dockview/dockviewComponent.d.ts +307 -19
  32. package/dist/cjs/dockview/dockviewGroupPanel.d.ts +5 -0
  33. package/dist/cjs/dockview/dockviewGroupPanelModel.d.ts +76 -2
  34. package/dist/cjs/dockview/dockviewPanel.d.ts +12 -0
  35. package/dist/cjs/dockview/dockviewShell.d.ts +48 -24
  36. package/dist/cjs/dockview/edgeGroupService.d.ts +20 -0
  37. package/dist/cjs/dockview/events.d.ts +6 -0
  38. package/dist/cjs/dockview/liveRegionService.d.ts +18 -5
  39. package/dist/cjs/dockview/moduleContracts.d.ts +485 -14
  40. package/dist/cjs/dockview/modules.d.ts +101 -22
  41. package/dist/cjs/dockview/options.d.ts +336 -30
  42. package/dist/cjs/dockview/optionsModules.d.ts +73 -0
  43. package/dist/cjs/dockview/popoutWindowService.d.ts +15 -10
  44. package/dist/cjs/dockview/rootDropTargetService.d.ts +11 -0
  45. package/dist/cjs/dockview/tabGroup.d.ts +3 -0
  46. package/dist/cjs/dockview/tabGroupAccent.d.ts +1 -1
  47. package/dist/cjs/dockview/tabGroupChipsService.d.ts +10 -0
  48. package/dist/cjs/dockview/theme.d.ts +2 -2
  49. package/dist/cjs/dockview/types.d.ts +3 -0
  50. package/dist/cjs/dom.d.ts +9 -1
  51. package/dist/cjs/events.d.ts +1 -1
  52. package/dist/cjs/gridview/baseComponentGridview.d.ts +2 -2
  53. package/dist/cjs/gridview/branchNode.d.ts +16 -0
  54. package/dist/cjs/gridview/gridview.d.ts +2 -0
  55. package/dist/cjs/index.d.ts +35 -29
  56. package/dist/cjs/lifecycle.d.ts +1 -0
  57. package/dist/cjs/overlay/overlay.d.ts +4 -2
  58. package/dist/cjs/overlay/overlayRenderContainer.d.ts +8 -0
  59. package/dist/cjs/paneview/paneview.d.ts +2 -1
  60. package/dist/cjs/paneview/paneviewComponent.d.ts +3 -0
  61. package/dist/cjs/paneview/paneviewPanel.d.ts +5 -0
  62. package/dist/cjs/scrollbar.d.ts +10 -0
  63. package/dist/cjs/splitview/viewItem.d.ts +10 -0
  64. package/dist/cjs/svg.d.ts +1 -0
  65. package/dist/cjs/types.d.ts +8 -0
  66. package/dist/dockview-core.js +18513 -19679
  67. package/dist/dockview-core.min.js +4138 -6
  68. package/dist/dockview-core.min.noStyle.js +6 -7
  69. package/dist/dockview-core.noStyle.js +18512 -19656
  70. package/dist/package/main.cjs.js +18123 -19267
  71. package/dist/package/main.cjs.min.js +6 -6
  72. package/dist/package/main.esm.min.mjs +6 -6
  73. package/dist/package/main.esm.mjs +18081 -19260
  74. package/package.json +81 -77
  75. package/dist/cjs/api/component.api.js +0 -1242
  76. package/dist/cjs/api/dockviewGroupPanelApi.js +0 -200
  77. package/dist/cjs/api/dockviewPanelApi.js +0 -172
  78. package/dist/cjs/api/entryPoints.js +0 -27
  79. package/dist/cjs/api/gridviewPanelApi.js +0 -45
  80. package/dist/cjs/api/panelApi.js +0 -133
  81. package/dist/cjs/api/paneviewPanelApi.js +0 -57
  82. package/dist/cjs/api/splitviewPanelApi.js +0 -47
  83. package/dist/cjs/array.js +0 -66
  84. package/dist/cjs/constants.js +0 -11
  85. package/dist/cjs/dnd/backend.js +0 -171
  86. package/dist/cjs/dnd/dataTransfer.js +0 -100
  87. package/dist/cjs/dnd/dnd.js +0 -74
  88. package/dist/cjs/dnd/dropOverlay.js +0 -197
  89. package/dist/cjs/dnd/dropTargetAnchorContainer.js +0 -104
  90. package/dist/cjs/dnd/droptarget.js +0 -362
  91. package/dist/cjs/dnd/ghost.js +0 -17
  92. package/dist/cjs/dnd/pointer/index.js +0 -13
  93. package/dist/cjs/dnd/pointer/longPress.js +0 -151
  94. package/dist/cjs/dnd/pointer/pointerDragController.js +0 -243
  95. package/dist/cjs/dnd/pointer/pointerDragSource.js +0 -197
  96. package/dist/cjs/dnd/pointer/pointerDropTarget.js +0 -198
  97. package/dist/cjs/dnd/pointer/pointerGhost.js +0 -44
  98. package/dist/cjs/dnd/pointer/types.js +0 -2
  99. package/dist/cjs/dockview/accessibilityMessages.js +0 -51
  100. package/dist/cjs/dockview/allModules.js +0 -25
  101. package/dist/cjs/dockview/components/panel/content.js +0 -213
  102. package/dist/cjs/dockview/components/popupService.js +0 -132
  103. package/dist/cjs/dockview/components/tab/defaultTab.js +0 -70
  104. package/dist/cjs/dockview/components/tab/tab.js +0 -281
  105. package/dist/cjs/dockview/components/titlebar/floatingTitleBar.js +0 -95
  106. package/dist/cjs/dockview/components/titlebar/groupDragSource.js +0 -218
  107. package/dist/cjs/dockview/components/titlebar/tabGroupChip.js +0 -104
  108. package/dist/cjs/dockview/components/titlebar/tabGroupIndicator.js +0 -477
  109. package/dist/cjs/dockview/components/titlebar/tabGroups.js +0 -854
  110. package/dist/cjs/dockview/components/titlebar/tabOverflowControl.js +0 -19
  111. package/dist/cjs/dockview/components/titlebar/tabs.js +0 -2016
  112. package/dist/cjs/dockview/components/titlebar/tabsContainer.js +0 -458
  113. package/dist/cjs/dockview/components/titlebar/voidContainer.js +0 -120
  114. package/dist/cjs/dockview/components/watermark/watermark.js +0 -40
  115. package/dist/cjs/dockview/deserializer.js +0 -39
  116. package/dist/cjs/dockview/dndCapabilities.js +0 -39
  117. package/dist/cjs/dockview/dockviewComponent.js +0 -3896
  118. package/dist/cjs/dockview/dockviewFloatingGroupPanel.js +0 -70
  119. package/dist/cjs/dockview/dockviewGroupPanel.js +0 -204
  120. package/dist/cjs/dockview/dockviewGroupPanelModel.js +0 -1514
  121. package/dist/cjs/dockview/dockviewPanel.js +0 -265
  122. package/dist/cjs/dockview/dockviewPanelModel.js +0 -105
  123. package/dist/cjs/dockview/dockviewShell.js +0 -744
  124. package/dist/cjs/dockview/edgeGroupService.js +0 -128
  125. package/dist/cjs/dockview/events.js +0 -67
  126. package/dist/cjs/dockview/floatingGroupService.js +0 -231
  127. package/dist/cjs/dockview/framework.js +0 -2
  128. package/dist/cjs/dockview/headerActionsService.js +0 -149
  129. package/dist/cjs/dockview/liveRegionService.js +0 -185
  130. package/dist/cjs/dockview/moduleContracts.js +0 -2
  131. package/dist/cjs/dockview/modules.js +0 -304
  132. package/dist/cjs/dockview/options.js +0 -103
  133. package/dist/cjs/dockview/popoutWindowService.js +0 -261
  134. package/dist/cjs/dockview/rootDropTargetService.js +0 -87
  135. package/dist/cjs/dockview/strictEventsSequencing.js +0 -63
  136. package/dist/cjs/dockview/tabGroup.js +0 -219
  137. package/dist/cjs/dockview/tabGroupAccent.js +0 -126
  138. package/dist/cjs/dockview/theme.js +0 -139
  139. package/dist/cjs/dockview/types.js +0 -2
  140. package/dist/cjs/dockview/validate.js +0 -76
  141. package/dist/cjs/dockview/watermarkService.js +0 -61
  142. package/dist/cjs/dom.js +0 -543
  143. package/dist/cjs/events.js +0 -296
  144. package/dist/cjs/framwork.js +0 -2
  145. package/dist/cjs/gridview/baseComponentGridview.js +0 -330
  146. package/dist/cjs/gridview/basePanelView.js +0 -162
  147. package/dist/cjs/gridview/branchNode.js +0 -372
  148. package/dist/cjs/gridview/gridview.js +0 -776
  149. package/dist/cjs/gridview/gridviewComponent.js +0 -363
  150. package/dist/cjs/gridview/gridviewPanel.js +0 -249
  151. package/dist/cjs/gridview/leafNode.js +0 -169
  152. package/dist/cjs/gridview/options.js +0 -17
  153. package/dist/cjs/gridview/types.js +0 -2
  154. package/dist/cjs/index.js +0 -105
  155. package/dist/cjs/lifecycle.js +0 -80
  156. package/dist/cjs/math.js +0 -38
  157. package/dist/cjs/overlay/overlay.js +0 -602
  158. package/dist/cjs/overlay/overlayRenderContainer.js +0 -309
  159. package/dist/cjs/panel/types.js +0 -2
  160. package/dist/cjs/paneview/defaultPaneviewHeader.js +0 -92
  161. package/dist/cjs/paneview/draggablePaneviewPanel.js +0 -141
  162. package/dist/cjs/paneview/options.js +0 -44
  163. package/dist/cjs/paneview/paneview.js +0 -203
  164. package/dist/cjs/paneview/paneviewComponent.js +0 -430
  165. package/dist/cjs/paneview/paneviewPanel.js +0 -275
  166. package/dist/cjs/popoutWindow.js +0 -244
  167. package/dist/cjs/resizable.js +0 -97
  168. package/dist/cjs/scrollbar.js +0 -169
  169. package/dist/cjs/splitview/options.js +0 -19
  170. package/dist/cjs/splitview/splitview.js +0 -999
  171. package/dist/cjs/splitview/splitviewComponent.js +0 -401
  172. package/dist/cjs/splitview/splitviewPanel.js +0 -179
  173. package/dist/cjs/splitview/viewItem.js +0 -119
  174. package/dist/cjs/svg.js +0 -43
  175. package/dist/cjs/types.js +0 -2
  176. package/dist/dockview-core.min.js.map +0 -1
  177. package/dist/dockview-core.min.noStyle.js.map +0 -1
  178. package/dist/esm/api/component.api.d.ts +0 -640
  179. package/dist/esm/api/component.api.js +0 -887
  180. package/dist/esm/api/dockviewGroupPanelApi.d.ts +0 -109
  181. package/dist/esm/api/dockviewGroupPanelApi.js +0 -155
  182. package/dist/esm/api/dockviewPanelApi.d.ts +0 -84
  183. package/dist/esm/api/dockviewPanelApi.js +0 -124
  184. package/dist/esm/api/entryPoints.d.ts +0 -9
  185. package/dist/esm/api/entryPoints.js +0 -21
  186. package/dist/esm/api/gridviewPanelApi.d.ts +0 -37
  187. package/dist/esm/api/gridviewPanelApi.js +0 -23
  188. package/dist/esm/api/panelApi.d.ts +0 -100
  189. package/dist/esm/api/panelApi.js +0 -87
  190. package/dist/esm/api/paneviewPanelApi.d.ts +0 -26
  191. package/dist/esm/api/paneviewPanelApi.js +0 -27
  192. package/dist/esm/api/splitviewPanelApi.d.ts +0 -32
  193. package/dist/esm/api/splitviewPanelApi.js +0 -25
  194. package/dist/esm/array.d.ts +0 -13
  195. package/dist/esm/array.js +0 -57
  196. package/dist/esm/constants.d.ts +0 -8
  197. package/dist/esm/constants.js +0 -8
  198. package/dist/esm/dnd/backend.d.ts +0 -70
  199. package/dist/esm/dnd/backend.js +0 -148
  200. package/dist/esm/dnd/dataTransfer.d.ts +0 -31
  201. package/dist/esm/dnd/dataTransfer.js +0 -67
  202. package/dist/esm/dnd/dnd.d.ts +0 -32
  203. package/dist/esm/dnd/dnd.js +0 -51
  204. package/dist/esm/dnd/dropOverlay.d.ts +0 -20
  205. package/dist/esm/dnd/dropOverlay.js +0 -192
  206. package/dist/esm/dnd/dropTargetAnchorContainer.d.ts +0 -16
  207. package/dist/esm/dnd/dropTargetAnchorContainer.js +0 -73
  208. package/dist/esm/dnd/droptarget.d.ts +0 -116
  209. package/dist/esm/dnd/droptarget.js +0 -316
  210. package/dist/esm/dnd/ghost.d.ts +0 -4
  211. package/dist/esm/dnd/ghost.js +0 -14
  212. package/dist/esm/dnd/pointer/index.d.ts +0 -11
  213. package/dist/esm/dnd/pointer/index.js +0 -5
  214. package/dist/esm/dnd/pointer/longPress.d.ts +0 -32
  215. package/dist/esm/dnd/pointer/longPress.js +0 -127
  216. package/dist/esm/dnd/pointer/pointerDragController.d.ts +0 -60
  217. package/dist/esm/dnd/pointer/pointerDragController.js +0 -193
  218. package/dist/esm/dnd/pointer/pointerDragSource.d.ts +0 -61
  219. package/dist/esm/dnd/pointer/pointerDragSource.js +0 -173
  220. package/dist/esm/dnd/pointer/pointerDropTarget.d.ts +0 -39
  221. package/dist/esm/dnd/pointer/pointerDropTarget.js +0 -168
  222. package/dist/esm/dnd/pointer/pointerGhost.d.ts +0 -30
  223. package/dist/esm/dnd/pointer/pointerGhost.js +0 -39
  224. package/dist/esm/dnd/pointer/types.d.ts +0 -16
  225. package/dist/esm/dnd/pointer/types.js +0 -1
  226. package/dist/esm/dockview/accessibilityMessages.d.ts +0 -32
  227. package/dist/esm/dockview/accessibilityMessages.js +0 -30
  228. package/dist/esm/dockview/allModules.d.ts +0 -8
  229. package/dist/esm/dockview/allModules.js +0 -22
  230. package/dist/esm/dockview/components/panel/content.d.ts +0 -54
  231. package/dist/esm/dockview/components/panel/content.js +0 -185
  232. package/dist/esm/dockview/components/popupService.d.ts +0 -21
  233. package/dist/esm/dockview/components/popupService.js +0 -108
  234. package/dist/esm/dockview/components/tab/defaultTab.d.ts +0 -12
  235. package/dist/esm/dockview/components/tab/defaultTab.js +0 -43
  236. package/dist/esm/dockview/components/tab/tab.d.ts +0 -44
  237. package/dist/esm/dockview/components/tab/tab.js +0 -242
  238. package/dist/esm/dockview/components/titlebar/floatingTitleBar.d.ts +0 -34
  239. package/dist/esm/dockview/components/titlebar/floatingTitleBar.js +0 -65
  240. package/dist/esm/dockview/components/titlebar/groupDragSource.d.ts +0 -51
  241. package/dist/esm/dockview/components/titlebar/groupDragSource.js +0 -178
  242. package/dist/esm/dockview/components/titlebar/tabGroupChip.d.ts +0 -37
  243. package/dist/esm/dockview/components/titlebar/tabGroupChip.js +0 -77
  244. package/dist/esm/dockview/components/titlebar/tabGroupIndicator.d.ts +0 -72
  245. package/dist/esm/dockview/components/titlebar/tabGroupIndicator.js +0 -360
  246. package/dist/esm/dockview/components/titlebar/tabGroups.d.ts +0 -107
  247. package/dist/esm/dockview/components/titlebar/tabGroups.js +0 -621
  248. package/dist/esm/dockview/components/titlebar/tabOverflowControl.d.ts +0 -8
  249. package/dist/esm/dockview/components/titlebar/tabOverflowControl.js +0 -16
  250. package/dist/esm/dockview/components/titlebar/tabs.d.ts +0 -167
  251. package/dist/esm/dockview/components/titlebar/tabs.js +0 -1653
  252. package/dist/esm/dockview/components/titlebar/tabsContainer.d.ts +0 -104
  253. package/dist/esm/dockview/components/titlebar/tabsContainer.js +0 -359
  254. package/dist/esm/dockview/components/titlebar/voidContainer.d.ts +0 -21
  255. package/dist/esm/dockview/components/titlebar/voidContainer.js +0 -92
  256. package/dist/esm/dockview/components/watermark/watermark.d.ts +0 -8
  257. package/dist/esm/dockview/components/watermark/watermark.js +0 -14
  258. package/dist/esm/dockview/deserializer.d.ts +0 -12
  259. package/dist/esm/dockview/deserializer.js +0 -34
  260. package/dist/esm/dockview/dndCapabilities.d.ts +0 -19
  261. package/dist/esm/dockview/dndCapabilities.js +0 -36
  262. package/dist/esm/dockview/dockviewComponent.d.ts +0 -626
  263. package/dist/esm/dockview/dockviewComponent.js +0 -3214
  264. package/dist/esm/dockview/dockviewFloatingGroupPanel.d.ts +0 -45
  265. package/dist/esm/dockview/dockviewFloatingGroupPanel.js +0 -44
  266. package/dist/esm/dockview/dockviewGroupPanel.d.ts +0 -35
  267. package/dist/esm/dockview/dockviewGroupPanel.js +0 -142
  268. package/dist/esm/dockview/dockviewGroupPanelModel.d.ts +0 -358
  269. package/dist/esm/dockview/dockviewGroupPanelModel.js +0 -1180
  270. package/dist/esm/dockview/dockviewPanel.d.ts +0 -69
  271. package/dist/esm/dockview/dockviewPanel.js +0 -178
  272. package/dist/esm/dockview/dockviewPanelModel.d.ts +0 -37
  273. package/dist/esm/dockview/dockviewPanelModel.js +0 -81
  274. package/dist/esm/dockview/dockviewShell.d.ts +0 -150
  275. package/dist/esm/dockview/dockviewShell.js +0 -678
  276. package/dist/esm/dockview/edgeGroupService.d.ts +0 -38
  277. package/dist/esm/dockview/edgeGroupService.js +0 -63
  278. package/dist/esm/dockview/events.d.ts +0 -38
  279. package/dist/esm/dockview/events.js +0 -34
  280. package/dist/esm/dockview/floatingGroupService.d.ts +0 -37
  281. package/dist/esm/dockview/floatingGroupService.js +0 -150
  282. package/dist/esm/dockview/framework.d.ts +0 -65
  283. package/dist/esm/dockview/framework.js +0 -1
  284. package/dist/esm/dockview/headerActionsService.d.ts +0 -32
  285. package/dist/esm/dockview/headerActionsService.js +0 -86
  286. package/dist/esm/dockview/liveRegionService.d.ts +0 -53
  287. package/dist/esm/dockview/liveRegionService.js +0 -159
  288. package/dist/esm/dockview/moduleContracts.d.ts +0 -119
  289. package/dist/esm/dockview/moduleContracts.js +0 -1
  290. package/dist/esm/dockview/modules.d.ts +0 -110
  291. package/dist/esm/dockview/modules.js +0 -170
  292. package/dist/esm/dockview/options.d.ts +0 -474
  293. package/dist/esm/dockview/options.js +0 -77
  294. package/dist/esm/dockview/popoutWindowService.d.ts +0 -95
  295. package/dist/esm/dockview/popoutWindowService.js +0 -175
  296. package/dist/esm/dockview/rootDropTargetService.d.ts +0 -35
  297. package/dist/esm/dockview/rootDropTargetService.js +0 -82
  298. package/dist/esm/dockview/strictEventsSequencing.d.ts +0 -7
  299. package/dist/esm/dockview/strictEventsSequencing.js +0 -41
  300. package/dist/esm/dockview/tabGroup.d.ts +0 -99
  301. package/dist/esm/dockview/tabGroup.js +0 -144
  302. package/dist/esm/dockview/tabGroupAccent.d.ts +0 -65
  303. package/dist/esm/dockview/tabGroupAccent.js +0 -114
  304. package/dist/esm/dockview/theme.d.ts +0 -86
  305. package/dist/esm/dockview/theme.js +0 -136
  306. package/dist/esm/dockview/types.d.ts +0 -53
  307. package/dist/esm/dockview/types.js +0 -1
  308. package/dist/esm/dockview/validate.d.ts +0 -0
  309. package/dist/esm/dockview/validate.js +0 -76
  310. package/dist/esm/dockview/watermarkService.d.ts +0 -30
  311. package/dist/esm/dockview/watermarkService.js +0 -56
  312. package/dist/esm/dom.d.ts +0 -60
  313. package/dist/esm/dom.js +0 -375
  314. package/dist/esm/events.d.ts +0 -79
  315. package/dist/esm/events.js +0 -219
  316. package/dist/esm/framwork.d.ts +0 -4
  317. package/dist/esm/framwork.js +0 -1
  318. package/dist/esm/gridview/baseComponentGridview.d.ts +0 -111
  319. package/dist/esm/gridview/baseComponentGridview.js +0 -237
  320. package/dist/esm/gridview/basePanelView.d.ts +0 -40
  321. package/dist/esm/gridview/basePanelView.js +0 -91
  322. package/dist/esm/gridview/branchNode.d.ts +0 -57
  323. package/dist/esm/gridview/branchNode.js +0 -257
  324. package/dist/esm/gridview/gridview.d.ts +0 -158
  325. package/dist/esm/gridview/gridview.js +0 -681
  326. package/dist/esm/gridview/gridviewComponent.d.ts +0 -88
  327. package/dist/esm/gridview/gridviewComponent.js +0 -265
  328. package/dist/esm/gridview/gridviewPanel.d.ts +0 -77
  329. package/dist/esm/gridview/gridviewPanel.js +0 -182
  330. package/dist/esm/gridview/leafNode.d.ts +0 -34
  331. package/dist/esm/gridview/leafNode.js +0 -102
  332. package/dist/esm/gridview/options.d.ts +0 -15
  333. package/dist/esm/gridview/options.js +0 -14
  334. package/dist/esm/gridview/types.d.ts +0 -3
  335. package/dist/esm/gridview/types.js +0 -1
  336. package/dist/esm/index.d.ts +0 -58
  337. package/dist/esm/index.js +0 -44
  338. package/dist/esm/lifecycle.d.ts +0 -25
  339. package/dist/esm/lifecycle.js +0 -56
  340. package/dist/esm/math.d.ts +0 -5
  341. package/dist/esm/math.js +0 -32
  342. package/dist/esm/overlay/overlay.d.ts +0 -91
  343. package/dist/esm/overlay/overlay.js +0 -520
  344. package/dist/esm/overlay/overlayRenderContainer.d.ts +0 -24
  345. package/dist/esm/overlay/overlayRenderContainer.js +0 -249
  346. package/dist/esm/panel/types.d.ts +0 -33
  347. package/dist/esm/panel/types.js +0 -1
  348. package/dist/esm/paneview/defaultPaneviewHeader.d.ts +0 -21
  349. package/dist/esm/paneview/defaultPaneviewHeader.js +0 -65
  350. package/dist/esm/paneview/draggablePaneviewPanel.d.ts +0 -38
  351. package/dist/esm/paneview/draggablePaneviewPanel.js +0 -107
  352. package/dist/esm/paneview/options.d.ts +0 -30
  353. package/dist/esm/paneview/options.js +0 -22
  354. package/dist/esm/paneview/paneview.d.ts +0 -41
  355. package/dist/esm/paneview/paneview.js +0 -148
  356. package/dist/esm/paneview/paneviewComponent.d.ts +0 -133
  357. package/dist/esm/paneview/paneviewComponent.js +0 -306
  358. package/dist/esm/paneview/paneviewPanel.d.ts +0 -98
  359. package/dist/esm/paneview/paneviewPanel.js +0 -192
  360. package/dist/esm/popoutWindow.d.ts +0 -38
  361. package/dist/esm/popoutWindow.js +0 -170
  362. package/dist/esm/resizable.d.ts +0 -12
  363. package/dist/esm/resizable.js +0 -66
  364. package/dist/esm/scrollbar.d.ts +0 -15
  365. package/dist/esm/scrollbar.js +0 -139
  366. package/dist/esm/splitview/options.d.ts +0 -21
  367. package/dist/esm/splitview/options.js +0 -16
  368. package/dist/esm/splitview/splitview.d.ts +0 -145
  369. package/dist/esm/splitview/splitview.js +0 -770
  370. package/dist/esm/splitview/splitviewComponent.d.ts +0 -101
  371. package/dist/esm/splitview/splitviewComponent.js +0 -267
  372. package/dist/esm/splitview/splitviewPanel.d.ts +0 -45
  373. package/dist/esm/splitview/splitviewPanel.js +0 -108
  374. package/dist/esm/splitview/viewItem.d.ts +0 -25
  375. package/dist/esm/splitview/viewItem.js +0 -74
  376. package/dist/esm/svg.d.ts +0 -3
  377. package/dist/esm/svg.js +0 -31
  378. package/dist/esm/types.d.ts +0 -31
  379. package/dist/esm/types.js +0 -1
  380. package/dist/styles/dockview.css +0 -3436
@@ -1,3896 +0,0 @@
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 __read = (this && this.__read) || function (o, n) {
29
- var m = typeof Symbol === "function" && o[Symbol.iterator];
30
- if (!m) return o;
31
- var i = m.call(o), r, ar = [], e;
32
- try {
33
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
34
- }
35
- catch (error) { e = { error: error }; }
36
- finally {
37
- try {
38
- if (r && !r.done && (m = i["return"])) m.call(i);
39
- }
40
- finally { if (e) throw e.error; }
41
- }
42
- return ar;
43
- };
44
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
45
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
46
- if (ar || !(i in from)) {
47
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
48
- ar[i] = from[i];
49
- }
50
- }
51
- return to.concat(ar || Array.prototype.slice.call(from));
52
- };
53
- var __values = (this && this.__values) || function(o) {
54
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
55
- if (m) return m.call(o);
56
- if (o && typeof o.length === "number") return {
57
- next: function () {
58
- if (o && i >= o.length) o = void 0;
59
- return { value: o && o[i++], done: !o };
60
- }
61
- };
62
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
63
- };
64
- Object.defineProperty(exports, "__esModule", { value: true });
65
- exports.DockviewComponent = void 0;
66
- var gridview_1 = require("../gridview/gridview");
67
- var droptarget_1 = require("../dnd/droptarget");
68
- var array_1 = require("../array");
69
- var dockviewPanel_1 = require("./dockviewPanel");
70
- var lifecycle_1 = require("../lifecycle");
71
- var events_1 = require("../events");
72
- var watermark_1 = require("./components/watermark/watermark");
73
- var math_1 = require("../math");
74
- var deserializer_1 = require("./deserializer");
75
- var options_1 = require("./options");
76
- var baseComponentGridview_1 = require("../gridview/baseComponentGridview");
77
- var component_api_1 = require("../api/component.api");
78
- var splitview_1 = require("../splitview/splitview");
79
- var dockviewGroupPanelModel_1 = require("./dockviewGroupPanelModel");
80
- var events_2 = require("./events");
81
- var dockviewGroupPanel_1 = require("./dockviewGroupPanel");
82
- var dockviewPanelModel_1 = require("./dockviewPanelModel");
83
- var dataTransfer_1 = require("../dnd/dataTransfer");
84
- var overlay_1 = require("../overlay/overlay");
85
- var dom_1 = require("../dom");
86
- var floatingTitleBar_1 = require("./components/titlebar/floatingTitleBar");
87
- var modules_1 = require("./modules");
88
- var allModules_1 = require("./allModules");
89
- var constants_1 = require("../constants");
90
- var overlayRenderContainer_1 = require("../overlay/overlayRenderContainer");
91
- var popoutWindow_1 = require("../popoutWindow");
92
- var strictEventsSequencing_1 = require("./strictEventsSequencing");
93
- var popupService_1 = require("./components/popupService");
94
- var dropTargetAnchorContainer_1 = require("../dnd/dropTargetAnchorContainer");
95
- var theme_1 = require("./theme");
96
- var dockviewShell_1 = require("./dockviewShell");
97
- var tabGroupAccent_1 = require("./tabGroupAccent");
98
- function buildTabGroupColorPalette(options) {
99
- var _a;
100
- var entries = (_a = options.tabGroupColors) !== null && _a !== void 0 ? _a : tabGroupAccent_1.DEFAULT_TAB_GROUP_COLORS;
101
- var enabled = options.tabGroupAccent !== 'off';
102
- return new tabGroupAccent_1.TabGroupColorPalette(entries, enabled);
103
- }
104
- function moveGroupWithoutDestroying(options) {
105
- var activePanel = options.from.activePanel;
106
- var panels = __spreadArray([], __read(options.from.panels), false).map(function (panel) {
107
- var removedPanel = options.from.model.removePanel(panel);
108
- options.from.model.renderContainer.detatch(panel);
109
- return removedPanel;
110
- });
111
- panels.forEach(function (panel) {
112
- options.to.model.openPanel(panel, {
113
- skipSetActive: activePanel !== panel,
114
- skipSetGroupActive: true,
115
- });
116
- });
117
- }
118
- var _hasWarnedUsingCoreDirectly = false;
119
- /**
120
- * `dockview-core` is an internal package. The public `dockview` package calls
121
- * `markDockviewPackageLoaded()` on import; if that marker is absent the consumer
122
- * is using `dockview-core` directly, so emit a one-time console warning
123
- * steering them to `dockview`.
124
- *
125
- * Suppressed in production builds: it is a development-time nudge and most
126
- * bundlers inline `process.env.NODE_ENV` so the branch is dropped entirely. The
127
- * `typeof process` guard keeps this safe in plain browser/UMD contexts where
128
- * `process` is undefined.
129
- */
130
- function warnIfUsingCoreDirectly() {
131
- var _a;
132
- if (typeof process !== 'undefined' &&
133
- ((_a = process.env) === null || _a === void 0 ? void 0 : _a.NODE_ENV) === 'production') {
134
- return;
135
- }
136
- if (_hasWarnedUsingCoreDirectly || (0, modules_1.isDockviewPackageLoaded)()) {
137
- return;
138
- }
139
- _hasWarnedUsingCoreDirectly = true;
140
- console.warn('dockview: do not use "dockview-core" directly — it is an internal ' +
141
- 'package. Use the "dockview" package, the JavaScript version of ' +
142
- 'dockview, instead. This notice is shown once.');
143
- }
144
- var DockviewComponent = /** @class */ (function (_super) {
145
- __extends(DockviewComponent, _super);
146
- function DockviewComponent(container, options) {
147
- var e_1, _a;
148
- var _b, _c, _d, _e, _f;
149
- var _this = _super.call(this, container, {
150
- proportionalLayout: true,
151
- orientation: splitview_1.Orientation.HORIZONTAL,
152
- styles: options.hideBorders
153
- ? { separatorBorder: 'transparent' }
154
- : undefined,
155
- disableAutoResizing: options.disableAutoResizing,
156
- locked: options.locked,
157
- margin: (_c = (_b = options.theme) === null || _b === void 0 ? void 0 : _b.gap) !== null && _c !== void 0 ? _c : 0,
158
- className: options.className,
159
- }) || this;
160
- _this.nextGroupId = (0, math_1.sequentialNumberGenerator)();
161
- _this._deserializer = new deserializer_1.DefaultDockviewDeserialzier(_this);
162
- _this._moduleRegistry = new modules_1.ModuleRegistry();
163
- _this._onWillDragPanel = new events_1.Emitter();
164
- _this.onWillDragPanel = _this._onWillDragPanel.event;
165
- _this._onWillDragGroup = new events_1.Emitter();
166
- _this.onWillDragGroup = _this._onWillDragGroup.event;
167
- _this._onDidDrop = new events_1.Emitter();
168
- _this.onDidDrop = _this._onDidDrop.event;
169
- _this._onWillDrop = new events_1.Emitter();
170
- _this.onWillDrop = _this._onWillDrop.event;
171
- // Transaction boundary bracketing each top-level structural mutation.
172
- // Compound operations (e.g. a drag that relocates a panel) nest via the
173
- // depth counter and bracket as a single transaction. See `mutation()`.
174
- _this._mutationDepth = 0;
175
- // Current operation origin. Defaults to `'user'`; the DockviewApi boundary
176
- // flips it to `'api'` for the duration of a programmatic call via
177
- // `withOrigin`. Nested operations inherit the outermost origin (tracked by
178
- // `_originDepth`, independent of mutation bracketing so it also covers
179
- // active-panel changes that are not structural mutations).
180
- _this._origin = 'user';
181
- _this._originDepth = 0;
182
- _this._onWillMutateLayout = new events_1.Emitter();
183
- _this.onWillMutateLayout = _this._onWillMutateLayout.event;
184
- _this._onDidMutateLayout = new events_1.Emitter();
185
- _this.onDidMutateLayout = _this._onDidMutateLayout.event;
186
- _this._onWillShowOverlay = new events_1.Emitter();
187
- _this.onWillShowOverlay = _this._onWillShowOverlay.event;
188
- _this._onUnhandledDragOver = new events_1.Emitter();
189
- _this.onUnhandledDragOver = _this._onUnhandledDragOver.event;
190
- _this._onDidRemovePanel = new events_1.Emitter();
191
- _this.onDidRemovePanel = _this._onDidRemovePanel.event;
192
- _this._onDidAddPanel = new events_1.Emitter();
193
- _this.onDidAddPanel = _this._onDidAddPanel.event;
194
- _this._onDidPopoutGroupSizeChange = new events_1.Emitter();
195
- _this.onDidPopoutGroupSizeChange = _this._onDidPopoutGroupSizeChange.event;
196
- _this._onDidPopoutGroupPositionChange = new events_1.Emitter();
197
- _this.onDidPopoutGroupPositionChange = _this._onDidPopoutGroupPositionChange.event;
198
- _this._onDidAddPopoutGroup = new events_1.Emitter();
199
- _this.onDidAddPopoutGroup = _this._onDidAddPopoutGroup.event;
200
- _this._onDidRemovePopoutGroup = new events_1.Emitter();
201
- _this.onDidRemovePopoutGroup = _this._onDidRemovePopoutGroup.event;
202
- _this._onDidOpenPopoutWindowFail = new events_1.Emitter();
203
- _this.onDidOpenPopoutWindowFail = _this._onDidOpenPopoutWindowFail.event;
204
- _this._onDidLayoutFromJSON = new events_1.Emitter();
205
- _this.onDidLayoutFromJSON = _this._onDidLayoutFromJSON.event;
206
- _this._onDidActivePanelChange = new events_1.Emitter({ replay: true });
207
- _this.onDidActivePanelChange = _this._onDidActivePanelChange.event;
208
- _this._onDidMovePanel = new events_1.Emitter();
209
- _this.onDidMovePanel = _this._onDidMovePanel.event;
210
- _this._onDidCreateTabGroup = new events_1.Emitter();
211
- _this.onDidCreateTabGroup = _this._onDidCreateTabGroup.event;
212
- _this._onDidDestroyTabGroup = new events_1.Emitter();
213
- _this.onDidDestroyTabGroup = _this._onDidDestroyTabGroup.event;
214
- _this._onDidAddPanelToTabGroup = new events_1.Emitter();
215
- _this.onDidAddPanelToTabGroup = _this._onDidAddPanelToTabGroup.event;
216
- _this._onDidRemovePanelFromTabGroup = new events_1.Emitter();
217
- _this.onDidRemovePanelFromTabGroup = _this._onDidRemovePanelFromTabGroup.event;
218
- _this._onDidTabGroupChange = new events_1.Emitter();
219
- _this.onDidTabGroupChange = _this._onDidTabGroupChange.event;
220
- _this._onDidTabGroupCollapsedChange = new events_1.Emitter();
221
- _this.onDidTabGroupCollapsedChange = _this._onDidTabGroupCollapsedChange.event;
222
- _this._onDidMaximizedGroupChange = new events_1.Emitter();
223
- _this.onDidMaximizedGroupChange = _this._onDidMaximizedGroupChange.event;
224
- _this._inShellLayout = false;
225
- _this._onDidRemoveGroup = new events_1.Emitter();
226
- _this.onDidRemoveGroup = _this._onDidRemoveGroup.event;
227
- _this._onDidAddGroup = new events_1.Emitter();
228
- _this.onDidAddGroup = _this._onDidAddGroup.event;
229
- _this._onDidOptionsChange = new events_1.Emitter();
230
- _this.onDidOptionsChange = _this._onDidOptionsChange.event;
231
- _this._onDidActiveGroupChange = new events_1.Emitter();
232
- _this.onDidActiveGroupChange = _this._onDidActiveGroupChange.event;
233
- _this._moving = false;
234
- _this._options = options;
235
- _this._tabGroupColorPalette = buildTabGroupColorPalette(options);
236
- // Internal seam: defaults to the full set, but tests can supply a
237
- // subset to assert every module is independently removable (and the
238
- // opt-in module API will build on this later). Not part of the public
239
- // options surface.
240
- var explicitModules = options
241
- .modules;
242
- var modules = explicitModules !== null && explicitModules !== void 0 ? explicitModules : __spreadArray(__spreadArray([], __read(allModules_1.AllModules), false), __read((0, modules_1.getRegisteredModules)()), false);
243
- try {
244
- for (var modules_2 = __values(modules), modules_2_1 = modules_2.next(); !modules_2_1.done; modules_2_1 = modules_2.next()) {
245
- var module_1 = modules_2_1.value;
246
- _this._moduleRegistry.register(module_1);
247
- }
248
- }
249
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
250
- finally {
251
- try {
252
- if (modules_2_1 && !modules_2_1.done && (_a = modules_2.return)) _a.call(modules_2);
253
- }
254
- finally { if (e_1) throw e_1.error; }
255
- }
256
- _this._moduleRegistry.initialize(_this);
257
- // Surface popout removal symmetrically with `onDidAddPopoutGroup`. The
258
- // service is the single point every removal path funnels through — a
259
- // genuine window close and an explicit removal alike — and it suppresses
260
- // the event during component teardown.
261
- var popoutWindowService = _this._popoutWindowService;
262
- if (popoutWindowService) {
263
- _this.addDisposables(popoutWindowService.onDidRemove(function (entry) {
264
- _this._onDidRemovePopoutGroup.fire({
265
- id: entry.popoutGroup.id,
266
- group: entry.popoutGroup,
267
- window: entry.getWindow(),
268
- });
269
- }));
270
- }
271
- // Purely a developer warning (no functional effect): nudge anyone using
272
- // the internal `dockview-core` package directly towards `dockview`.
273
- warnIfUsingCoreDirectly();
274
- _this.popupService = new popupService_1.PopupService(_this.element);
275
- _this._api = new component_api_1.DockviewApi(_this);
276
- // The shell always wraps the dockview element so edge groups can be
277
- // added at any time via addEdgeGroup() without re-parenting the DOM.
278
- _this.disableResizing = true;
279
- _this.element.remove();
280
- _this._shellManager = new dockviewShell_1.ShellManager(container, _this.element, function (w, h) { return _this._layoutFromShell(w, h); }, (_e = (_d = options.theme) === null || _d === void 0 ? void 0 : _d.gap) !== null && _e !== void 0 ? _e : 0, (_f = options.theme) === null || _f === void 0 ? void 0 : _f.edgeGroupCollapsedSize);
281
- // The shell wraps the dockview element, so move the popup anchor
282
- // into the shell so overflow dropdowns in edge groups position correctly
283
- _this.popupService.updateRoot(_this._shellManager.element);
284
- _this._shellThemeClassnames = new dom_1.Classnames(_this._shellManager.element);
285
- // Anchor the overlay container to the shell element so that edge groups
286
- // (which live outside this.element in the shell layout) are covered when
287
- // dndOverlayMounting is 'absolute'.
288
- _this.rootDropTargetContainer = new dropTargetAnchorContainer_1.DropTargetAnchorContainer(_this._shellManager.element, { disabled: true });
289
- _this.overlayRenderContainer = new overlayRenderContainer_1.OverlayRenderContainer(_this._shellManager.element, _this);
290
- // Hosted in the shell (not inside `.dv-dockview`) so floating overlays
291
- // share a stacking context with `dv-render-overlay` panels; sized to
292
- // mirror the gridview rect so saved positions remain valid.
293
- _this._floatingOverlayHost = document.createElement('div');
294
- _this._floatingOverlayHost.className = 'dv-floating-overlay-host';
295
- _this._shellManager.element.appendChild(_this._floatingOverlayHost);
296
- (0, dom_1.toggleClass)(_this.gridview.element, 'dv-dockview', true);
297
- (0, dom_1.toggleClass)(_this.element, 'dv-debug', !!options.debug);
298
- _this.updateTheme();
299
- if (options.debug) {
300
- _this.addDisposables(new strictEventsSequencing_1.StrictEventsSequencing(_this));
301
- }
302
- _this.addDisposables(_this.rootDropTargetContainer, _this.overlayRenderContainer, _this._onWillDragPanel, _this._onWillDragGroup, _this._onWillShowOverlay, _this._onDidActivePanelChange, _this._onDidAddPanel, _this._onDidRemovePanel, _this._onDidLayoutFromJSON, _this._onDidDrop, _this._onWillDrop, _this._onWillMutateLayout, _this._onDidMutateLayout, _this._onDidMovePanel, _this._onDidMovePanel.event(function () {
303
- /**
304
- * Update overlay positions after DOM layout completes to prevent 0×0 dimensions.
305
- * With defaultRenderer="always" this results in panel content not showing after move operations.
306
- * Debounced to avoid multiple calls when moving groups with multiple panels.
307
- */
308
- _this.debouncedUpdateAllPositions();
309
- }), _this._onDidAddGroup, _this._onDidRemoveGroup, _this._onDidActiveGroupChange, _this._onUnhandledDragOver, _this._onDidMaximizedGroupChange, _this._onDidPopoutGroupSizeChange, _this._onDidPopoutGroupPositionChange, _this._onDidAddPopoutGroup, _this._onDidRemovePopoutGroup, _this._onDidOpenPopoutWindowFail, _this._onDidCreateTabGroup, _this._onDidDestroyTabGroup, _this._onDidAddPanelToTabGroup, _this._onDidRemovePanelFromTabGroup, _this._onDidTabGroupChange, _this._onDidTabGroupCollapsedChange, events_1.Event.any(_this.onDidPopoutGroupSizeChange, _this.onDidPopoutGroupPositionChange, _this.onDidCreateTabGroup, _this.onDidDestroyTabGroup, _this.onDidAddPanelToTabGroup, _this.onDidRemovePanelFromTabGroup, _this.onDidTabGroupChange, _this.onDidTabGroupCollapsedChange)(function () {
310
- // Popout size/position and tab-group mutations persist as layout changes.
311
- _this.fireLayoutChange();
312
- }), _this._onDidOptionsChange, _this.onDidAdd(function (event) {
313
- if (!_this._moving) {
314
- _this._onDidAddGroup.fire(event);
315
- }
316
- }), _this.onDidRemove(function (event) {
317
- if (!_this._moving) {
318
- _this._onDidRemoveGroup.fire(event);
319
- }
320
- }), _this.onDidActiveChange(function (event) {
321
- if (!_this._moving) {
322
- _this._onDidActiveGroupChange.fire(event);
323
- }
324
- }), _this.onDidMaximizedChange(function (event) {
325
- _this._onDidMaximizedGroupChange.fire({
326
- group: event.panel,
327
- isMaximized: event.isMaximized,
328
- });
329
- }), events_1.Event.any(_this.onDidAddPanel, _this.onDidRemovePanel, _this.onDidAddGroup, _this.onDidRemove, _this.onDidRemoveGroup, _this.onDidMovePanel, _this.onDidActivePanelChange)(function () {
330
- _this._bufferOnDidLayoutChange.fire();
331
- }), lifecycle_1.Disposable.from(function () {
332
- var _a;
333
- // Registry disposes init() subscriptions then every module
334
- // service that implements IDisposable. The order matters so
335
- // init handlers stop firing into services about to be torn
336
- // down. Includes popout-restoration timer cancellation that
337
- // resolves promises so awaiters of popoutRestorationPromise
338
- // don't hang. See issue #851.
339
- _this._moduleRegistry.dispose();
340
- (_a = _this._shellManager) === null || _a === void 0 ? void 0 : _a.dispose();
341
- }));
342
- // Root edge-drop wiring lives with its (optional) module — guard it so
343
- // the module is independently removable.
344
- var rootDropTarget = _this._rootDropTargetService;
345
- if (rootDropTarget) {
346
- _this.addDisposables(rootDropTarget.onWillShowOverlay(function (event) {
347
- if (_this.gridview.length > 0 &&
348
- event.position === 'center') {
349
- // option only available when no panels in primary grid
350
- return;
351
- }
352
- _this._onWillShowOverlay.fire(new events_2.DockviewWillShowOverlayLocationEvent(event, {
353
- kind: 'edge',
354
- panel: undefined,
355
- api: _this._api,
356
- group: undefined,
357
- getData: dataTransfer_1.getPanelData,
358
- }));
359
- }), rootDropTarget.onDrop(function (event) {
360
- var _a;
361
- var willDropEvent = new dockviewGroupPanelModel_1.DockviewWillDropEvent({
362
- nativeEvent: event.nativeEvent,
363
- position: event.position,
364
- panel: undefined,
365
- api: _this._api,
366
- group: undefined,
367
- getData: dataTransfer_1.getPanelData,
368
- kind: 'edge',
369
- });
370
- _this._onWillDrop.fire(willDropEvent);
371
- if (willDropEvent.defaultPrevented) {
372
- return;
373
- }
374
- var data = (0, dataTransfer_1.getPanelData)();
375
- if (data) {
376
- _this.moveGroupOrPanel({
377
- from: {
378
- groupId: data.groupId,
379
- panelId: (_a = data.panelId) !== null && _a !== void 0 ? _a : undefined,
380
- },
381
- to: {
382
- group: _this.orthogonalize(event.position),
383
- position: 'center',
384
- },
385
- });
386
- }
387
- else {
388
- _this._onDidDrop.fire(new dockviewGroupPanelModel_1.DockviewDidDropEvent({
389
- nativeEvent: event.nativeEvent,
390
- position: event.position,
391
- panel: undefined,
392
- api: _this._api,
393
- group: undefined,
394
- getData: dataTransfer_1.getPanelData,
395
- }));
396
- }
397
- }));
398
- }
399
- // Final module wiring: runs after the host is fully constructed.
400
- // Modules subscribe to host events here so the component doesn't
401
- // need to manually invoke them at scattered call sites.
402
- _this._moduleRegistry.postConstruct(_this);
403
- return _this;
404
- }
405
- DockviewComponent.prototype.fireDidCreateTabGroup = function (event) {
406
- this._onDidCreateTabGroup.fire(event);
407
- };
408
- DockviewComponent.prototype.fireDidDestroyTabGroup = function (event) {
409
- this._onDidDestroyTabGroup.fire(event);
410
- };
411
- DockviewComponent.prototype.fireDidAddPanelToTabGroup = function (event) {
412
- this._onDidAddPanelToTabGroup.fire(event);
413
- };
414
- DockviewComponent.prototype.fireDidRemovePanelFromTabGroup = function (event) {
415
- this._onDidRemovePanelFromTabGroup.fire(event);
416
- };
417
- DockviewComponent.prototype.fireDidTabGroupChange = function (event) {
418
- this._onDidTabGroupChange.fire(event);
419
- };
420
- DockviewComponent.prototype.fireDidTabGroupCollapsedChange = function (event) {
421
- this._onDidTabGroupCollapsedChange.fire(event);
422
- };
423
- Object.defineProperty(DockviewComponent.prototype, "orientation", {
424
- get: function () {
425
- return this.gridview.orientation;
426
- },
427
- enumerable: false,
428
- configurable: true
429
- });
430
- Object.defineProperty(DockviewComponent.prototype, "totalPanels", {
431
- get: function () {
432
- return this.panels.length;
433
- },
434
- enumerable: false,
435
- configurable: true
436
- });
437
- Object.defineProperty(DockviewComponent.prototype, "panels", {
438
- get: function () {
439
- return this.groups.flatMap(function (group) { return group.panels; });
440
- },
441
- enumerable: false,
442
- configurable: true
443
- });
444
- Object.defineProperty(DockviewComponent.prototype, "options", {
445
- get: function () {
446
- return this._options;
447
- },
448
- enumerable: false,
449
- configurable: true
450
- });
451
- Object.defineProperty(DockviewComponent.prototype, "tabGroupColorPalette", {
452
- get: function () {
453
- return this._tabGroupColorPalette;
454
- },
455
- enumerable: false,
456
- configurable: true
457
- });
458
- Object.defineProperty(DockviewComponent.prototype, "activePanel", {
459
- get: function () {
460
- var activeGroup = this.activeGroup;
461
- if (!activeGroup) {
462
- return undefined;
463
- }
464
- return activeGroup.activePanel;
465
- },
466
- enumerable: false,
467
- configurable: true
468
- });
469
- Object.defineProperty(DockviewComponent.prototype, "renderer", {
470
- get: function () {
471
- var _a;
472
- return (_a = this.options.defaultRenderer) !== null && _a !== void 0 ? _a : 'onlyWhenVisible';
473
- },
474
- enumerable: false,
475
- configurable: true
476
- });
477
- Object.defineProperty(DockviewComponent.prototype, "defaultHeaderPosition", {
478
- get: function () {
479
- var _a;
480
- return (_a = this.options.defaultHeaderPosition) !== null && _a !== void 0 ? _a : 'top';
481
- },
482
- enumerable: false,
483
- configurable: true
484
- });
485
- Object.defineProperty(DockviewComponent.prototype, "api", {
486
- get: function () {
487
- return this._api;
488
- },
489
- enumerable: false,
490
- configurable: true
491
- });
492
- Object.defineProperty(DockviewComponent.prototype, "floatingGroups", {
493
- get: function () {
494
- var _a, _b, _c;
495
- return ((_c = (_b = (_a = this._moduleRegistry) === null || _a === void 0 ? void 0 : _a.services.floatingGroupService) === null || _b === void 0 ? void 0 : _b.floatingGroups) !== null && _c !== void 0 ? _c : []);
496
- },
497
- enumerable: false,
498
- configurable: true
499
- });
500
- /**
501
- * Boxes of the floating groups other than `exclude`, in coordinates
502
- * relative to the floating overlay container. Supplied to a
503
- * `transformFloatingGroupDrag` callback as `context.others` so it can
504
- * align the dragged float against its siblings.
505
- */
506
- DockviewComponent.prototype._gatherFloatingGroupBoxes = function (exclude) {
507
- var _a;
508
- var container = (_a = this._floatingOverlayHost) !== null && _a !== void 0 ? _a : this.gridview.element;
509
- var containerRect = container.getBoundingClientRect();
510
- return this.floatingGroups
511
- .filter(function (floating) { return floating.group !== exclude; })
512
- .map(function (floating) {
513
- var rect = floating.overlay.element.getBoundingClientRect();
514
- return {
515
- left: rect.left - containerRect.left,
516
- top: rect.top - containerRect.top,
517
- width: rect.width,
518
- height: rect.height,
519
- };
520
- });
521
- };
522
- Object.defineProperty(DockviewComponent.prototype, "_floatingGroupService", {
523
- get: function () {
524
- return this._moduleRegistry.services.floatingGroupService;
525
- },
526
- enumerable: false,
527
- configurable: true
528
- });
529
- Object.defineProperty(DockviewComponent.prototype, "_popoutWindowService", {
530
- get: function () {
531
- return this._moduleRegistry.services.popoutWindowService;
532
- },
533
- enumerable: false,
534
- configurable: true
535
- });
536
- Object.defineProperty(DockviewComponent.prototype, "_watermarkService", {
537
- get: function () {
538
- // Tier 1 module — optional. Callers must `?.`-guard so the module
539
- // can be removed from AllModules without crashing the component.
540
- return this._moduleRegistry.services.watermarkService;
541
- },
542
- enumerable: false,
543
- configurable: true
544
- });
545
- Object.defineProperty(DockviewComponent.prototype, "_edgeGroupService", {
546
- get: function () {
547
- return this._moduleRegistry.services.edgeGroupService;
548
- },
549
- enumerable: false,
550
- configurable: true
551
- });
552
- Object.defineProperty(DockviewComponent.prototype, "_rootDropTargetService", {
553
- get: function () {
554
- // Optional like every other module service — RootDropTargetModule can be
555
- // removed from the registered set without crashing the component.
556
- return this._moduleRegistry.services.rootDropTargetService;
557
- },
558
- enumerable: false,
559
- configurable: true
560
- });
561
- Object.defineProperty(DockviewComponent.prototype, "_advancedDnDService", {
562
- get: function () {
563
- // Optional — callers `?.`-guard so the module can be removed from
564
- // AllModules. Absent ⇒ the onWill* hooks simply don't fire (≡ no
565
- // subscriber), which is invisible to apps not customising DnD.
566
- return this._moduleRegistry.services.advancedDnDService;
567
- },
568
- enumerable: false,
569
- configurable: true
570
- });
571
- Object.defineProperty(DockviewComponent.prototype, "headerActionsService", {
572
- get: function () {
573
- return this._moduleRegistry.services.headerActionsService;
574
- },
575
- enumerable: false,
576
- configurable: true
577
- });
578
- DockviewComponent.prototype.isGridEmpty = function () {
579
- return this.gridview.length === 0;
580
- };
581
- DockviewComponent.prototype.rootDropTargetOverrideTarget = function () {
582
- var _a;
583
- return (_a = this.rootDropTargetContainer) === null || _a === void 0 ? void 0 : _a.model;
584
- };
585
- DockviewComponent.prototype.dispatchUnhandledDragOver = function (nativeEvent, position) {
586
- var event = new options_1.DockviewUnhandledDragOverEvent(nativeEvent, 'edge', position, dataTransfer_1.getPanelData);
587
- this._onUnhandledDragOver.fire(event);
588
- return event.isAccepted;
589
- };
590
- // IAdvancedDnDHost — the emitters stay here so the public onWill* event
591
- // shape is unchanged; AdvancedDnDService routes the per-group fires
592
- // through these. Engine guards (e.g. disableDnd) run on the component
593
- // ahead of the dispatch.
594
- DockviewComponent.prototype.fireWillDragPanel = function (event) {
595
- this._onWillDragPanel.fire(event);
596
- };
597
- DockviewComponent.prototype.fireWillDragGroup = function (event) {
598
- this._onWillDragGroup.fire(event);
599
- };
600
- DockviewComponent.prototype.fireWillDrop = function (event) {
601
- this._onWillDrop.fire(event);
602
- };
603
- DockviewComponent.prototype.fireWillShowOverlay = function (event) {
604
- this._onWillShowOverlay.fire(event);
605
- };
606
- /**
607
- * Resolve the custom group drag ghost (via the AdvancedDnD module), or
608
- * `undefined` to fall back to the default chip. Returns `undefined` when
609
- * the module is absent — the default ghost then renders.
610
- */
611
- DockviewComponent.prototype.buildGroupDragGhost = function (group) {
612
- var _a;
613
- return (_a = this._advancedDnDService) === null || _a === void 0 ? void 0 : _a.buildGroupDragGhost(group);
614
- };
615
- /**
616
- * Resolve the app-supplied drop overlay model (via the AdvancedDnD module)
617
- * for a group drop target, or `undefined` to keep the target's default.
618
- */
619
- DockviewComponent.prototype.resolveDropOverlayModel = function (location, group) {
620
- var _a;
621
- return (_a = this._advancedDnDService) === null || _a === void 0 ? void 0 : _a.resolveOverlayModel(location, group);
622
- };
623
- Object.defineProperty(DockviewComponent.prototype, "rootElement", {
624
- // IAccessibilityHost — keyboard docking reaches the AdvancedDnD preview +
625
- // LiveRegion announcer through these so the service stays decoupled.
626
- /** Outermost element — the shell (incl. edge groups) once built, else the gridview. */
627
- get: function () {
628
- var _a, _b;
629
- return (_b = (_a = this._shellManager) === null || _a === void 0 ? void 0 : _a.element) !== null && _b !== void 0 ? _b : this.element;
630
- },
631
- enumerable: false,
632
- configurable: true
633
- });
634
- /**
635
- * The next / previous group in gridview (spatial) order, wrapping round.
636
- * The keyboard accessibility module's focus navigation is built on this
637
- * primitive — the only piece that needs the grid internals; the rest of
638
- * the navigation logic lives in the AccessibilityService.
639
- */
640
- DockviewComponent.prototype.adjacentGroup = function (group, reverse) {
641
- var _a;
642
- // gridview traversal only covers grid groups; a floating/popout group
643
- // isn't in the grid, so there's no adjacent grid group to step to.
644
- if (group.api.location.type !== 'grid') {
645
- return undefined;
646
- }
647
- var location = (0, gridview_1.getGridLocation)(group.element);
648
- return ((_a = (reverse
649
- ? this.gridview.previous(location)
650
- : this.gridview.next(location))) === null || _a === void 0 ? void 0 : _a.view);
651
- };
652
- /**
653
- * The nearest grid group in a spatial direction from `group`, by
654
- * comparing group centre points. Floating and popout groups sit outside
655
- * the grid's geometry and are ignored. Returns `undefined` when there is
656
- * no group in that direction.
657
- */
658
- DockviewComponent.prototype.adjacentGroupInDirection = function (group, direction) {
659
- var e_2, _a;
660
- if (group.api.location.type !== 'grid') {
661
- return undefined;
662
- }
663
- var from = group.element.getBoundingClientRect();
664
- var fromX = from.left + from.width / 2;
665
- var fromY = from.top + from.height / 2;
666
- var best;
667
- var bestDistance = Number.POSITIVE_INFINITY;
668
- try {
669
- for (var _b = __values(this.groups), _c = _b.next(); !_c.done; _c = _b.next()) {
670
- var candidate = _c.value;
671
- if (candidate === group || candidate.api.location.type !== 'grid') {
672
- continue;
673
- }
674
- var rect = candidate.element.getBoundingClientRect();
675
- var dx = rect.left + rect.width / 2 - fromX;
676
- var dy = rect.top + rect.height / 2 - fromY;
677
- // Require the candidate to sit predominantly in the asked-for
678
- // direction (dominant axis), so 'left' ignores a group that's
679
- // mostly above/below.
680
- var inDirection = direction === 'left'
681
- ? dx < 0 && Math.abs(dx) >= Math.abs(dy)
682
- : direction === 'right'
683
- ? dx > 0 && Math.abs(dx) >= Math.abs(dy)
684
- : direction === 'up'
685
- ? dy < 0 && Math.abs(dy) >= Math.abs(dx)
686
- : dy > 0 && Math.abs(dy) >= Math.abs(dx);
687
- if (!inDirection) {
688
- continue;
689
- }
690
- var distance = dx * dx + dy * dy;
691
- if (distance < bestDistance) {
692
- bestDistance = distance;
693
- best = candidate;
694
- }
695
- }
696
- }
697
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
698
- finally {
699
- try {
700
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
701
- }
702
- finally { if (e_2) throw e_2.error; }
703
- }
704
- return best;
705
- };
706
- DockviewComponent.prototype.showDropPreview = function (group, position) {
707
- var _a, _b;
708
- return ((_b = (_a = this._advancedDnDService) === null || _a === void 0 ? void 0 : _a.showPreviewOverlay(group, position)) !== null && _b !== void 0 ? _b : lifecycle_1.Disposable.NONE);
709
- };
710
- DockviewComponent.prototype.announce = function (message) {
711
- var _a;
712
- (_a = this._moduleRegistry.services.liveRegionService) === null || _a === void 0 ? void 0 : _a.announce(message);
713
- };
714
- DockviewComponent.prototype.dockPanel = function (panel, group, position) {
715
- this.moveGroupOrPanel({
716
- from: { groupId: panel.group.id, panelId: panel.id },
717
- to: { group: group, position: position },
718
- });
719
- };
720
- Object.defineProperty(DockviewComponent.prototype, "contextMenuService", {
721
- get: function () {
722
- // Owned by ContextMenuModule — undefined when the module is not
723
- // registered, so callers must `?.`-guard.
724
- return this._moduleRegistry.services.contextMenuService;
725
- },
726
- enumerable: false,
727
- configurable: true
728
- });
729
- Object.defineProperty(DockviewComponent.prototype, "mountElement", {
730
- get: function () {
731
- return this.gridview.element;
732
- },
733
- enumerable: false,
734
- configurable: true
735
- });
736
- DockviewComponent.prototype.hasVisibleGridGroup = function () {
737
- return this.groups.some(function (group) { return group.api.location.type === 'grid' && group.api.isVisible; });
738
- };
739
- DockviewComponent.prototype.fireLayoutChange = function () {
740
- this._bufferOnDidLayoutChange.fire();
741
- };
742
- Object.defineProperty(DockviewComponent.prototype, "popoutRestorationPromise", {
743
- /**
744
- * Promise that resolves when all popout groups from the last fromJSON call are restored.
745
- * Useful for tests that need to wait for delayed popout creation.
746
- */
747
- get: function () {
748
- var _a, _b;
749
- return ((_b = (_a = this._popoutWindowService) === null || _a === void 0 ? void 0 : _a.restorationPromise) !== null && _b !== void 0 ? _b : Promise.resolve());
750
- },
751
- enumerable: false,
752
- configurable: true
753
- });
754
- DockviewComponent.prototype.setVisible = function (panel, visible) {
755
- switch (panel.api.location.type) {
756
- case 'grid':
757
- _super.prototype.setVisible.call(this, panel, visible);
758
- break;
759
- case 'floating': {
760
- var item = this.floatingGroups.find(function (floatingGroup) { return floatingGroup.group === panel; });
761
- if (item) {
762
- item.overlay.setVisible(visible);
763
- panel.api._onDidVisibilityChange.fire({
764
- isVisible: visible,
765
- });
766
- }
767
- break;
768
- }
769
- case 'popout':
770
- console.warn('dockview: You cannot hide a group that is in a popout window');
771
- break;
772
- case 'edge':
773
- // Edge group visibility is managed via setEdgeGroupVisible
774
- break;
775
- }
776
- };
777
- /**
778
- * Returns the {@link PopupService} that should host popovers (context
779
- * menus, tab overflow menus) for the given group. Popout groups have their
780
- * own service rooted in their popout window so the popover renders there
781
- * and dismisses on events from that window.
782
- */
783
- DockviewComponent.prototype.getPopupServiceForGroup = function (group) {
784
- var _a, _b;
785
- return ((_b = (_a = this._popoutWindowService) === null || _a === void 0 ? void 0 : _a.getPopupService(group.id)) !== null && _b !== void 0 ? _b : this.popupService);
786
- };
787
- DockviewComponent.prototype.addPopoutGroup = function (itemToPopout, options) {
788
- var _this = this;
789
- // The transaction brackets the synchronous structural change; the
790
- // popout window opens asynchronously after it resolves.
791
- return this.mutation('popout', function () {
792
- return _this._doAddPopoutGroup(itemToPopout, options);
793
- });
794
- };
795
- /** Enumerate the popout groups currently open in their own windows. */
796
- DockviewComponent.prototype.getPopouts = function () {
797
- var _a, _b;
798
- return ((_b = (_a = this._popoutWindowService) === null || _a === void 0 ? void 0 : _a.entries.map(function (entry) { return ({
799
- id: entry.popoutGroup.id,
800
- group: entry.popoutGroup,
801
- window: entry.getWindow(),
802
- }); })) !== null && _b !== void 0 ? _b : []);
803
- };
804
- DockviewComponent.prototype._doAddPopoutGroup = function (itemToPopout, options) {
805
- var _this = this;
806
- var _a, _b, _c, _d, _e;
807
- var service = (0, modules_1.assertModule)(this._popoutWindowService, 'PopoutWindow', 'api.addPopoutGroup');
808
- if (!service) {
809
- return Promise.resolve(false);
810
- }
811
- if (itemToPopout instanceof dockviewGroupPanel_1.DockviewGroupPanel &&
812
- itemToPopout.model.location.type === 'edge') {
813
- // edge groups are permanent structural elements and cannot be popped out
814
- return Promise.resolve(false);
815
- }
816
- if (itemToPopout instanceof dockviewPanel_1.DockviewPanel &&
817
- itemToPopout.group.size === 1) {
818
- return this.addPopoutGroup(itemToPopout.group, options);
819
- }
820
- var theme = (0, dom_1.getDockviewTheme)(this.gridview.element);
821
- var element = this.element;
822
- function getBox() {
823
- if (options === null || options === void 0 ? void 0 : options.position) {
824
- return options.position;
825
- }
826
- if (itemToPopout instanceof dockviewGroupPanel_1.DockviewGroupPanel) {
827
- return itemToPopout.element.getBoundingClientRect();
828
- }
829
- if (itemToPopout.group) {
830
- return itemToPopout.group.element.getBoundingClientRect();
831
- }
832
- return element.getBoundingClientRect();
833
- }
834
- var box = getBox();
835
- var groupId = (_b = (_a = options === null || options === void 0 ? void 0 : options.overridePopoutGroup) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : this.getNextGroupId();
836
- // Resolve the configured popout URL once (per-call override → global
837
- // option). Recorded on the entry / group locations so it survives
838
- // serialization; the '/popout.html' default is applied only when
839
- // actually opening the window, not baked into saved layouts.
840
- var resolvedPopoutUrl = (_c = options === null || options === void 0 ? void 0 : options.popoutUrl) !== null && _c !== void 0 ? _c : (_d = this.options) === null || _d === void 0 ? void 0 : _d.popoutUrl;
841
- var _window = new popoutWindow_1.PopoutWindow("".concat(this.id, "-").concat(groupId), // unique id
842
- theme !== null && theme !== void 0 ? theme : '', {
843
- url: resolvedPopoutUrl !== null && resolvedPopoutUrl !== void 0 ? resolvedPopoutUrl : '/popout.html',
844
- left: window.screenX + box.left,
845
- top: window.screenY + box.top,
846
- width: box.width,
847
- height: box.height,
848
- onDidOpen: options === null || options === void 0 ? void 0 : options.onDidOpen,
849
- onWillClose: options === null || options === void 0 ? void 0 : options.onWillClose,
850
- nonce: (_e = this.options) === null || _e === void 0 ? void 0 : _e.nonce,
851
- });
852
- var popoutWindowDisposable = new lifecycle_1.CompositeDisposable(_window, _window.onDidClose(function () {
853
- popoutWindowDisposable.dispose();
854
- }));
855
- return _window
856
- .open()
857
- .then(function (popoutContainer) {
858
- var e_3, _a;
859
- var _b, _c, _d, _e;
860
- if (_window.isDisposed) {
861
- return false;
862
- }
863
- var referenceGroup = (_b = options === null || options === void 0 ? void 0 : options.referenceGroup) !== null && _b !== void 0 ? _b : (itemToPopout instanceof dockviewPanel_1.DockviewPanel
864
- ? itemToPopout.group
865
- : itemToPopout);
866
- var referenceLocation = itemToPopout.api.location.type;
867
- /**
868
- * The group that is being added doesn't already exist within the DOM, the most likely occurrence
869
- * of this case is when being called from the `fromJSON(...)` method
870
- */
871
- var isGroupAddedToDom = referenceGroup.element.parentElement !== null;
872
- var group;
873
- if (options === null || options === void 0 ? void 0 : options.overridePopoutGridview) {
874
- // Restoring a multi-group window: the anchor group is
875
- // already built inside the supplied gridview.
876
- group = (_c = options.overridePopoutGroup) !== null && _c !== void 0 ? _c : referenceGroup;
877
- }
878
- else if (!isGroupAddedToDom) {
879
- group = referenceGroup;
880
- }
881
- else if (options === null || options === void 0 ? void 0 : options.overridePopoutGroup) {
882
- group = options.overridePopoutGroup;
883
- }
884
- else {
885
- group = _this.createGroup({ id: groupId });
886
- if (popoutContainer) {
887
- _this._onDidAddGroup.fire(group);
888
- }
889
- }
890
- if (popoutContainer === null) {
891
- _this.handleBlockedPopout({
892
- group: group,
893
- referenceGroup: referenceGroup,
894
- options: options,
895
- popoutWindowDisposable: popoutWindowDisposable,
896
- });
897
- return false;
898
- }
899
- var gready = document.createElement('div');
900
- gready.className = 'dv-overlay-render-container';
901
- var overlayRenderContainer = new overlayRenderContainer_1.OverlayRenderContainer(gready, _this);
902
- group.model.renderContainer = overlayRenderContainer;
903
- // The popout window hosts its own gridview so it can grow into
904
- // a nested splitview layout. The window starts with the single
905
- // anchor group; further groups arrive via drag-and-drop. On
906
- // restore a pre-populated gridview is supplied instead.
907
- var popoutGridview = (_d = options === null || options === void 0 ? void 0 : options.overridePopoutGridview) !== null && _d !== void 0 ? _d : _this.createNestedGridview();
908
- if (!(options === null || options === void 0 ? void 0 : options.overridePopoutGridview)) {
909
- popoutGridview.addView(group, splitview_1.Sizing.Distribute, [0]);
910
- }
911
- // Fill the popout window. Unlike the main grid (explicit px) and
912
- // floating windows (CSS inside .dv-resize-container), the popout
913
- // gridview has no sizing context, so without this it collapses
914
- // to 0 height and nothing renders.
915
- popoutGridview.element.style.width = '100%';
916
- popoutGridview.element.style.height = '100%';
917
- popoutGridview.layout(_window.window.innerWidth, _window.window.innerHeight);
918
- // Guarded so the teardown's re-entrant paths (window close
919
- // re-enters via the anchor's doRemoveGroup) never double-dispose.
920
- var popoutGridviewDisposed = false;
921
- var disposePopoutGridview = function () {
922
- if (!popoutGridviewDisposed) {
923
- popoutGridviewDisposed = true;
924
- popoutGridview.dispose();
925
- }
926
- };
927
- var floatingBox;
928
- if (!(options === null || options === void 0 ? void 0 : options.overridePopoutGroup) &&
929
- !(options === null || options === void 0 ? void 0 : options.overridePopoutGridview) &&
930
- isGroupAddedToDom) {
931
- if (itemToPopout instanceof dockviewPanel_1.DockviewPanel) {
932
- _this.movingLock(function () {
933
- var panel = referenceGroup.model.removePanel(itemToPopout);
934
- group.model.openPanel(panel);
935
- });
936
- }
937
- else {
938
- _this.movingLock(function () {
939
- return moveGroupWithoutDestroying({
940
- from: referenceGroup,
941
- to: group,
942
- });
943
- });
944
- switch (referenceLocation) {
945
- case 'grid':
946
- referenceGroup.api.setVisible(false);
947
- break;
948
- case 'floating':
949
- case 'popout':
950
- floatingBox = (_e = _this.floatingGroups
951
- .find(function (value) {
952
- return value.group.api.id ===
953
- itemToPopout.api.id;
954
- })) === null || _e === void 0 ? void 0 : _e.overlay.toJSON();
955
- _this.removeGroup(referenceGroup);
956
- break;
957
- }
958
- }
959
- }
960
- popoutContainer.classList.add('dv-dockview');
961
- popoutContainer.style.overflow = 'hidden';
962
- popoutContainer.appendChild(gready);
963
- popoutContainer.appendChild(popoutGridview.element);
964
- var anchor = document.createElement('div');
965
- var dropTargetContainer = new dropTargetAnchorContainer_1.DropTargetAnchorContainer(anchor, { disabled: _this.rootDropTargetContainer.disabled });
966
- popoutContainer.appendChild(anchor);
967
- group.model.dropTargetContainer = dropTargetContainer;
968
- // Each popout group needs its own popover service so that
969
- // tab context menus, chip menus, and tab overflow menus
970
- // render in the popout window (not the main window) and
971
- // their pointerdown/keydown listeners fire on the right
972
- // window for outside-click and Escape dismissal.
973
- var popoutPopupService = new popupService_1.PopupService(popoutContainer, _window.window);
974
- service.setPopupService(group.id, popoutPopupService);
975
- popoutWindowDisposable.addDisposables(popoutPopupService, lifecycle_1.Disposable.from(function () {
976
- service.deletePopupService(group.id);
977
- }));
978
- group.model.location = {
979
- type: 'popout',
980
- getWindow: function () { return _window.window; },
981
- popoutUrl: resolvedPopoutUrl,
982
- };
983
- if (options === null || options === void 0 ? void 0 : options.overridePopoutGridview) {
984
- // Restored multi-group window. Wire every member (including
985
- // the anchor) to this window's containers and popout
986
- // location now that the gridview is attached and laid out —
987
- // re-setting renderContainer forces a re-render at the right
988
- // time so 'always'-rendered content positions in this
989
- // window rather than where it was first created.
990
- var members = _this.groups.filter(function (candidate) {
991
- return popoutGridview.element.contains(candidate.element);
992
- });
993
- try {
994
- for (var members_1 = __values(members), members_1_1 = members_1.next(); !members_1_1.done; members_1_1 = members_1.next()) {
995
- var member = members_1_1.value;
996
- member.model.renderContainer = overlayRenderContainer;
997
- member.model.dropTargetContainer = dropTargetContainer;
998
- member.model.location = {
999
- type: 'popout',
1000
- getWindow: function () { return _window.window; },
1001
- popoutUrl: resolvedPopoutUrl,
1002
- };
1003
- }
1004
- }
1005
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
1006
- finally {
1007
- try {
1008
- if (members_1_1 && !members_1_1.done && (_a = members_1.return)) _a.call(members_1);
1009
- }
1010
- finally { if (e_3) throw e_3.error; }
1011
- }
1012
- }
1013
- if (isGroupAddedToDom &&
1014
- itemToPopout.api.location.type === 'grid') {
1015
- itemToPopout.api.setVisible(false);
1016
- }
1017
- _this.doSetGroupAndPanelActive(group);
1018
- var resizeObserverDisposable = service.observeGridviewSize(_window, popoutGridview, overlayRenderContainer);
1019
- if (resizeObserverDisposable) {
1020
- popoutWindowDisposable.addDisposables(resizeObserverDisposable);
1021
- }
1022
- popoutWindowDisposable.addDisposables(group.api.onDidActiveChange(function (event) {
1023
- var _a;
1024
- if (event.isActive) {
1025
- (_a = _window.window) === null || _a === void 0 ? void 0 : _a.focus();
1026
- }
1027
- }), group.api.onWillFocus(function () {
1028
- var _a;
1029
- (_a = _window.window) === null || _a === void 0 ? void 0 : _a.focus();
1030
- }));
1031
- // Holder so the close teardown (extracted below) can publish
1032
- // the group that was returned to the main grid back to the
1033
- // entry's `dispose()` contract.
1034
- var closeResult = {};
1035
- var isValidReferenceGroup = isGroupAddedToDom &&
1036
- referenceGroup &&
1037
- _this.getPanel(referenceGroup.id);
1038
- var value = {
1039
- window: _window,
1040
- popoutGroup: group,
1041
- gridview: popoutGridview,
1042
- overlayRenderContainer: overlayRenderContainer,
1043
- dropTargetContainer: dropTargetContainer,
1044
- getWindow: function () { return _window.window; },
1045
- popoutUrl: resolvedPopoutUrl,
1046
- referenceGroup: isValidReferenceGroup
1047
- ? referenceGroup.id
1048
- : undefined,
1049
- disposable: {
1050
- dispose: function () {
1051
- popoutWindowDisposable.dispose();
1052
- return closeResult.returnedGroup;
1053
- },
1054
- },
1055
- };
1056
- var _onDidWindowPositionChange = (0, dom_1.onDidWindowMoveEnd)(_window.window);
1057
- popoutWindowDisposable.addDisposables(_onDidWindowPositionChange, (0, dom_1.onDidWindowResizeEnd)(_window.window, function () {
1058
- _this._onDidPopoutGroupSizeChange.fire({
1059
- width: _window.window.innerWidth,
1060
- height: _window.window.innerHeight,
1061
- group: group,
1062
- });
1063
- }), _onDidWindowPositionChange.event(function () {
1064
- _this._onDidPopoutGroupPositionChange.fire({
1065
- screenX: _window.window.screenX,
1066
- screenY: _window.window.screenX,
1067
- group: group,
1068
- });
1069
- }), (0, events_1.addDisposableListener)(_window.window, 'resize', function () {
1070
- popoutGridview.layout(_window.window.innerWidth, _window.window.innerHeight);
1071
- }), overlayRenderContainer, lifecycle_1.Disposable.from(function () {
1072
- return _this.disposePopoutWindow({
1073
- group: group,
1074
- referenceGroup: referenceGroup,
1075
- popoutGridview: popoutGridview,
1076
- isGroupAddedToDom: isGroupAddedToDom,
1077
- floatingBox: floatingBox,
1078
- disposePopoutGridview: disposePopoutGridview,
1079
- closeResult: closeResult,
1080
- });
1081
- }));
1082
- service.add(value);
1083
- _this._onDidAddPopoutGroup.fire({
1084
- id: value.popoutGroup.id,
1085
- group: value.popoutGroup,
1086
- window: value.getWindow(),
1087
- });
1088
- return true;
1089
- })
1090
- .catch(function (err) {
1091
- console.error('dockview: failed to create popout.', err);
1092
- return false;
1093
- });
1094
- };
1095
- /**
1096
- * The popout window was blocked (e.g. by the browser's popup blocker —
1097
- * common when restoring popouts on load). Fall back gracefully so the
1098
- * group(s) end up valid and visible in the main grid rather than as
1099
- * orphans that later crash clear()/remove().
1100
- */
1101
- DockviewComponent.prototype.handleBlockedPopout = function (params) {
1102
- var e_4, _a;
1103
- var _this = this;
1104
- var group = params.group, referenceGroup = params.referenceGroup, options = params.options, popoutWindowDisposable = params.popoutWindowDisposable;
1105
- console.error('dockview: failed to create popout. perhaps you need to allow pop-ups for this website');
1106
- popoutWindowDisposable.dispose();
1107
- this._onDidOpenPopoutWindowFail.fire();
1108
- if (options === null || options === void 0 ? void 0 : options.overridePopoutGridview) {
1109
- // Restoring a multi-group popout window: its nested gridview was
1110
- // built up-front but never attached to a window. Dock every member
1111
- // into the main grid so no group is lost, then discard the
1112
- // detached gridview.
1113
- var blockedGridview_1 = options.overridePopoutGridview;
1114
- var members = this.groups.filter(function (candidate) {
1115
- return blockedGridview_1.element.contains(candidate.element);
1116
- });
1117
- var _loop_1 = function (member) {
1118
- this_1.movingLock(function () {
1119
- blockedGridview_1.remove(member);
1120
- _this.redockGroupToMainGrid(member);
1121
- });
1122
- };
1123
- var this_1 = this;
1124
- try {
1125
- for (var members_2 = __values(members), members_2_1 = members_2.next(); !members_2_1.done; members_2_1 = members_2.next()) {
1126
- var member = members_2_1.value;
1127
- _loop_1(member);
1128
- }
1129
- }
1130
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
1131
- finally {
1132
- try {
1133
- if (members_2_1 && !members_2_1.done && (_a = members_2.return)) _a.call(members_2);
1134
- }
1135
- finally { if (e_4) throw e_4.error; }
1136
- }
1137
- blockedGridview_1.dispose();
1138
- if (referenceGroup && !referenceGroup.api.isVisible) {
1139
- referenceGroup.api.setVisible(true);
1140
- }
1141
- return;
1142
- }
1143
- if (group === referenceGroup) {
1144
- // No separate grid group to return to (e.g. restoring a popout
1145
- // straight from JSON) — dock this group into the main grid.
1146
- if (!this.gridview.element.contains(group.element)) {
1147
- this.movingLock(function () { return _this.doAddGroup(group, [0]); });
1148
- group.model.location = { type: 'grid' };
1149
- }
1150
- }
1151
- else {
1152
- // A fresh group was created for the popout — return its panels to
1153
- // the reference group and discard the now-empty popout group so it
1154
- // doesn't linger as an orphan.
1155
- this.movingLock(function () {
1156
- return moveGroupWithoutDestroying({
1157
- from: group,
1158
- to: referenceGroup,
1159
- });
1160
- });
1161
- if (group.model.size === 0 && this._groups.has(group.id)) {
1162
- group.dispose();
1163
- this._groups.delete(group.id);
1164
- this._onDidRemoveGroup.fire(group);
1165
- }
1166
- }
1167
- if (!referenceGroup.api.isVisible) {
1168
- referenceGroup.api.setVisible(true);
1169
- }
1170
- };
1171
- /**
1172
- * Wire a group that has been displaced from a floating / popout window back
1173
- * to the main grid's render & drop-target containers and dock it at the
1174
- * root. The caller is responsible for first detaching it from its old
1175
- * gridview — the detach strategy differs between the window-teardown path
1176
- * (`doRemoveGroup`) and the blocked-window path (`gridview.remove`).
1177
- */
1178
- DockviewComponent.prototype.redockGroupToMainGrid = function (group) {
1179
- group.model.renderContainer = this.overlayRenderContainer;
1180
- group.model.dropTargetContainer = this.rootDropTargetContainer;
1181
- group.model.location = { type: 'grid' };
1182
- this.doAddGroup(group, [0]);
1183
- };
1184
- /**
1185
- * Teardown for a popout window's `popoutWindowDisposable`. Runs when the
1186
- * window closes (by user, by `removeGroup`, or by component disposal):
1187
- * relocates every member group back to the main grid (or to a floating
1188
- * window when the anchor came from one), then disposes the nested gridview.
1189
- * `closeResult.returnedGroup` is read by the entry's `dispose()` contract.
1190
- */
1191
- DockviewComponent.prototype.disposePopoutWindow = function (params) {
1192
- var e_5, _a;
1193
- var _this = this;
1194
- var _b;
1195
- var group = params.group, referenceGroup = params.referenceGroup, popoutGridview = params.popoutGridview, isGroupAddedToDom = params.isGroupAddedToDom, floatingBox = params.floatingBox, disposePopoutGridview = params.disposePopoutGridview, closeResult = params.closeResult;
1196
- if (this.isDisposed) {
1197
- // cleanup may run after instance is disposed; just tear down the
1198
- // nested gridview.
1199
- disposePopoutGridview();
1200
- return;
1201
- }
1202
- // Distinguish a genuine window close from an explicit `removeGroup`:
1203
- // the explicit-removal paths remove the service entry *before* this
1204
- // disposable runs. Key off the stable `popoutGridview` rather than the
1205
- // captured `group`, which may no longer be the window's anchor (it can
1206
- // have been dragged out, promoting another member to anchor).
1207
- var genuineClose = !!((_b = this._popoutWindowService) === null || _b === void 0 ? void 0 : _b.entries.find(function (entry) { return entry.gridview === popoutGridview; }));
1208
- // The groups still living in this window, resolved from the gridview so
1209
- // a reassigned anchor doesn't hide surviving members.
1210
- var members = this.groups.filter(function (candidate) {
1211
- return popoutGridview.element.contains(candidate.element);
1212
- });
1213
- var anchorPresent = members.includes(group);
1214
- var anchorIsSoleMember = anchorPresent && members.length === 1;
1215
- // On a genuine close, relocate every member that ISN'T the captured
1216
- // anchor back to the main grid. The captured anchor (if still here) gets
1217
- // the reference-return / re-float treatment below. Explicit removal
1218
- // relocates via its own path, so the loop is skipped for it.
1219
- if (genuineClose) {
1220
- var _loop_2 = function (member) {
1221
- if (member === group) {
1222
- return "continue";
1223
- }
1224
- this_2.movingLock(function () {
1225
- _this.doRemoveGroup(member, {
1226
- skipDispose: true,
1227
- skipActive: true,
1228
- skipPopoutReturn: true,
1229
- });
1230
- _this.redockGroupToMainGrid(member);
1231
- });
1232
- };
1233
- var this_2 = this;
1234
- try {
1235
- for (var members_3 = __values(members), members_3_1 = members_3.next(); !members_3_1.done; members_3_1 = members_3.next()) {
1236
- var member = members_3_1.value;
1237
- _loop_2(member);
1238
- }
1239
- }
1240
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
1241
- finally {
1242
- try {
1243
- if (members_3_1 && !members_3_1.done && (_a = members_3.return)) _a.call(members_3);
1244
- }
1245
- finally { if (e_5) throw e_5.error; }
1246
- }
1247
- }
1248
- if (anchorPresent &&
1249
- isGroupAddedToDom &&
1250
- this.getPanel(referenceGroup.id)) {
1251
- this.movingLock(function () {
1252
- return moveGroupWithoutDestroying({
1253
- from: group,
1254
- to: referenceGroup,
1255
- });
1256
- });
1257
- if (!referenceGroup.api.isVisible) {
1258
- referenceGroup.api.setVisible(true);
1259
- }
1260
- if (this.getPanel(group.id)) {
1261
- this.doRemoveGroup(group, {
1262
- skipPopoutAssociated: true,
1263
- });
1264
- }
1265
- }
1266
- else if (anchorPresent && this.getPanel(group.id)) {
1267
- group.model.renderContainer = this.overlayRenderContainer;
1268
- group.model.dropTargetContainer = this.rootDropTargetContainer;
1269
- closeResult.returnedGroup = group;
1270
- if (!genuineClose) {
1271
- /**
1272
- * If this popout group was explicitly removed then we shouldn't run the additional
1273
- * steps. The explicit remover re-docks the returned group itself; here we only hand
1274
- * it back (above) and tear down the nested gridview.
1275
- */
1276
- disposePopoutGridview();
1277
- return;
1278
- }
1279
- // Re-float only restores the pre-popout state of a SINGLE popped-out
1280
- // group. A multi-group window must not be split (anchor re-floats
1281
- // while the rest dock to the grid), so dock the anchor to the grid
1282
- // alongside the other members once they're no longer alone.
1283
- if (floatingBox && anchorIsSoleMember) {
1284
- this.addFloatingGroup(group, {
1285
- height: floatingBox.height,
1286
- width: floatingBox.width,
1287
- position: floatingBox,
1288
- });
1289
- }
1290
- else {
1291
- this.doRemoveGroup(group, {
1292
- skipDispose: true,
1293
- skipActive: true,
1294
- skipPopoutReturn: true,
1295
- });
1296
- group.model.location = { type: 'grid' };
1297
- this.movingLock(function () {
1298
- // suppress group add events since the group already exists
1299
- _this.doAddGroup(group, [0]);
1300
- });
1301
- }
1302
- this.doSetGroupAndPanelActive(group);
1303
- }
1304
- // All members have been relocated out; tear down the window's nested
1305
- // gridview (does not dispose the leaf views — their lifecycle stays
1306
- // with `_groups`).
1307
- disposePopoutGridview();
1308
- };
1309
- DockviewComponent.prototype.addFloatingGroup = function (item, options) {
1310
- var _this = this;
1311
- this.mutation('float', function () { return _this._doAddFloatingGroup(item, options); });
1312
- };
1313
- DockviewComponent.prototype._doAddFloatingGroup = function (item, options) {
1314
- var _this = this;
1315
- var _a;
1316
- var service = (0, modules_1.assertModule)(this._floatingGroupService, 'FloatingGroup', 'api.addFloatingGroup');
1317
- if (!service) {
1318
- return;
1319
- }
1320
- if (item instanceof dockviewGroupPanel_1.DockviewGroupPanel &&
1321
- item.model.location.type === 'edge') {
1322
- // edge groups are permanent structural elements and cannot be floated
1323
- return;
1324
- }
1325
- var group;
1326
- if (item instanceof dockviewPanel_1.DockviewPanel) {
1327
- group = this.createGroup();
1328
- this._onDidAddGroup.fire(group);
1329
- this.movingLock(function () {
1330
- return _this.removePanel(item, {
1331
- removeEmptyGroup: true,
1332
- skipDispose: true,
1333
- skipSetActiveGroup: true,
1334
- });
1335
- });
1336
- this.movingLock(function () {
1337
- return group.model.openPanel(item, { skipSetGroupActive: true });
1338
- });
1339
- }
1340
- else {
1341
- group = item;
1342
- var popoutReferenceGroupId = (_a = this._popoutWindowService) === null || _a === void 0 ? void 0 : _a.findReferenceGroupId(group);
1343
- var popoutReferenceGroup_1 = popoutReferenceGroupId
1344
- ? this.getPanel(popoutReferenceGroupId)
1345
- : undefined;
1346
- var skip = typeof (options === null || options === void 0 ? void 0 : options.skipRemoveGroup) === 'boolean' &&
1347
- options.skipRemoveGroup;
1348
- if (!skip) {
1349
- if (popoutReferenceGroup_1) {
1350
- this.movingLock(function () {
1351
- return moveGroupWithoutDestroying({
1352
- from: item,
1353
- to: popoutReferenceGroup_1,
1354
- });
1355
- });
1356
- this.doRemoveGroup(item, {
1357
- skipPopoutReturn: true,
1358
- skipPopoutAssociated: true,
1359
- });
1360
- this.doRemoveGroup(popoutReferenceGroup_1, {
1361
- skipDispose: true,
1362
- });
1363
- group = popoutReferenceGroup_1;
1364
- }
1365
- else {
1366
- this.doRemoveGroup(item, {
1367
- skipDispose: true,
1368
- skipPopoutReturn: true,
1369
- skipPopoutAssociated: false,
1370
- });
1371
- }
1372
- }
1373
- }
1374
- function getAnchoredBox() {
1375
- if (options === null || options === void 0 ? void 0 : options.position) {
1376
- var result = {};
1377
- if ('left' in options.position) {
1378
- result.left = Math.max(options.position.left, 0);
1379
- }
1380
- else if ('right' in options.position) {
1381
- result.right = Math.max(options.position.right, 0);
1382
- }
1383
- else {
1384
- result.left = constants_1.DEFAULT_FLOATING_GROUP_POSITION.left;
1385
- }
1386
- if ('top' in options.position) {
1387
- result.top = Math.max(options.position.top, 0);
1388
- }
1389
- else if ('bottom' in options.position) {
1390
- result.bottom = Math.max(options.position.bottom, 0);
1391
- }
1392
- else {
1393
- result.top = constants_1.DEFAULT_FLOATING_GROUP_POSITION.top;
1394
- }
1395
- if (typeof options.width === 'number') {
1396
- result.width = Math.max(options.width, 0);
1397
- }
1398
- else {
1399
- result.width = constants_1.DEFAULT_FLOATING_GROUP_POSITION.width;
1400
- }
1401
- if (typeof options.height === 'number') {
1402
- result.height = Math.max(options.height, 0);
1403
- }
1404
- else {
1405
- result.height = constants_1.DEFAULT_FLOATING_GROUP_POSITION.height;
1406
- }
1407
- return result;
1408
- }
1409
- return {
1410
- left: typeof (options === null || options === void 0 ? void 0 : options.x) === 'number'
1411
- ? Math.max(options.x, 0)
1412
- : constants_1.DEFAULT_FLOATING_GROUP_POSITION.left,
1413
- top: typeof (options === null || options === void 0 ? void 0 : options.y) === 'number'
1414
- ? Math.max(options.y, 0)
1415
- : constants_1.DEFAULT_FLOATING_GROUP_POSITION.top,
1416
- width: typeof (options === null || options === void 0 ? void 0 : options.width) === 'number'
1417
- ? Math.max(options.width, 0)
1418
- : constants_1.DEFAULT_FLOATING_GROUP_POSITION.width,
1419
- height: typeof (options === null || options === void 0 ? void 0 : options.height) === 'number'
1420
- ? Math.max(options.height, 0)
1421
- : constants_1.DEFAULT_FLOATING_GROUP_POSITION.height,
1422
- };
1423
- }
1424
- var anchoredBox = getAnchoredBox();
1425
- // The floating window hosts its own gridview so it can grow into a
1426
- // nested splitview layout. The window starts with the single anchor
1427
- // group; further groups are added via drag-and-drop.
1428
- var floatingGridview = this.createNestedGridview();
1429
- floatingGridview.addView(group, splitview_1.Sizing.Distribute, [0]);
1430
- this.mountFloatingWindow(floatingGridview, group, [group], anchoredBox, {
1431
- dragHandle: options === null || options === void 0 ? void 0 : options.dragHandle,
1432
- inDragMode: options === null || options === void 0 ? void 0 : options.inDragMode,
1433
- skipActiveGroup: options === null || options === void 0 ? void 0 : options.skipActiveGroup,
1434
- });
1435
- };
1436
- /**
1437
- * Build an empty gridview configured to match the main grid's styling, for
1438
- * hosting a nested layout inside a floating or popout window.
1439
- */
1440
- DockviewComponent.prototype.createNestedGridview = function (orientation) {
1441
- var _a, _b;
1442
- if (orientation === void 0) { orientation = splitview_1.Orientation.HORIZONTAL; }
1443
- return new gridview_1.Gridview(true, this.options.hideBorders
1444
- ? { separatorBorder: 'transparent' }
1445
- : undefined, orientation, false, (_b = (_a = this.options.theme) === null || _a === void 0 ? void 0 : _a.gap) !== null && _b !== void 0 ? _b : 0);
1446
- };
1447
- /**
1448
- * Wrap a (populated) floating gridview in an overlay window: title bar /
1449
- * move handle, drag wiring, the floating-group service entry and the
1450
- * `floating` location tag for every member group.
1451
- */
1452
- DockviewComponent.prototype.mountFloatingWindow = function (floatingGridview, anchorGroup, members, anchoredBox, options) {
1453
- var e_6, _a;
1454
- var _this = this;
1455
- var _b, _c, _d, _e, _f, _g, _h, _j;
1456
- var service = (0, modules_1.assertModule)(this._floatingGroupService, 'FloatingGroup', 'api.addFloatingGroup');
1457
- if (!service) {
1458
- return;
1459
- }
1460
- var dragHandleMode = (_c = (_b = options === null || options === void 0 ? void 0 : options.dragHandle) !== null && _b !== void 0 ? _b : this.options.floatingGroupDragHandle) !== null && _c !== void 0 ? _c : 'titlebar';
1461
- // `'titlebar'` renders a dedicated grab bar above the tab bar and uses
1462
- // it as the move handle; `'tabbar'` falls back to moving via the
1463
- // tab-bar void container.
1464
- var titleBar = dragHandleMode === 'titlebar'
1465
- ? new floatingTitleBar_1.FloatingTitleBar(this, anchorGroup)
1466
- : undefined;
1467
- var overlay = new overlay_1.Overlay(__assign(__assign({ container: (_d = this._floatingOverlayHost) !== null && _d !== void 0 ? _d : this.gridview.element, content: floatingGridview.element, header: titleBar === null || titleBar === void 0 ? void 0 : titleBar.element }, anchoredBox), { minimumInViewportWidth: this.options.floatingGroupBounds === 'boundedWithinViewport'
1468
- ? undefined
1469
- : ((_f = (_e = this.options.floatingGroupBounds) === null || _e === void 0 ? void 0 : _e.minimumWidthWithinViewport) !== null && _f !== void 0 ? _f : constants_1.DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE), minimumInViewportHeight: this.options.floatingGroupBounds === 'boundedWithinViewport'
1470
- ? undefined
1471
- : ((_h = (_g = this.options.floatingGroupBounds) === null || _g === void 0 ? void 0 : _g.minimumHeightWithinViewport) !== null && _h !== void 0 ? _h : constants_1.DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE), transformDragPosition: this.options.transformFloatingGroupDrag
1472
- ? function (context) {
1473
- return _this.options.transformFloatingGroupDrag({
1474
- group: anchorGroup,
1475
- proposed: context.proposed,
1476
- container: context.container,
1477
- others: context.others,
1478
- });
1479
- }
1480
- : undefined, getSiblingBoxes: function () { return _this._gatherFloatingGroupBoxes(anchorGroup); } }));
1481
- var dragHandle = (_j = titleBar === null || titleBar === void 0 ? void 0 : titleBar.element) !== null && _j !== void 0 ? _j : anchorGroup.element.querySelector('.dv-void-container');
1482
- if (!dragHandle) {
1483
- throw new Error('dockview: failed to find drag handle');
1484
- }
1485
- overlay.setupDrag(dragHandle, {
1486
- inDragMode: typeof (options === null || options === void 0 ? void 0 : options.inDragMode) === 'boolean'
1487
- ? options.inDragMode
1488
- : false,
1489
- });
1490
- var floatingGroupPanel = service.add(anchorGroup, overlay, floatingGridview);
1491
- if (titleBar) {
1492
- // Tie the title bar's lifetime to the floating window and surface
1493
- // its redock drag through the same public `onWillDragGroup` event
1494
- // the tab-bar handle uses. Register it so anchor reassignment (when
1495
- // the original anchor leaves a multi-group window) retargets the
1496
- // bar at a group that still lives here.
1497
- floatingGroupPanel.setTitleBar(titleBar);
1498
- floatingGroupPanel.addDisposables(titleBar, lifecycle_1.Disposable.from(function () {
1499
- return floatingGroupPanel.setTitleBar(undefined);
1500
- }), titleBar.onDragStart(function (event) {
1501
- _this._onWillDragGroup.fire({
1502
- nativeEvent: event,
1503
- group: floatingGroupPanel.group,
1504
- });
1505
- }));
1506
- }
1507
- try {
1508
- for (var members_4 = __values(members), members_4_1 = members_4.next(); !members_4_1.done; members_4_1 = members_4.next()) {
1509
- var member = members_4_1.value;
1510
- member.model.location = { type: 'floating' };
1511
- }
1512
- }
1513
- catch (e_6_1) { e_6 = { error: e_6_1 }; }
1514
- finally {
1515
- try {
1516
- if (members_4_1 && !members_4_1.done && (_a = members_4.return)) _a.call(members_4);
1517
- }
1518
- finally { if (e_6) throw e_6.error; }
1519
- }
1520
- if (!(options === null || options === void 0 ? void 0 : options.skipActiveGroup)) {
1521
- this.doSetGroupAndPanelActive(anchorGroup);
1522
- }
1523
- };
1524
- DockviewComponent.prototype.orthogonalize = function (position, options) {
1525
- this.gridview.normalize();
1526
- switch (position) {
1527
- case 'top':
1528
- case 'bottom':
1529
- if (this.gridview.orientation === splitview_1.Orientation.HORIZONTAL) {
1530
- // we need to add to a vertical splitview but the current root is a horizontal splitview.
1531
- // insert a vertical splitview at the root level and add the existing view as a child
1532
- this.gridview.insertOrthogonalSplitviewAtRoot();
1533
- }
1534
- break;
1535
- case 'left':
1536
- case 'right':
1537
- if (this.gridview.orientation === splitview_1.Orientation.VERTICAL) {
1538
- // we need to add to a horizontal splitview but the current root is a vertical splitview.
1539
- // insert a horiziontal splitview at the root level and add the existing view as a child
1540
- this.gridview.insertOrthogonalSplitviewAtRoot();
1541
- }
1542
- break;
1543
- default:
1544
- break;
1545
- }
1546
- switch (position) {
1547
- case 'top':
1548
- case 'left':
1549
- case 'center':
1550
- return this.createGroupAtLocation([0], undefined, options); // insert into first position
1551
- case 'bottom':
1552
- case 'right':
1553
- return this.createGroupAtLocation([this.gridview.length], undefined, options); // insert into last position
1554
- default:
1555
- throw new Error("dockview: unsupported position ".concat(position));
1556
- }
1557
- };
1558
- DockviewComponent.prototype.updateOptions = function (options) {
1559
- var e_7, _a, e_8, _b;
1560
- var _c, _d, _e, _f, _g;
1561
- _super.prototype.updateOptions.call(this, options);
1562
- (_c = this._floatingGroupService) === null || _c === void 0 ? void 0 : _c.updateBounds(options);
1563
- (_d = this._rootDropTargetService) === null || _d === void 0 ? void 0 : _d.setOptions(options);
1564
- var oldDisableDnd = this.options.disableDnd;
1565
- var oldDndStrategy = this.options.dndStrategy;
1566
- this._options = __assign(__assign({}, this.options), options);
1567
- var newDisableDnd = this.options.disableDnd;
1568
- var newDndStrategy = this.options.dndStrategy;
1569
- if (oldDisableDnd !== newDisableDnd ||
1570
- oldDndStrategy !== newDndStrategy) {
1571
- this.updateDragAndDropState();
1572
- }
1573
- if ('theme' in options) {
1574
- this.updateTheme();
1575
- }
1576
- if ('createRightHeaderActionComponent' in options ||
1577
- 'createLeftHeaderActionComponent' in options ||
1578
- 'createPrefixHeaderActionComponent' in options) {
1579
- (_e = this.headerActionsService) === null || _e === void 0 ? void 0 : _e.refreshAll();
1580
- }
1581
- if ('createWatermarkComponent' in options) {
1582
- (_f = this._watermarkService) === null || _f === void 0 ? void 0 : _f.refresh();
1583
- try {
1584
- for (var _h = __values(this.groups), _j = _h.next(); !_j.done; _j = _h.next()) {
1585
- var group = _j.value;
1586
- group.model.refreshWatermark();
1587
- }
1588
- }
1589
- catch (e_7_1) { e_7 = { error: e_7_1 }; }
1590
- finally {
1591
- try {
1592
- if (_j && !_j.done && (_a = _h.return)) _a.call(_h);
1593
- }
1594
- finally { if (e_7) throw e_7.error; }
1595
- }
1596
- }
1597
- if ('tabGroupColors' in options || 'tabGroupAccent' in options) {
1598
- this._tabGroupColorPalette.setEntries((_g = this._options.tabGroupColors) !== null && _g !== void 0 ? _g : tabGroupAccent_1.DEFAULT_TAB_GROUP_COLORS);
1599
- this._tabGroupColorPalette.enabled =
1600
- this._options.tabGroupAccent !== 'off';
1601
- try {
1602
- for (var _k = __values(this.groups), _l = _k.next(); !_l.done; _l = _k.next()) {
1603
- var group = _l.value;
1604
- group.model.refreshTabGroupAccent();
1605
- }
1606
- }
1607
- catch (e_8_1) { e_8 = { error: e_8_1 }; }
1608
- finally {
1609
- try {
1610
- if (_l && !_l.done && (_b = _k.return)) _b.call(_k);
1611
- }
1612
- finally { if (e_8) throw e_8.error; }
1613
- }
1614
- }
1615
- this._onDidOptionsChange.fire();
1616
- this._layoutFromShell(this.gridview.width, this.gridview.height);
1617
- };
1618
- DockviewComponent.prototype.layout = function (width, height, forceResize) {
1619
- var _a, _b;
1620
- if (this._shellManager && !this._inShellLayout) {
1621
- this._shellManager.layout(width, height);
1622
- }
1623
- else {
1624
- _super.prototype.layout.call(this, width, height, forceResize);
1625
- }
1626
- this._syncFloatingOverlayHost();
1627
- // floatingGroupService may be undefined during super() (BaseGrid calls
1628
- // layout(0, 0) before subclass field initialisers run).
1629
- (_b = (_a = this._moduleRegistry) === null || _a === void 0 ? void 0 : _a.services.floatingGroupService) === null || _b === void 0 ? void 0 : _b.constrainBounds();
1630
- };
1631
- DockviewComponent.prototype._syncFloatingOverlayHost = function () {
1632
- if (!this._floatingOverlayHost || !this._shellManager) {
1633
- return;
1634
- }
1635
- var shellRect = this._shellManager.element.getBoundingClientRect();
1636
- var gridRect = this.element.getBoundingClientRect();
1637
- var host = this._floatingOverlayHost;
1638
- host.style.left = "".concat(gridRect.left - shellRect.left, "px");
1639
- host.style.top = "".concat(gridRect.top - shellRect.top, "px");
1640
- host.style.width = "".concat(gridRect.width, "px");
1641
- host.style.height = "".concat(gridRect.height, "px");
1642
- };
1643
- DockviewComponent.prototype._layoutFromShell = function (width, height) {
1644
- this._inShellLayout = true;
1645
- this.layout(width, height, true);
1646
- this._inShellLayout = false;
1647
- };
1648
- DockviewComponent.prototype.forceRelayout = function () {
1649
- if (this._shellManager) {
1650
- this._layoutFromShell(this.width, this.height);
1651
- }
1652
- else {
1653
- _super.prototype.forceRelayout.call(this);
1654
- }
1655
- };
1656
- DockviewComponent.prototype.addEdgeGroup = function (position, options) {
1657
- var _this = this;
1658
- var service = (0, modules_1.assertModule)(this._edgeGroupService, 'EdgeGroup', 'api.addEdgeGroup');
1659
- if (!service) {
1660
- throw new Error("dockview: EdgeGroup module is not registered");
1661
- }
1662
- if (service.has(position)) {
1663
- throw new Error("dockview: edge group already exists at position '".concat(position, "'"));
1664
- }
1665
- return this.mutation('add', function () {
1666
- var group = _this.createGroup({ id: options.id });
1667
- group.model.location = { type: 'edge', position: position };
1668
- group.model.headerPosition = position;
1669
- // Collapse when the group becomes empty
1670
- var autoCollapseDisposable = group.model.onDidRemovePanel(function () {
1671
- if (group.model.isEmpty) {
1672
- _this.setEdgeGroupCollapsed(group, true);
1673
- }
1674
- });
1675
- service.add(position, group, autoCollapseDisposable);
1676
- _this._onDidAddGroup.fire(group);
1677
- _this._shellManager.addEdgeView(position, options, group);
1678
- return group.api;
1679
- });
1680
- };
1681
- DockviewComponent.prototype.getEdgeGroup = function (position) {
1682
- var _a, _b;
1683
- return (_b = (_a = this._edgeGroupService) === null || _a === void 0 ? void 0 : _a.get(position)) === null || _b === void 0 ? void 0 : _b.api;
1684
- };
1685
- DockviewComponent.prototype.setEdgeGroupVisible = function (position, visible) {
1686
- this._shellManager.setEdgeGroupVisible(position, visible);
1687
- };
1688
- DockviewComponent.prototype.isEdgeGroupVisible = function (position) {
1689
- return this._shellManager.isEdgeGroupVisible(position);
1690
- };
1691
- DockviewComponent.prototype.removeEdgeGroup = function (position) {
1692
- var _this = this;
1693
- var service = (0, modules_1.assertModule)(this._edgeGroupService, 'EdgeGroup', 'api.removeEdgeGroup');
1694
- if (!service) {
1695
- return;
1696
- }
1697
- var group = service.get(position);
1698
- if (!group) {
1699
- throw new Error("dockview: no edge group exists at position '".concat(position, "'"));
1700
- }
1701
- // One transaction — the per-panel removals below nest via the depth
1702
- // counter, so consumers see a single edge-group removal.
1703
- this.mutation('remove', function () {
1704
- var e_9, _a;
1705
- try {
1706
- // Remove panels inside the group first
1707
- for (var _b = __values(__spreadArray([], __read(group.panels), false)), _c = _b.next(); !_c.done; _c = _b.next()) {
1708
- var panel = _c.value;
1709
- _this.removePanel(panel, {
1710
- removeEmptyGroup: false,
1711
- skipDispose: false,
1712
- });
1713
- }
1714
- }
1715
- catch (e_9_1) { e_9 = { error: e_9_1 }; }
1716
- finally {
1717
- try {
1718
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1719
- }
1720
- finally { if (e_9) throw e_9.error; }
1721
- }
1722
- // Remove from the shell splitview
1723
- _this._shellManager.removeEdgeView(position);
1724
- // Clean up service-tracked state + group itself
1725
- service.remove(position);
1726
- group.dispose();
1727
- _this._groups.delete(group.id);
1728
- _this._onDidRemoveGroup.fire(group);
1729
- });
1730
- };
1731
- DockviewComponent.prototype.setEdgeGroupCollapsed = function (group, collapsed) {
1732
- var _a;
1733
- var position = (_a = this._edgeGroupService) === null || _a === void 0 ? void 0 : _a.findPositionOf(group);
1734
- if (!position) {
1735
- return;
1736
- }
1737
- if (this._shellManager.isEdgeGroupCollapsed(position) === collapsed) {
1738
- // Skip the splitview resize on a no-op: with non-zero theme gap,
1739
- // redundant resizeView calls accumulate rounding drift that
1740
- // gradually shrinks the group.
1741
- return;
1742
- }
1743
- this._shellManager.setEdgeGroupCollapsed(position, collapsed);
1744
- group.api._onDidCollapsedChange.fire({ isCollapsed: collapsed });
1745
- };
1746
- DockviewComponent.prototype.isEdgeGroupCollapsed = function (group) {
1747
- var _a;
1748
- var position = (_a = this._edgeGroupService) === null || _a === void 0 ? void 0 : _a.findPositionOf(group);
1749
- return position
1750
- ? this._shellManager.isEdgeGroupCollapsed(position)
1751
- : false;
1752
- };
1753
- DockviewComponent.prototype.updateDragAndDropState = function () {
1754
- var e_10, _a;
1755
- try {
1756
- // Update draggable state for all tabs and void containers
1757
- for (var _b = __values(this.groups), _c = _b.next(); !_c.done; _c = _b.next()) {
1758
- var group = _c.value;
1759
- group.model.updateDragAndDropState();
1760
- }
1761
- }
1762
- catch (e_10_1) { e_10 = { error: e_10_1 }; }
1763
- finally {
1764
- try {
1765
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1766
- }
1767
- finally { if (e_10) throw e_10.error; }
1768
- }
1769
- };
1770
- DockviewComponent.prototype.focus = function () {
1771
- var _a;
1772
- (_a = this.activeGroup) === null || _a === void 0 ? void 0 : _a.focus();
1773
- };
1774
- DockviewComponent.prototype.getGroupPanel = function (id) {
1775
- return this.panels.find(function (panel) { return panel.id === id; });
1776
- };
1777
- DockviewComponent.prototype.setActivePanel = function (panel) {
1778
- panel.group.model.openPanel(panel);
1779
- this.doSetGroupAndPanelActive(panel.group);
1780
- };
1781
- DockviewComponent.prototype.moveToNext = function (options) {
1782
- var _a;
1783
- if (options === void 0) { options = {}; }
1784
- if (!options.group) {
1785
- if (!this.activeGroup) {
1786
- return;
1787
- }
1788
- options.group = this.activeGroup;
1789
- }
1790
- if (options.includePanel && options.group) {
1791
- if (options.group.activePanel !==
1792
- options.group.panels[options.group.panels.length - 1]) {
1793
- options.group.model.moveToNext({ suppressRoll: true });
1794
- return;
1795
- }
1796
- }
1797
- var location = (0, gridview_1.getGridLocation)(options.group.element);
1798
- var next = (_a = this.gridview.next(location)) === null || _a === void 0 ? void 0 : _a.view;
1799
- this.doSetGroupAndPanelActive(next);
1800
- };
1801
- DockviewComponent.prototype.moveToPrevious = function (options) {
1802
- var _a;
1803
- if (options === void 0) { options = {}; }
1804
- if (!options.group) {
1805
- if (!this.activeGroup) {
1806
- return;
1807
- }
1808
- options.group = this.activeGroup;
1809
- }
1810
- if (options.includePanel && options.group) {
1811
- if (options.group.activePanel !== options.group.panels[0]) {
1812
- options.group.model.moveToPrevious({ suppressRoll: true });
1813
- return;
1814
- }
1815
- }
1816
- var location = (0, gridview_1.getGridLocation)(options.group.element);
1817
- var next = (_a = this.gridview.previous(location)) === null || _a === void 0 ? void 0 : _a.view;
1818
- if (next) {
1819
- this.doSetGroupAndPanelActive(next);
1820
- }
1821
- };
1822
- /**
1823
- * Serialize the current state of the layout
1824
- *
1825
- * @returns A JSON respresentation of the layout
1826
- */
1827
- DockviewComponent.prototype.toJSON = function () {
1828
- var e_11, _a;
1829
- var _b, _c, _d, _e, _f, _g, _h, _j;
1830
- var data = this.gridview.serialize();
1831
- var panels = this.panels.reduce(function (collection, panel) {
1832
- collection[panel.id] = panel.toJSON();
1833
- return collection;
1834
- }, {});
1835
- var floats = (_c = (_b = this._floatingGroupService) === null || _b === void 0 ? void 0 : _b.serialize()) !== null && _c !== void 0 ? _c : [];
1836
- var popoutGroups = (_e = (_d = this._popoutWindowService) === null || _d === void 0 ? void 0 : _d.serialize()) !== null && _e !== void 0 ? _e : [];
1837
- var result = {
1838
- grid: data,
1839
- panels: panels,
1840
- activeGroup: (_f = this.activeGroup) === null || _f === void 0 ? void 0 : _f.id,
1841
- };
1842
- if (floats.length > 0) {
1843
- result.floatingGroups = floats;
1844
- }
1845
- if (popoutGroups.length > 0) {
1846
- result.popoutGroups = popoutGroups;
1847
- }
1848
- var edgeEntries = (_h = (_g = this._edgeGroupService) === null || _g === void 0 ? void 0 : _g.entries()) !== null && _h !== void 0 ? _h : [];
1849
- if ((_j = this._edgeGroupService) === null || _j === void 0 ? void 0 : _j.hasAny()) {
1850
- var shellSerialized = this._shellManager.toJSON();
1851
- try {
1852
- // Augment each entry with the serialized group state
1853
- for (var edgeEntries_1 = __values(edgeEntries), edgeEntries_1_1 = edgeEntries_1.next(); !edgeEntries_1_1.done; edgeEntries_1_1 = edgeEntries_1.next()) {
1854
- var _k = __read(edgeEntries_1_1.value, 2), position = _k[0], group = _k[1];
1855
- var entry = shellSerialized[position];
1856
- if (entry) {
1857
- entry.group = group.toJSON();
1858
- }
1859
- }
1860
- }
1861
- catch (e_11_1) { e_11 = { error: e_11_1 }; }
1862
- finally {
1863
- try {
1864
- if (edgeEntries_1_1 && !edgeEntries_1_1.done && (_a = edgeEntries_1.return)) _a.call(edgeEntries_1);
1865
- }
1866
- finally { if (e_11) throw e_11.error; }
1867
- }
1868
- result.edgeGroups = shellSerialized;
1869
- }
1870
- return result;
1871
- };
1872
- DockviewComponent.prototype.fromJSON = function (data, options) {
1873
- var _this = this;
1874
- // One 'load' transaction for the whole deserialization — the many
1875
- // nested add/remove mutations join it via the depth counter.
1876
- this.mutation('load', function () { return _this._doFromJSON(data, options); });
1877
- };
1878
- DockviewComponent.prototype._doFromJSON = function (data, options) {
1879
- var e_12, _a, e_13, _b, e_14, _c, e_15, _d;
1880
- var _this = this;
1881
- var _e, _f, _g, _h, _j, _k, _l;
1882
- // Cancel any popout-restoration timers queued by a previous fromJSON
1883
- // that haven't fired yet. The cancel path also disposes orphan groups
1884
- // registered in _groups synchronously but never parented into a popout
1885
- // window — otherwise the upcoming clear() would call gridview.remove()
1886
- // on an unparented element and throw "Invalid grid element". See
1887
- // issue #1304.
1888
- (_e = this._popoutWindowService) === null || _e === void 0 ? void 0 : _e.cancelPendingRestorations();
1889
- var existingPanels = new Map();
1890
- var tempGroup;
1891
- if (options === null || options === void 0 ? void 0 : options.reuseExistingPanels) {
1892
- /**
1893
- * What are we doing here?
1894
- *
1895
- * 1. Create a temporary group to hold any panels that currently exist and that also exist in the new layout
1896
- * 2. Remove that temporary group from the group mapping so that it doesn't get cleared when we clear the layout
1897
- */
1898
- tempGroup = this.createGroup();
1899
- this._groups.delete(tempGroup.api.id);
1900
- var newPanels = Object.keys(data.panels);
1901
- try {
1902
- for (var _m = __values(this.panels), _o = _m.next(); !_o.done; _o = _m.next()) {
1903
- var panel = _o.value;
1904
- if (newPanels.includes(panel.api.id)) {
1905
- existingPanels.set(panel.api.id, panel);
1906
- }
1907
- }
1908
- }
1909
- catch (e_12_1) { e_12 = { error: e_12_1 }; }
1910
- finally {
1911
- try {
1912
- if (_o && !_o.done && (_a = _m.return)) _a.call(_m);
1913
- }
1914
- finally { if (e_12) throw e_12.error; }
1915
- }
1916
- this.movingLock(function () {
1917
- Array.from(existingPanels.values()).forEach(function (panel) {
1918
- _this.moveGroupOrPanel({
1919
- from: {
1920
- groupId: panel.api.group.api.id,
1921
- panelId: panel.api.id,
1922
- },
1923
- to: {
1924
- group: tempGroup,
1925
- position: 'center',
1926
- },
1927
- keepEmptyGroups: true,
1928
- });
1929
- });
1930
- });
1931
- }
1932
- this.clear();
1933
- if (typeof data !== 'object' || data === null) {
1934
- throw new Error('dockview: serialized layout must be a non-null object');
1935
- }
1936
- var grid = data.grid, panels = data.panels, activeGroup = data.activeGroup;
1937
- if (grid.root.type !== 'branch' || !Array.isArray(grid.root.data)) {
1938
- throw new Error('dockview: root must be of type branch');
1939
- }
1940
- try {
1941
- // take note of the existing dimensions
1942
- var width = this.width;
1943
- var height = this.height;
1944
- var createGroupFromSerializedState_1 = function (data) {
1945
- var e_16, _a;
1946
- var id = data.id, locked = data.locked, hideHeader = data.hideHeader, headerPosition = data.headerPosition, views = data.views, activeView = data.activeView;
1947
- if (typeof id !== 'string') {
1948
- throw new TypeError('dockview: group id must be of type string');
1949
- }
1950
- var group = _this.createGroup({
1951
- id: id,
1952
- locked: !!locked,
1953
- hideHeader: !!hideHeader,
1954
- headerPosition: headerPosition,
1955
- });
1956
- _this._onDidAddGroup.fire(group);
1957
- var createdPanels = [];
1958
- var _loop_3 = function (child) {
1959
- /**
1960
- * Run the deserializer step seperately since this may fail to due corrupted external state.
1961
- * In running this section first we avoid firing lots of 'add' events in the event of a failure
1962
- * due to a corruption of input data.
1963
- */
1964
- var existingPanel = existingPanels.get(child);
1965
- if (tempGroup && existingPanel) {
1966
- _this.movingLock(function () {
1967
- tempGroup.model.removePanel(existingPanel);
1968
- });
1969
- createdPanels.push(existingPanel);
1970
- existingPanel.updateFromStateModel(panels[child]);
1971
- }
1972
- else {
1973
- var panel = _this._deserializer.fromJSON(panels[child], group);
1974
- createdPanels.push(panel);
1975
- }
1976
- };
1977
- try {
1978
- for (var views_1 = __values(views), views_1_1 = views_1.next(); !views_1_1.done; views_1_1 = views_1.next()) {
1979
- var child = views_1_1.value;
1980
- _loop_3(child);
1981
- }
1982
- }
1983
- catch (e_16_1) { e_16 = { error: e_16_1 }; }
1984
- finally {
1985
- try {
1986
- if (views_1_1 && !views_1_1.done && (_a = views_1.return)) _a.call(views_1);
1987
- }
1988
- finally { if (e_16) throw e_16.error; }
1989
- }
1990
- var _loop_4 = function (i) {
1991
- var panel = createdPanels[i];
1992
- var isActive = typeof activeView === 'string' &&
1993
- activeView === panel.id;
1994
- var hasExisting = existingPanels.has(panel.api.id);
1995
- if (hasExisting) {
1996
- _this.movingLock(function () {
1997
- group.model.openPanel(panel, {
1998
- skipSetActive: !isActive,
1999
- skipSetGroupActive: true,
2000
- });
2001
- });
2002
- }
2003
- else {
2004
- group.model.openPanel(panel, {
2005
- skipSetActive: !isActive,
2006
- skipSetGroupActive: true,
2007
- });
2008
- }
2009
- };
2010
- for (var i = 0; i < views.length; i++) {
2011
- _loop_4(i);
2012
- }
2013
- // Restore tab groups before activating a fallback panel so
2014
- // that collapsed groups can clear the active panel correctly.
2015
- if (data.tabGroups && data.tabGroups.length > 0) {
2016
- group.model.restoreTabGroups(data.tabGroups);
2017
- }
2018
- if (!group.activePanel && group.panels.length > 0) {
2019
- group.model.openPanel(group.panels[group.panels.length - 1], {
2020
- skipSetGroupActive: true,
2021
- });
2022
- }
2023
- return group;
2024
- };
2025
- this.gridview.deserialize(grid, {
2026
- fromJSON: function (node) {
2027
- return createGroupFromSerializedState_1(node.data);
2028
- },
2029
- });
2030
- this._layoutFromShell(width, height);
2031
- if (data.edgeGroups) {
2032
- this.deserializeEdgeGroups(data.edgeGroups, panels);
2033
- }
2034
- this.deserializeFloatingWindows((_f = data.floatingGroups) !== null && _f !== void 0 ? _f : [], createGroupFromSerializedState_1);
2035
- var popoutPromises = this.deserializePopoutWindows((_g = data.popoutGroups) !== null && _g !== void 0 ? _g : [], createGroupFromSerializedState_1);
2036
- (_h = this._popoutWindowService) === null || _h === void 0 ? void 0 : _h.finishRestoration(popoutPromises);
2037
- (_j = this._floatingGroupService) === null || _j === void 0 ? void 0 : _j.constrainBounds();
2038
- if (typeof activeGroup === 'string') {
2039
- var panel = this.getPanel(activeGroup);
2040
- if (panel) {
2041
- this.doSetGroupAndPanelActive(panel);
2042
- }
2043
- }
2044
- // `gridview.deserialize()` rebuilds the grid without firing the
2045
- // BaseGrid add events the watermark module reacts to, so the
2046
- // watermark mounted during `clear()` would otherwise persist over
2047
- // the restored layout. Re-evaluate now the layout is in place.
2048
- (_k = this._watermarkService) === null || _k === void 0 ? void 0 : _k.update();
2049
- }
2050
- catch (err) {
2051
- console.error('dockview: failed to deserialize layout. Reverting changes', err);
2052
- try {
2053
- /**
2054
- * Takes all the successfully created groups and remove all of their panels.
2055
- */
2056
- for (var _p = __values(this.groups), _q = _p.next(); !_q.done; _q = _p.next()) {
2057
- var group = _q.value;
2058
- try {
2059
- for (var _r = (e_14 = void 0, __values(group.panels)), _s = _r.next(); !_s.done; _s = _r.next()) {
2060
- var panel = _s.value;
2061
- this.removePanel(panel, {
2062
- removeEmptyGroup: false,
2063
- skipDispose: false,
2064
- });
2065
- }
2066
- }
2067
- catch (e_14_1) { e_14 = { error: e_14_1 }; }
2068
- finally {
2069
- try {
2070
- if (_s && !_s.done && (_c = _r.return)) _c.call(_r);
2071
- }
2072
- finally { if (e_14) throw e_14.error; }
2073
- }
2074
- }
2075
- }
2076
- catch (e_13_1) { e_13 = { error: e_13_1 }; }
2077
- finally {
2078
- try {
2079
- if (_q && !_q.done && (_b = _p.return)) _b.call(_p);
2080
- }
2081
- finally { if (e_13) throw e_13.error; }
2082
- }
2083
- try {
2084
- /**
2085
- * To remove a group we cannot call this.removeGroup(...) since this makes assumptions about
2086
- * the underlying HTMLElement existing in the Gridview.
2087
- */
2088
- for (var _t = __values(this.groups), _u = _t.next(); !_u.done; _u = _t.next()) {
2089
- var group = _u.value;
2090
- group.dispose();
2091
- this._groups.delete(group.id);
2092
- this._onDidRemoveGroup.fire(group);
2093
- }
2094
- }
2095
- catch (e_15_1) { e_15 = { error: e_15_1 }; }
2096
- finally {
2097
- try {
2098
- if (_u && !_u.done && (_d = _t.return)) _d.call(_t);
2099
- }
2100
- finally { if (e_15) throw e_15.error; }
2101
- }
2102
- (_l = this._floatingGroupService) === null || _l === void 0 ? void 0 : _l.disposeAll();
2103
- // fires clean-up events and clears the underlying HTML gridview.
2104
- this.clear();
2105
- /**
2106
- * even though we have cleaned-up we still want to inform the caller of their error
2107
- * and we'll do this through re-throwing the original error since afterall you would
2108
- * expect trying to load a corrupted layout to result in an error and not silently fail...
2109
- */
2110
- throw err;
2111
- }
2112
- // Force position updates for always visible panels after DOM layout is complete
2113
- this.debouncedUpdateAllPositions();
2114
- this._onDidLayoutFromJSON.fire();
2115
- };
2116
- /**
2117
- * Rebuild a floating / popout window's nested gridview from its serialized
2118
- * tree, collecting the member groups (in deserialization order) so the
2119
- * caller can mount or restore the window.
2120
- */
2121
- DockviewComponent.prototype.deserializeNestedGridview = function (grid, createGroup) {
2122
- var gridview = this.createNestedGridview(grid.orientation);
2123
- var members = [];
2124
- gridview.deserialize(grid, {
2125
- fromJSON: function (node) {
2126
- var group = createGroup(node.data);
2127
- members.push(group);
2128
- return group;
2129
- },
2130
- });
2131
- return { gridview: gridview, members: members };
2132
- };
2133
- DockviewComponent.prototype.deserializeEdgeGroups = function (edgeGroups, panels) {
2134
- var e_17, _a, e_18, _b, e_19, _c, e_20, _d;
2135
- var _e;
2136
- var edgeService = (0, modules_1.assertModule)(this._edgeGroupService, 'EdgeGroup', 'fromJSON edge restoration');
2137
- if (!edgeService) {
2138
- return;
2139
- }
2140
- try {
2141
- // Auto-create edge groups for positions in the serialized state that
2142
- // don't already have a group registered (e.g. when fromJSON is called
2143
- // before the user has called addEdgeGroup).
2144
- for (var _f = __values([
2145
- 'top',
2146
- 'bottom',
2147
- 'left',
2148
- 'right',
2149
- ]), _g = _f.next(); !_g.done; _g = _f.next()) {
2150
- var _position = _g.value;
2151
- var fixedData = edgeGroups[_position];
2152
- if (fixedData && !edgeService.has(_position)) {
2153
- var groupState = fixedData.group;
2154
- var id = (_e = groupState === null || groupState === void 0 ? void 0 : groupState.id) !== null && _e !== void 0 ? _e : "".concat(_position, "-group");
2155
- this.addEdgeGroup(_position, { id: id });
2156
- }
2157
- }
2158
- }
2159
- catch (e_17_1) { e_17 = { error: e_17_1 }; }
2160
- finally {
2161
- try {
2162
- if (_g && !_g.done && (_a = _f.return)) _a.call(_f);
2163
- }
2164
- finally { if (e_17) throw e_17.error; }
2165
- }
2166
- try {
2167
- // Restore panel contents of edge groups
2168
- for (var _h = __values(edgeService.entries()), _j = _h.next(); !_j.done; _j = _h.next()) {
2169
- var _k = __read(_j.value, 2), position = _k[0], edgeGroup = _k[1];
2170
- var edgeData = edgeGroups[position];
2171
- var groupState = edgeData === null || edgeData === void 0 ? void 0 : edgeData.group;
2172
- if (groupState) {
2173
- var views = groupState.views, activeView = groupState.activeView;
2174
- var createdPanels = [];
2175
- try {
2176
- for (var views_2 = (e_19 = void 0, __values(views)), views_2_1 = views_2.next(); !views_2_1.done; views_2_1 = views_2.next()) {
2177
- var panelId = views_2_1.value;
2178
- if (panels[panelId]) {
2179
- var panel = this._deserializer.fromJSON(panels[panelId], edgeGroup);
2180
- createdPanels.push(panel);
2181
- }
2182
- }
2183
- }
2184
- catch (e_19_1) { e_19 = { error: e_19_1 }; }
2185
- finally {
2186
- try {
2187
- if (views_2_1 && !views_2_1.done && (_c = views_2.return)) _c.call(views_2);
2188
- }
2189
- finally { if (e_19) throw e_19.error; }
2190
- }
2191
- try {
2192
- for (var createdPanels_1 = (e_20 = void 0, __values(createdPanels)), createdPanels_1_1 = createdPanels_1.next(); !createdPanels_1_1.done; createdPanels_1_1 = createdPanels_1.next()) {
2193
- var panel = createdPanels_1_1.value;
2194
- var isActive = activeView === panel.id;
2195
- edgeGroup.model.openPanel(panel, {
2196
- skipSetActive: !isActive,
2197
- skipSetGroupActive: true,
2198
- });
2199
- }
2200
- }
2201
- catch (e_20_1) { e_20 = { error: e_20_1 }; }
2202
- finally {
2203
- try {
2204
- if (createdPanels_1_1 && !createdPanels_1_1.done && (_d = createdPanels_1.return)) _d.call(createdPanels_1);
2205
- }
2206
- finally { if (e_20) throw e_20.error; }
2207
- }
2208
- // Restore tab groups before activating a fallback panel
2209
- if (groupState.tabGroups && groupState.tabGroups.length > 0) {
2210
- edgeGroup.model.restoreTabGroups(groupState.tabGroups);
2211
- }
2212
- if (!edgeGroup.activePanel && edgeGroup.panels.length > 0) {
2213
- edgeGroup.model.openPanel(edgeGroup.panels[edgeGroup.panels.length - 1], { skipSetGroupActive: true });
2214
- }
2215
- }
2216
- }
2217
- }
2218
- catch (e_18_1) { e_18 = { error: e_18_1 }; }
2219
- finally {
2220
- try {
2221
- if (_j && !_j.done && (_b = _h.return)) _b.call(_h);
2222
- }
2223
- finally { if (e_18) throw e_18.error; }
2224
- }
2225
- this._shellManager.fromJSON(edgeGroups);
2226
- };
2227
- DockviewComponent.prototype.deserializeFloatingWindows = function (serialized, createGroup) {
2228
- var e_21, _a;
2229
- try {
2230
- for (var serialized_1 = __values(serialized), serialized_1_1 = serialized_1.next(); !serialized_1_1.done; serialized_1_1 = serialized_1.next()) {
2231
- var serializedFloatingGroup = serialized_1_1.value;
2232
- var data = serializedFloatingGroup.data, grid = serializedFloatingGroup.grid, position = serializedFloatingGroup.position;
2233
- if (grid) {
2234
- // Multi-group window: rebuild the window's nested gridview from
2235
- // its serialized tree.
2236
- var _b = this.deserializeNestedGridview(grid, createGroup), floatingGridview = _b.gridview, members = _b.members;
2237
- if (members.length === 0) {
2238
- continue;
2239
- }
2240
- this.mountFloatingWindow(floatingGridview, members[0], members, position, { inDragMode: false });
2241
- }
2242
- else if (data) {
2243
- var group = createGroup(data);
2244
- this.addFloatingGroup(group, {
2245
- position: position,
2246
- width: position.width,
2247
- height: position.height,
2248
- skipRemoveGroup: true,
2249
- inDragMode: false,
2250
- });
2251
- }
2252
- }
2253
- }
2254
- catch (e_21_1) { e_21 = { error: e_21_1 }; }
2255
- finally {
2256
- try {
2257
- if (serialized_1_1 && !serialized_1_1.done && (_a = serialized_1.return)) _a.call(serialized_1);
2258
- }
2259
- finally { if (e_21) throw e_21.error; }
2260
- }
2261
- };
2262
- DockviewComponent.prototype.deserializePopoutWindows = function (serialized, createGroup) {
2263
- var _this = this;
2264
- var popoutService = serialized.length > 0
2265
- ? (0, modules_1.assertModule)(this._popoutWindowService, 'PopoutWindow', 'fromJSON popout restoration')
2266
- : this._popoutWindowService;
2267
- if (!popoutService) {
2268
- return [];
2269
- }
2270
- // Queue popup group creation with delays to avoid browser blocking
2271
- return serialized.flatMap(function (serializedPopoutGroup, index) {
2272
- var data = serializedPopoutGroup.data, grid = serializedPopoutGroup.grid, position = serializedPopoutGroup.position, gridReferenceGroup = serializedPopoutGroup.gridReferenceGroup, url = serializedPopoutGroup.url;
2273
- // Multi-group popout windows rebuild their nested gridview from the
2274
- // serialized tree; single-group windows use the legacy single-group
2275
- // path.
2276
- var overridePopoutGridview;
2277
- var members = [];
2278
- if (grid) {
2279
- var built = _this.deserializeNestedGridview(grid, createGroup);
2280
- overridePopoutGridview = built.gridview;
2281
- members = built.members;
2282
- if (members.length === 0) {
2283
- // A serialized window with no groups: nothing to restore.
2284
- // Mirror the floating path's guard and discard the empty
2285
- // gridview rather than passing an undefined anchor to
2286
- // addPopoutGroup.
2287
- overridePopoutGridview.dispose();
2288
- return [];
2289
- }
2290
- }
2291
- var group = grid ? members[0] : createGroup(data);
2292
- return popoutService.scheduleRestoration(index * constants_1.DESERIALIZATION_POPOUT_DELAY_MS, function () {
2293
- _this.addPopoutGroup(group, {
2294
- position: position !== null && position !== void 0 ? position : undefined,
2295
- overridePopoutGroup: gridReferenceGroup
2296
- ? group
2297
- : undefined,
2298
- overridePopoutGridview: overridePopoutGridview,
2299
- referenceGroup: gridReferenceGroup
2300
- ? _this.getPanel(gridReferenceGroup)
2301
- : undefined,
2302
- popoutUrl: url,
2303
- });
2304
- }, function () {
2305
- var e_22, _a, e_23, _b;
2306
- try {
2307
- // The group was registered in _groups synchronously but the
2308
- // timer that would parent it into the popout window never
2309
- // ran. Dispose the orphan here so the next clear() doesn't
2310
- // trip over an unparented element. See issue #1304.
2311
- for (var _c = __values(members.length > 0
2312
- ? members
2313
- : [group]), _d = _c.next(); !_d.done; _d = _c.next()) {
2314
- var orphan = _d.value;
2315
- if (!_this.isDisposed &&
2316
- _this._groups.has(orphan.id) &&
2317
- orphan.element.parentElement === null) {
2318
- try {
2319
- for (var _e = (e_23 = void 0, __values(__spreadArray([], __read(orphan.panels), false))), _f = _e.next(); !_f.done; _f = _e.next()) {
2320
- var panel = _f.value;
2321
- _this.removePanel(panel, {
2322
- removeEmptyGroup: false,
2323
- });
2324
- }
2325
- }
2326
- catch (e_23_1) { e_23 = { error: e_23_1 }; }
2327
- finally {
2328
- try {
2329
- if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
2330
- }
2331
- finally { if (e_23) throw e_23.error; }
2332
- }
2333
- orphan.dispose();
2334
- _this._groups.delete(orphan.id);
2335
- _this._onDidRemoveGroup.fire(orphan);
2336
- }
2337
- }
2338
- }
2339
- catch (e_22_1) { e_22 = { error: e_22_1 }; }
2340
- finally {
2341
- try {
2342
- if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
2343
- }
2344
- finally { if (e_22) throw e_22.error; }
2345
- }
2346
- });
2347
- });
2348
- };
2349
- DockviewComponent.prototype.clear = function () {
2350
- var _this = this;
2351
- this.mutation('clear', function () { return _this._doClear(); });
2352
- };
2353
- DockviewComponent.prototype._doClear = function () {
2354
- var e_24, _a, e_25, _b;
2355
- var _c;
2356
- var groups = Array.from(this._groups.values()).map(function (_) { return _.value; });
2357
- var hasActiveGroup = !!this.activeGroup;
2358
- try {
2359
- for (var groups_1 = __values(groups), groups_1_1 = groups_1.next(); !groups_1_1.done; groups_1_1 = groups_1.next()) {
2360
- var group = groups_1_1.value;
2361
- if ((_c = this._edgeGroupService) === null || _c === void 0 ? void 0 : _c.includes(group)) {
2362
- // Edge groups are structural - only clear their panels, not the group itself
2363
- var panels = __spreadArray([], __read(group.panels), false);
2364
- try {
2365
- for (var panels_1 = (e_25 = void 0, __values(panels)), panels_1_1 = panels_1.next(); !panels_1_1.done; panels_1_1 = panels_1.next()) {
2366
- var panel = panels_1_1.value;
2367
- this.removePanel(panel, { removeEmptyGroup: false });
2368
- }
2369
- }
2370
- catch (e_25_1) { e_25 = { error: e_25_1 }; }
2371
- finally {
2372
- try {
2373
- if (panels_1_1 && !panels_1_1.done && (_b = panels_1.return)) _b.call(panels_1);
2374
- }
2375
- finally { if (e_25) throw e_25.error; }
2376
- }
2377
- continue;
2378
- }
2379
- // remove the group will automatically remove the panels
2380
- this.removeGroup(group, { skipActive: true });
2381
- }
2382
- }
2383
- catch (e_24_1) { e_24 = { error: e_24_1 }; }
2384
- finally {
2385
- try {
2386
- if (groups_1_1 && !groups_1_1.done && (_a = groups_1.return)) _a.call(groups_1);
2387
- }
2388
- finally { if (e_24) throw e_24.error; }
2389
- }
2390
- if (hasActiveGroup) {
2391
- this.doSetGroupAndPanelActive(undefined);
2392
- }
2393
- this.gridview.clear();
2394
- };
2395
- DockviewComponent.prototype.closeAllGroups = function () {
2396
- var _this = this;
2397
- // One transaction — the per-panel removals inside nest via the depth
2398
- // counter, so consumers (undo, announcements) see a single mutation.
2399
- this.mutation('remove', function () {
2400
- var e_26, _a;
2401
- try {
2402
- for (var _b = __values(_this._groups.entries()), _c = _b.next(); !_c.done; _c = _b.next()) {
2403
- var entry = _c.value;
2404
- var _d = __read(entry, 2), _ = _d[0], group = _d[1];
2405
- group.value.model.closeAllPanels();
2406
- }
2407
- }
2408
- catch (e_26_1) { e_26 = { error: e_26_1 }; }
2409
- finally {
2410
- try {
2411
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
2412
- }
2413
- finally { if (e_26) throw e_26.error; }
2414
- }
2415
- });
2416
- };
2417
- DockviewComponent.prototype.addPanel = function (options) {
2418
- var _this = this;
2419
- return this.mutation('add', function () { return _this._doAddPanel(options); });
2420
- };
2421
- DockviewComponent.prototype._doAddPanel = function (options) {
2422
- var _a, _b, _c, _d;
2423
- if (this.panels.some(function (_) { return _.id === options.id; })) {
2424
- throw new Error("dockview: panel with id ".concat(options.id, " already exists"));
2425
- }
2426
- var referenceGroup;
2427
- if (options.position && options.floating) {
2428
- throw new Error('dockview: you can only provide one of: position, floating as arguments to .addPanel(...)');
2429
- }
2430
- var initial = {
2431
- width: options.initialWidth,
2432
- height: options.initialHeight,
2433
- };
2434
- var index;
2435
- if (options.position) {
2436
- if ((0, options_1.isPanelOptionsWithPanel)(options.position)) {
2437
- var referencePanel = typeof options.position.referencePanel === 'string'
2438
- ? this.getGroupPanel(options.position.referencePanel)
2439
- : options.position.referencePanel;
2440
- index = options.position.index;
2441
- if (!referencePanel) {
2442
- var referenceId = typeof options.position.referencePanel === 'string'
2443
- ? options.position.referencePanel
2444
- : (_a = options.position.referencePanel) === null || _a === void 0 ? void 0 : _a.id;
2445
- throw new Error("dockview: referencePanel '".concat(referenceId, "' does not exist"));
2446
- }
2447
- referenceGroup = this.findGroup(referencePanel);
2448
- }
2449
- else if ((0, options_1.isPanelOptionsWithGroup)(options.position)) {
2450
- referenceGroup =
2451
- typeof options.position.referenceGroup === 'string'
2452
- ? (_b = this._groups.get(options.position.referenceGroup)) === null || _b === void 0 ? void 0 : _b.value
2453
- : options.position.referenceGroup;
2454
- index = options.position.index;
2455
- if (!referenceGroup) {
2456
- var referenceId = typeof options.position.referenceGroup === 'string'
2457
- ? options.position.referenceGroup
2458
- : (_c = options.position.referenceGroup) === null || _c === void 0 ? void 0 : _c.id;
2459
- throw new Error("dockview: referenceGroup '".concat(referenceId, "' does not exist"));
2460
- }
2461
- }
2462
- else {
2463
- var group = this.orthogonalize((0, droptarget_1.directionToPosition)(options.position.direction));
2464
- var panel_1 = this.createPanel(options, group);
2465
- group.model.openPanel(panel_1, {
2466
- skipSetActive: options.inactive,
2467
- skipSetGroupActive: options.inactive,
2468
- index: index,
2469
- });
2470
- if (!options.inactive) {
2471
- this.doSetGroupAndPanelActive(group);
2472
- }
2473
- group.api.setSize({
2474
- height: initial === null || initial === void 0 ? void 0 : initial.height,
2475
- width: initial === null || initial === void 0 ? void 0 : initial.width,
2476
- });
2477
- return panel_1;
2478
- }
2479
- }
2480
- else {
2481
- referenceGroup = this.activeGroup;
2482
- }
2483
- var panel;
2484
- if (referenceGroup) {
2485
- var target = (0, baseComponentGridview_1.toTarget)(((_d = options.position) === null || _d === void 0 ? void 0 : _d.direction) || 'within');
2486
- if (options.floating) {
2487
- var group = this.createGroup();
2488
- this._onDidAddGroup.fire(group);
2489
- var floatingGroupOptions = typeof options.floating === 'object' &&
2490
- options.floating !== null
2491
- ? options.floating
2492
- : {};
2493
- this.addFloatingGroup(group, __assign(__assign({}, floatingGroupOptions), { inDragMode: false, skipRemoveGroup: true, skipActiveGroup: true }));
2494
- panel = this.createPanel(options, group);
2495
- group.model.openPanel(panel, {
2496
- skipSetActive: options.inactive,
2497
- skipSetGroupActive: options.inactive,
2498
- index: index,
2499
- });
2500
- }
2501
- else if (referenceGroup.api.location.type === 'floating' ||
2502
- referenceGroup.api.location.type === 'edge' ||
2503
- target === 'center') {
2504
- panel = this.createPanel(options, referenceGroup);
2505
- referenceGroup.model.openPanel(panel, {
2506
- skipSetActive: options.inactive,
2507
- skipSetGroupActive: options.inactive,
2508
- index: index,
2509
- });
2510
- referenceGroup.api.setSize({
2511
- width: initial === null || initial === void 0 ? void 0 : initial.width,
2512
- height: initial === null || initial === void 0 ? void 0 : initial.height,
2513
- });
2514
- if (!options.inactive) {
2515
- this.doSetGroupAndPanelActive(referenceGroup);
2516
- }
2517
- }
2518
- else {
2519
- var location_1 = (0, gridview_1.getGridLocation)(referenceGroup.element);
2520
- var relativeLocation = (0, gridview_1.getRelativeLocation)(this.gridview.orientation, location_1, target);
2521
- var group = this.createGroupAtLocation(relativeLocation, this.orientationAtLocation(relativeLocation) ===
2522
- splitview_1.Orientation.VERTICAL
2523
- ? initial === null || initial === void 0 ? void 0 : initial.height
2524
- : initial === null || initial === void 0 ? void 0 : initial.width);
2525
- panel = this.createPanel(options, group);
2526
- group.model.openPanel(panel, {
2527
- skipSetActive: options.inactive,
2528
- skipSetGroupActive: options.inactive,
2529
- index: index,
2530
- });
2531
- if (!options.inactive) {
2532
- this.doSetGroupAndPanelActive(group);
2533
- }
2534
- }
2535
- }
2536
- else if (options.floating) {
2537
- var group = this.createGroup();
2538
- this._onDidAddGroup.fire(group);
2539
- var coordinates = typeof options.floating === 'object' &&
2540
- options.floating !== null
2541
- ? options.floating
2542
- : {};
2543
- this.addFloatingGroup(group, __assign(__assign({}, coordinates), { inDragMode: false, skipRemoveGroup: true, skipActiveGroup: true }));
2544
- panel = this.createPanel(options, group);
2545
- group.model.openPanel(panel, {
2546
- skipSetActive: options.inactive,
2547
- skipSetGroupActive: options.inactive,
2548
- index: index,
2549
- });
2550
- }
2551
- else {
2552
- var group = this.createGroupAtLocation([0], this.gridview.orientation === splitview_1.Orientation.VERTICAL
2553
- ? initial === null || initial === void 0 ? void 0 : initial.height
2554
- : initial === null || initial === void 0 ? void 0 : initial.width);
2555
- panel = this.createPanel(options, group);
2556
- group.model.openPanel(panel, {
2557
- skipSetActive: options.inactive,
2558
- skipSetGroupActive: options.inactive,
2559
- index: index,
2560
- });
2561
- if (!options.inactive) {
2562
- this.doSetGroupAndPanelActive(group);
2563
- }
2564
- }
2565
- return panel;
2566
- };
2567
- DockviewComponent.prototype.removePanel = function (panel, options) {
2568
- var _this = this;
2569
- this.mutation('remove', function () {
2570
- var _a;
2571
- return _this._doRemovePanel(panel, {
2572
- removeEmptyGroup: (_a = options === null || options === void 0 ? void 0 : options.removeEmptyGroup) !== null && _a !== void 0 ? _a : true,
2573
- skipDispose: options === null || options === void 0 ? void 0 : options.skipDispose,
2574
- skipSetActiveGroup: options === null || options === void 0 ? void 0 : options.skipSetActiveGroup,
2575
- });
2576
- });
2577
- };
2578
- DockviewComponent.prototype._doRemovePanel = function (panel, options) {
2579
- var group = panel.group;
2580
- if (!group) {
2581
- throw new Error("dockview: cannot remove panel ".concat(panel.id, ". it's missing a group."));
2582
- }
2583
- group.model.removePanel(panel, {
2584
- skipSetActiveGroup: options.skipSetActiveGroup,
2585
- });
2586
- if (!options.skipDispose) {
2587
- panel.group.model.renderContainer.detatch(panel);
2588
- panel.dispose();
2589
- }
2590
- if (group.size === 0 && options.removeEmptyGroup) {
2591
- this.removeGroup(group, { skipActive: options.skipSetActiveGroup });
2592
- }
2593
- };
2594
- DockviewComponent.prototype.createWatermarkComponent = function () {
2595
- if (this.options.createWatermarkComponent) {
2596
- return this.options.createWatermarkComponent();
2597
- }
2598
- return new watermark_1.Watermark();
2599
- };
2600
- DockviewComponent.prototype.addGroup = function (options) {
2601
- var _this = this;
2602
- return this.mutation('add', function () { return _this._doAddGroup(options); });
2603
- };
2604
- DockviewComponent.prototype._doAddGroup = function (options) {
2605
- var _a, _b, _c;
2606
- if (options) {
2607
- var referenceGroup = void 0;
2608
- if ((0, options_1.isGroupOptionsWithPanel)(options)) {
2609
- var referencePanel = typeof options.referencePanel === 'string'
2610
- ? this.panels.find(function (panel) { return panel.id === options.referencePanel; })
2611
- : options.referencePanel;
2612
- var referencePanelId = typeof options.referencePanel === 'string'
2613
- ? options.referencePanel
2614
- : (_a = options.referencePanel) === null || _a === void 0 ? void 0 : _a.id;
2615
- if (!referencePanel) {
2616
- throw new Error("dockview: reference panel ".concat(referencePanelId, " does not exist"));
2617
- }
2618
- referenceGroup = this.findGroup(referencePanel);
2619
- if (!referenceGroup) {
2620
- throw new Error("dockview: reference group for reference panel ".concat(referencePanelId, " does not exist"));
2621
- }
2622
- }
2623
- else if ((0, options_1.isGroupOptionsWithGroup)(options)) {
2624
- referenceGroup =
2625
- typeof options.referenceGroup === 'string'
2626
- ? (_b = this._groups.get(options.referenceGroup)) === null || _b === void 0 ? void 0 : _b.value
2627
- : options.referenceGroup;
2628
- if (!referenceGroup) {
2629
- var referenceId = typeof options.referenceGroup === 'string'
2630
- ? options.referenceGroup
2631
- : (_c = options.referenceGroup) === null || _c === void 0 ? void 0 : _c.id;
2632
- throw new Error("dockview: reference group ".concat(referenceId, " does not exist"));
2633
- }
2634
- }
2635
- else {
2636
- var group_1 = this.orthogonalize((0, droptarget_1.directionToPosition)(options.direction), options);
2637
- if (!options.skipSetActive) {
2638
- this.doSetGroupAndPanelActive(group_1);
2639
- }
2640
- return group_1;
2641
- }
2642
- var target = (0, baseComponentGridview_1.toTarget)(options.direction || 'within');
2643
- var location_2 = (0, gridview_1.getGridLocation)(referenceGroup.element);
2644
- var relativeLocation = (0, gridview_1.getRelativeLocation)(this.gridview.orientation, location_2, target);
2645
- var group = this.createGroup(options);
2646
- var size = this.getLocationOrientation(relativeLocation) ===
2647
- splitview_1.Orientation.VERTICAL
2648
- ? options.initialHeight
2649
- : options.initialWidth;
2650
- this.doAddGroup(group, relativeLocation, size);
2651
- if (!options.skipSetActive) {
2652
- this.doSetGroupAndPanelActive(group);
2653
- }
2654
- return group;
2655
- }
2656
- else {
2657
- var group = this.createGroup(options);
2658
- this.doAddGroup(group);
2659
- this.doSetGroupAndPanelActive(group);
2660
- return group;
2661
- }
2662
- };
2663
- DockviewComponent.prototype.getLocationOrientation = function (location) {
2664
- return location.length % 2 == 0 &&
2665
- this.gridview.orientation === splitview_1.Orientation.HORIZONTAL
2666
- ? splitview_1.Orientation.HORIZONTAL
2667
- : splitview_1.Orientation.VERTICAL;
2668
- };
2669
- DockviewComponent.prototype.removeGroup = function (group, options) {
2670
- var _this = this;
2671
- this.mutation('remove', function () { return _this.doRemoveGroup(group, options); });
2672
- };
2673
- /**
2674
- * Detach a single group from the nested gridview of its floating / popout
2675
- * window, keeping the window and its remaining members alive, and reassign
2676
- * the window's anchor if the detached group was it.
2677
- *
2678
- * @returns `true` if the group was detached from a multi-member window;
2679
- * `false` if `group` is not in a nested window, or is the window's only
2680
- * member — in which case the caller is responsible for disposing the whole
2681
- * window.
2682
- */
2683
- DockviewComponent.prototype.detachFromNestedWindow = function (group) {
2684
- var _a, _b;
2685
- var floating = (_a = this._floatingGroupService) === null || _a === void 0 ? void 0 : _a.findByGroup(group);
2686
- if (floating) {
2687
- var members = this.nestedWindowMembers(group);
2688
- if (members.length <= 1) {
2689
- return false;
2690
- }
2691
- floating.gridview.remove(group);
2692
- if (floating.group === group) {
2693
- // The anchor left; promote a remaining member.
2694
- floating.setAnchorGroup(members.find(function (m) { return m !== group; }));
2695
- }
2696
- return true;
2697
- }
2698
- var popout = (_b = this._popoutWindowService) === null || _b === void 0 ? void 0 : _b.findByGroup(group);
2699
- if (popout) {
2700
- var members = this.nestedWindowMembers(group);
2701
- if (members.length <= 1) {
2702
- return false;
2703
- }
2704
- popout.gridview.remove(group);
2705
- if (popout.popoutGroup === group) {
2706
- // The anchor left; promote a remaining member.
2707
- popout.popoutGroup = members.find(function (m) { return m !== group; });
2708
- }
2709
- return true;
2710
- }
2711
- return false;
2712
- };
2713
- /**
2714
- * Dispose a group and forget it: remove it from `_groups` and fire the
2715
- * removed event.
2716
- */
2717
- DockviewComponent.prototype.disposeGroupRecord = function (group) {
2718
- group.dispose();
2719
- this._groups.delete(group.id);
2720
- this._onDidRemoveGroup.fire(group);
2721
- };
2722
- /**
2723
- * When `removed` was the active group, fall the active selection back to
2724
- * the first remaining group (or clear it when none remain).
2725
- */
2726
- DockviewComponent.prototype.activateFallbackGroupIfRemoved = function (removed, skipActive) {
2727
- if (!skipActive && this._activeGroup === removed) {
2728
- var groups = Array.from(this._groups.values());
2729
- this.doSetGroupAndPanelActive(groups.length > 0 ? groups[0].value : undefined);
2730
- }
2731
- };
2732
- DockviewComponent.prototype.doRemoveGroup = function (group, options) {
2733
- var e_27, _a;
2734
- var _b, _c, _d, _e, _f;
2735
- // Edge groups are permanent structural elements - never remove them from the layout
2736
- if ((_b = this._edgeGroupService) === null || _b === void 0 ? void 0 : _b.includes(group)) {
2737
- return group;
2738
- }
2739
- var panels = __spreadArray([], __read(group.panels), false); // reassign since group panels will mutate
2740
- if (!(options === null || options === void 0 ? void 0 : options.skipDispose)) {
2741
- try {
2742
- for (var panels_2 = __values(panels), panels_2_1 = panels_2.next(); !panels_2_1.done; panels_2_1 = panels_2.next()) {
2743
- var panel = panels_2_1.value;
2744
- this.removePanel(panel, {
2745
- removeEmptyGroup: false,
2746
- skipDispose: (_c = options === null || options === void 0 ? void 0 : options.skipDispose) !== null && _c !== void 0 ? _c : false,
2747
- });
2748
- }
2749
- }
2750
- catch (e_27_1) { e_27 = { error: e_27_1 }; }
2751
- finally {
2752
- try {
2753
- if (panels_2_1 && !panels_2_1.done && (_a = panels_2.return)) _a.call(panels_2);
2754
- }
2755
- finally { if (e_27) throw e_27.error; }
2756
- }
2757
- }
2758
- var activePanel = this.activePanel;
2759
- if (group.api.location.type === 'floating') {
2760
- var floatingGroup = (_d = this._floatingGroupService) === null || _d === void 0 ? void 0 : _d.findByGroup(group);
2761
- if (!floatingGroup) {
2762
- throw new Error('dockview: failed to find floating group');
2763
- }
2764
- if (this.detachFromNestedWindow(group)) {
2765
- // The floating window hosts other groups and stays alive —
2766
- // finalize just this group.
2767
- if (options === null || options === void 0 ? void 0 : options.skipDispose) {
2768
- // Relocation: reset location so the destination root can
2769
- // re-tag it.
2770
- group.model.location = { type: 'grid' };
2771
- }
2772
- else {
2773
- this.disposeGroupRecord(group);
2774
- }
2775
- this.activateFallbackGroupIfRemoved(group, options === null || options === void 0 ? void 0 : options.skipActive);
2776
- return group;
2777
- }
2778
- // Last group leaving — dispose the whole floating window.
2779
- if (!(options === null || options === void 0 ? void 0 : options.skipDispose)) {
2780
- this.disposeGroupRecord(group);
2781
- }
2782
- // floatingGroup.dispose() removes itself from the service array
2783
- floatingGroup.dispose();
2784
- this.activateFallbackGroupIfRemoved(group, options === null || options === void 0 ? void 0 : options.skipActive);
2785
- return group;
2786
- }
2787
- if (group.api.location.type === 'popout') {
2788
- var selectedGroup = (_e = this._popoutWindowService) === null || _e === void 0 ? void 0 : _e.findByGroup(group);
2789
- if (!selectedGroup) {
2790
- throw new Error('dockview: failed to find popout group');
2791
- }
2792
- if (this.detachFromNestedWindow(group)) {
2793
- // The popout window hosts other groups and stays alive —
2794
- // finalize just this group.
2795
- if (options === null || options === void 0 ? void 0 : options.skipDispose) {
2796
- // Relocation: reset location so the destination root can
2797
- // re-tag it.
2798
- group.model.location = { type: 'grid' };
2799
- }
2800
- else {
2801
- this.disposeGroupRecord(group);
2802
- }
2803
- this.activateFallbackGroupIfRemoved(group, options === null || options === void 0 ? void 0 : options.skipActive);
2804
- return group;
2805
- }
2806
- // Last group leaving — tear the whole popout window down.
2807
- if (!(options === null || options === void 0 ? void 0 : options.skipDispose)) {
2808
- if (!(options === null || options === void 0 ? void 0 : options.skipPopoutAssociated)) {
2809
- var refGroup = selectedGroup.referenceGroup
2810
- ? this.getPanel(selectedGroup.referenceGroup)
2811
- : undefined;
2812
- if ((refGroup === null || refGroup === void 0 ? void 0 : refGroup.panels.length) === 0) {
2813
- this.removeGroup(refGroup);
2814
- }
2815
- }
2816
- selectedGroup.popoutGroup.dispose();
2817
- this._groups.delete(group.id);
2818
- this._onDidRemoveGroup.fire(group);
2819
- }
2820
- (_f = this._popoutWindowService) === null || _f === void 0 ? void 0 : _f.remove(selectedGroup);
2821
- var removedGroup = selectedGroup.disposable.dispose();
2822
- if (!(options === null || options === void 0 ? void 0 : options.skipPopoutReturn) && removedGroup) {
2823
- this.doAddGroup(removedGroup, [0]);
2824
- this.doSetGroupAndPanelActive(removedGroup);
2825
- }
2826
- this.activateFallbackGroupIfRemoved(group, options === null || options === void 0 ? void 0 : options.skipActive);
2827
- return selectedGroup.popoutGroup;
2828
- }
2829
- // A `grid`-location group whose element isn't actually in the gridview
2830
- // is an orphan — e.g. a popout-destined group created during fromJSON
2831
- // whose window hasn't opened yet, swept up by clear()/a re-entrant
2832
- // fromJSON. `gridview.remove()` would throw "Invalid grid element", so
2833
- // dispose it directly.
2834
- if (!this.gridview.element.contains(group.element)) {
2835
- if (!(options === null || options === void 0 ? void 0 : options.skipDispose)) {
2836
- var item = this._groups.get(group.id);
2837
- item === null || item === void 0 ? void 0 : item.disposable.dispose();
2838
- this.disposeGroupRecord(group);
2839
- }
2840
- this.activateFallbackGroupIfRemoved(group, options === null || options === void 0 ? void 0 : options.skipActive);
2841
- return group;
2842
- }
2843
- var re = _super.prototype.doRemoveGroup.call(this, group, options);
2844
- if (!(options === null || options === void 0 ? void 0 : options.skipActive)) {
2845
- if (this.activePanel !== activePanel) {
2846
- this.fireActivePanelChange(this.activePanel);
2847
- }
2848
- }
2849
- return re;
2850
- };
2851
- DockviewComponent.prototype.debouncedUpdateAllPositions = function () {
2852
- var _this = this;
2853
- if (this._updatePositionsFrameId !== undefined) {
2854
- cancelAnimationFrame(this._updatePositionsFrameId);
2855
- }
2856
- this._updatePositionsFrameId = requestAnimationFrame(function () {
2857
- var e_28, _a;
2858
- var _b, _c;
2859
- _this._updatePositionsFrameId = undefined;
2860
- _this.overlayRenderContainer.updateAllPositions();
2861
- try {
2862
- // Popout windows have their own render containers; reposition those
2863
- // too so panels moved/split within a popout are laid out (the main
2864
- // container only covers grid + floating, which share it).
2865
- for (var _d = __values((_c = (_b = _this._popoutWindowService) === null || _b === void 0 ? void 0 : _b.entries) !== null && _c !== void 0 ? _c : []), _e = _d.next(); !_e.done; _e = _d.next()) {
2866
- var entry = _e.value;
2867
- entry.overlayRenderContainer.updateAllPositions();
2868
- }
2869
- }
2870
- catch (e_28_1) { e_28 = { error: e_28_1 }; }
2871
- finally {
2872
- try {
2873
- if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
2874
- }
2875
- finally { if (e_28) throw e_28.error; }
2876
- }
2877
- });
2878
- };
2879
- DockviewComponent.prototype.movingLock = function (func) {
2880
- var isMoving = this._moving;
2881
- try {
2882
- this._moving = true;
2883
- return func();
2884
- }
2885
- finally {
2886
- this._moving = isMoving;
2887
- }
2888
- };
2889
- /**
2890
- * Bracket a structural mutation with `onWillMutateLayout` /
2891
- * `onDidMutateLayout`. Re-entrant: nested calls (a compound operation such
2892
- * as a drag that relocates a panel) join the outermost transaction, so the
2893
- * events fire exactly once around the whole operation. `kind` reflects the
2894
- * outermost mutation.
2895
- */
2896
- DockviewComponent.prototype.mutation = function (kind, func) {
2897
- var outer = this._mutationDepth === 0;
2898
- var origin = this._origin;
2899
- if (outer) {
2900
- this._onWillMutateLayout.fire({ kind: kind, origin: origin });
2901
- }
2902
- this._mutationDepth++;
2903
- try {
2904
- return func();
2905
- }
2906
- finally {
2907
- this._mutationDepth--;
2908
- if (outer) {
2909
- this._onDidMutateLayout.fire({ kind: kind, origin: origin });
2910
- }
2911
- }
2912
- };
2913
- /**
2914
- * The origin of the operation currently in progress (`'user'` by default).
2915
- * Read inside a `mutation()` or active-panel change to learn whether the
2916
- * change was driven by application code (via the {@link DockviewApi}) or a
2917
- * user gesture.
2918
- */
2919
- DockviewComponent.prototype.currentOrigin = function () {
2920
- return this._origin;
2921
- };
2922
- /**
2923
- * Run `func` with the operation origin set to `origin`, restoring the
2924
- * previous value afterwards. Used by the DockviewApi boundary to tag
2925
- * programmatic operations as `'api'`, and by user-gesture handlers to tag
2926
- * `'user'`. Only the outermost caller sets the origin — a nested call (or a
2927
- * call made while a mutation is already in flight) keeps whatever the
2928
- * enclosing operation established, so the trigger always wins.
2929
- */
2930
- DockviewComponent.prototype.withOrigin = function (origin, func) {
2931
- if (this._originDepth > 0 || this._mutationDepth > 0) {
2932
- return func();
2933
- }
2934
- var previous = this._origin;
2935
- this._origin = origin;
2936
- this._originDepth++;
2937
- try {
2938
- return func();
2939
- }
2940
- finally {
2941
- this._originDepth--;
2942
- this._origin = previous;
2943
- }
2944
- };
2945
- /**
2946
- * Fire `onDidActivePanelChange` with the panel and the current operation
2947
- * {@link DockviewOrigin}. Callers keep their own dedupe guards.
2948
- */
2949
- DockviewComponent.prototype.fireActivePanelChange = function (panel) {
2950
- this._onDidActivePanelChange.fire({ panel: panel, origin: this._origin });
2951
- };
2952
- DockviewComponent.prototype.moveGroupOrPanel = function (options) {
2953
- var _this = this;
2954
- this.mutation('move', function () { return _this._doMoveGroupOrPanel(options); });
2955
- };
2956
- DockviewComponent.prototype._doMoveGroupOrPanel = function (options) {
2957
- var _this = this;
2958
- var _a, _b;
2959
- var destinationGroup = options.to.group;
2960
- var sourceGroupId = options.from.groupId;
2961
- var sourceItemId = options.from.panelId;
2962
- var destinationTarget = options.to.position;
2963
- var destinationIndex = options.to.index;
2964
- var sourceGroup = sourceGroupId
2965
- ? (_a = this._groups.get(sourceGroupId)) === null || _a === void 0 ? void 0 : _a.value
2966
- : undefined;
2967
- if (!sourceGroup) {
2968
- throw new Error("dockview: Failed to find group id ".concat(sourceGroupId));
2969
- }
2970
- if (sourceItemId === undefined) {
2971
- if (options.from.tabGroupId) {
2972
- /**
2973
- * Moving a tab group (subset of panels) into another group
2974
- */
2975
- this.moveTabGroupToGroup({
2976
- sourceGroup: sourceGroup,
2977
- tabGroupId: options.from.tabGroupId,
2978
- destinationGroup: destinationGroup,
2979
- destinationTarget: destinationTarget,
2980
- destinationIndex: destinationIndex,
2981
- skipSetActive: options.skipSetActive,
2982
- keepEmptyGroups: options.keepEmptyGroups,
2983
- });
2984
- }
2985
- else {
2986
- /**
2987
- * Moving an entire group into another group
2988
- */
2989
- this.moveGroup({
2990
- from: { group: sourceGroup },
2991
- to: {
2992
- group: destinationGroup,
2993
- position: destinationTarget,
2994
- },
2995
- skipSetActive: options.skipSetActive,
2996
- });
2997
- }
2998
- return;
2999
- }
3000
- if (!destinationTarget || destinationTarget === 'center') {
3001
- /**
3002
- * Dropping a panel within another group
3003
- */
3004
- var removedPanel_1 = this.movingLock(function () {
3005
- return sourceGroup.model.removePanel(sourceItemId, {
3006
- skipSetActive: false,
3007
- skipSetActiveGroup: true,
3008
- });
3009
- });
3010
- if (!removedPanel_1) {
3011
- throw new Error("dockview: No panel with id ".concat(sourceItemId));
3012
- }
3013
- if (!options.keepEmptyGroups && sourceGroup.model.size === 0) {
3014
- // remove the group and do not set a new group as active
3015
- this.doRemoveGroup(sourceGroup, { skipActive: true });
3016
- }
3017
- // Check if destination group is empty - if so, force render the component
3018
- var isDestinationGroupEmpty_1 = destinationGroup.model.size === 0;
3019
- this.movingLock(function () {
3020
- var _a;
3021
- return destinationGroup.model.openPanel(removedPanel_1, {
3022
- index: destinationIndex,
3023
- skipSetActive: ((_a = options.skipSetActive) !== null && _a !== void 0 ? _a : false) &&
3024
- !isDestinationGroupEmpty_1,
3025
- skipSetGroupActive: true,
3026
- });
3027
- });
3028
- if (!options.skipSetActive) {
3029
- this.doSetGroupAndPanelActive(destinationGroup);
3030
- }
3031
- this._onDidMovePanel.fire({
3032
- panel: removedPanel_1,
3033
- from: sourceGroup,
3034
- });
3035
- }
3036
- else {
3037
- /**
3038
- * Dropping a panel to the extremities of a group which will place that panel
3039
- * into an adjacent group
3040
- */
3041
- // The destination group may live in the main grid or in a floating
3042
- // window's nested gridview — resolve which root we are dropping
3043
- // into so locations/orientation are computed against it.
3044
- var destinationGridview_1 = this.getGridviewForGroup(destinationGroup);
3045
- var referenceLocation = (0, gridview_1.getGridLocation)(destinationGroup.element);
3046
- var targetLocation = (0, gridview_1.getRelativeLocation)(destinationGridview_1.orientation, referenceLocation, destinationTarget);
3047
- if (sourceGroup.size < 2) {
3048
- /**
3049
- * If we are moving from a group which only has one panel left we will consider
3050
- * moving the group itself rather than moving the panel into a newly created group
3051
- */
3052
- var _c = __read((0, array_1.tail)(targetLocation), 2), targetParentLocation = _c[0], to = _c[1];
3053
- if (sourceGroup.api.location.type === 'grid' &&
3054
- destinationGridview_1 === this.gridview) {
3055
- var sourceLocation = (0, gridview_1.getGridLocation)(sourceGroup.element);
3056
- var _d = __read((0, array_1.tail)(sourceLocation), 2), sourceParentLocation = _d[0], from = _d[1];
3057
- if ((0, array_1.sequenceEquals)(sourceParentLocation, targetParentLocation)) {
3058
- // special case when 'swapping' two views within same grid location
3059
- // if a group has one tab - we are essentially moving the 'group'
3060
- // which is equivalent to swapping two views in this case
3061
- this.gridview.moveView(sourceParentLocation, from, to);
3062
- this._onDidMovePanel.fire({
3063
- panel: this.getGroupPanel(sourceItemId),
3064
- from: sourceGroup,
3065
- });
3066
- return;
3067
- }
3068
- }
3069
- if (sourceGroup.api.location.type === 'popout' &&
3070
- this.nestedWindowMembers(sourceGroup).length <= 1) {
3071
- /**
3072
- * the source group is the only group in a popout window and
3073
- * has a single panel
3074
- *
3075
- * 1. remove the panel from the group without triggering any events
3076
- * 2. remove the popout group — this may cascade-remove the empty
3077
- * reference group it left behind in the main grid (see
3078
- * doRemoveGroup for popout groups), which can shift grid indices
3079
- * 3. recompute the target location now that the grid is stable
3080
- * 4. create a new group at the recomputed location and add that panel
3081
- *
3082
- * Multi-group popout windows fall through to the generic
3083
- * detach-and-re-add path so the window stays alive.
3084
- */
3085
- var popoutGroup_1 = (_b = this._popoutWindowService) === null || _b === void 0 ? void 0 : _b.findByGroup(sourceGroup);
3086
- if (!popoutGroup_1) {
3087
- return;
3088
- }
3089
- var removedPanel_2 = this.movingLock(function () {
3090
- return popoutGroup_1.popoutGroup.model.removePanel(popoutGroup_1.popoutGroup.panels[0], {
3091
- skipSetActive: true,
3092
- skipSetActiveGroup: true,
3093
- });
3094
- });
3095
- this.doRemoveGroup(sourceGroup, { skipActive: true });
3096
- var updatedTargetLocation = (0, gridview_1.getRelativeLocation)(destinationGridview_1.orientation, (0, gridview_1.getGridLocation)(destinationGroup.element), destinationTarget);
3097
- var newGroup_1 = this.createGroupAtLocation(updatedTargetLocation, undefined, undefined, destinationGridview_1);
3098
- this.movingLock(function () {
3099
- return newGroup_1.model.openPanel(removedPanel_2, {
3100
- skipSetActive: true,
3101
- });
3102
- });
3103
- this.doSetGroupAndPanelActive(newGroup_1);
3104
- this._onDidMovePanel.fire({
3105
- panel: this.getGroupPanel(sourceItemId),
3106
- from: sourceGroup,
3107
- });
3108
- return;
3109
- }
3110
- if (sourceGroup.api.location.type === 'edge') {
3111
- /**
3112
- * Edge groups are permanent structural elements — never move the
3113
- * group itself. Instead extract the panel and create a new grid group,
3114
- * leaving the edge slot intact (same behaviour as the size >= 2 path).
3115
- */
3116
- var removedPanel_3 = this.movingLock(function () {
3117
- return sourceGroup.model.removePanel(sourceItemId, {
3118
- skipSetActive: false,
3119
- skipSetActiveGroup: true,
3120
- });
3121
- });
3122
- if (!removedPanel_3) {
3123
- throw new Error("dockview: No panel with id ".concat(sourceItemId));
3124
- }
3125
- var newGroup_2 = this.createGroupAtLocation(targetLocation, undefined, undefined, destinationGridview_1);
3126
- this.movingLock(function () {
3127
- return newGroup_2.model.openPanel(removedPanel_3, {
3128
- skipSetGroupActive: true,
3129
- });
3130
- });
3131
- this.doSetGroupAndPanelActive(newGroup_2);
3132
- this._onDidMovePanel.fire({
3133
- panel: removedPanel_3,
3134
- from: sourceGroup,
3135
- });
3136
- return;
3137
- }
3138
- // source group will become empty so delete the group
3139
- var targetGroup_1 = this.movingLock(function () {
3140
- return _this.doRemoveGroup(sourceGroup, {
3141
- skipActive: true,
3142
- skipDispose: true,
3143
- });
3144
- });
3145
- // after deleting the group we need to re-evaulate the ref location
3146
- var updatedReferenceLocation = (0, gridview_1.getGridLocation)(destinationGroup.element);
3147
- var location_3 = (0, gridview_1.getRelativeLocation)(destinationGridview_1.orientation, updatedReferenceLocation, destinationTarget);
3148
- this.movingLock(function () {
3149
- return _this.doAddGroup(targetGroup_1, location_3, undefined, destinationGridview_1);
3150
- });
3151
- this.setGroupLocationForRoot(targetGroup_1, destinationGridview_1);
3152
- this.doSetGroupAndPanelActive(targetGroup_1);
3153
- this._onDidMovePanel.fire({
3154
- panel: this.getGroupPanel(sourceItemId),
3155
- from: sourceGroup,
3156
- });
3157
- }
3158
- else {
3159
- /**
3160
- * The group we are removing from has many panels, we need to remove the panels we are moving,
3161
- * create a new group, add the panels to that new group and add the new group in an appropiate position
3162
- */
3163
- var removedPanel_4 = this.movingLock(function () {
3164
- return sourceGroup.model.removePanel(sourceItemId, {
3165
- skipSetActive: false,
3166
- skipSetActiveGroup: true,
3167
- });
3168
- });
3169
- if (!removedPanel_4) {
3170
- throw new Error("dockview: No panel with id ".concat(sourceItemId));
3171
- }
3172
- var dropLocation = (0, gridview_1.getRelativeLocation)(destinationGridview_1.orientation, referenceLocation, destinationTarget);
3173
- var group_2 = this.createGroupAtLocation(dropLocation, undefined, undefined, destinationGridview_1);
3174
- this.movingLock(function () {
3175
- return group_2.model.openPanel(removedPanel_4, {
3176
- skipSetGroupActive: true,
3177
- });
3178
- });
3179
- this.doSetGroupAndPanelActive(group_2);
3180
- this._onDidMovePanel.fire({
3181
- panel: removedPanel_4,
3182
- from: sourceGroup,
3183
- });
3184
- }
3185
- }
3186
- };
3187
- DockviewComponent.prototype.moveTabGroupToGroup = function (options) {
3188
- var _this = this;
3189
- var sourceGroup = options.sourceGroup, tabGroupId = options.tabGroupId, destinationGroup = options.destinationGroup, destinationTarget = options.destinationTarget, destinationIndex = options.destinationIndex;
3190
- var tabGroup = sourceGroup.model
3191
- .getTabGroups()
3192
- .find(function (tg) { return tg.id === tabGroupId; });
3193
- if (!tabGroup || tabGroup.panelIds.length === 0) {
3194
- return;
3195
- }
3196
- // Snapshot tab group metadata before removing panels
3197
- var label = tabGroup.label;
3198
- var color = tabGroup.color;
3199
- var collapsed = tabGroup.collapsed;
3200
- var componentParams = tabGroup.componentParams;
3201
- var panelIds = __spreadArray([], __read(tabGroup.panelIds), false);
3202
- // Capture the destination's grid location BEFORE potentially
3203
- // removing the source group, in case source === destination and
3204
- // the source becomes empty after panel removal.
3205
- var referenceLocation = destinationTarget && destinationTarget !== 'center'
3206
- ? (0, gridview_1.getGridLocation)(destinationGroup.element)
3207
- : undefined;
3208
- // Remove panels from the source group
3209
- var removedPanels = this.movingLock(function () {
3210
- return panelIds
3211
- .map(function (pid) {
3212
- return sourceGroup.model.removePanel(pid, {
3213
- skipSetActive: false,
3214
- skipSetActiveGroup: true,
3215
- });
3216
- })
3217
- .filter(function (p) { return p !== undefined; });
3218
- });
3219
- if (removedPanels.length === 0) {
3220
- return;
3221
- }
3222
- var addPanelsToGroup = function (targetGroup) {
3223
- var e_29, _a, e_30, _b;
3224
- _this.movingLock(function () {
3225
- var e_31, _a;
3226
- try {
3227
- for (var removedPanels_3 = __values(removedPanels), removedPanels_3_1 = removedPanels_3.next(); !removedPanels_3_1.done; removedPanels_3_1 = removedPanels_3.next()) {
3228
- var panel = removedPanels_3_1.value;
3229
- targetGroup.model.openPanel(panel, {
3230
- index: destinationIndex,
3231
- skipSetActive: true,
3232
- skipSetGroupActive: true,
3233
- });
3234
- }
3235
- }
3236
- catch (e_31_1) { e_31 = { error: e_31_1 }; }
3237
- finally {
3238
- try {
3239
- if (removedPanels_3_1 && !removedPanels_3_1.done && (_a = removedPanels_3.return)) _a.call(removedPanels_3);
3240
- }
3241
- finally { if (e_31) throw e_31.error; }
3242
- }
3243
- });
3244
- // Recreate the tab group in the destination
3245
- var newTabGroup = targetGroup.model.createTabGroup({
3246
- label: label,
3247
- color: color,
3248
- collapsed: collapsed,
3249
- componentParams: componentParams,
3250
- });
3251
- try {
3252
- for (var removedPanels_1 = __values(removedPanels), removedPanels_1_1 = removedPanels_1.next(); !removedPanels_1_1.done; removedPanels_1_1 = removedPanels_1.next()) {
3253
- var panel = removedPanels_1_1.value;
3254
- targetGroup.model.addPanelToTabGroup(newTabGroup.id, panel.id);
3255
- }
3256
- }
3257
- catch (e_29_1) { e_29 = { error: e_29_1 }; }
3258
- finally {
3259
- try {
3260
- if (removedPanels_1_1 && !removedPanels_1_1.done && (_a = removedPanels_1.return)) _a.call(removedPanels_1);
3261
- }
3262
- finally { if (e_29) throw e_29.error; }
3263
- }
3264
- if (!options.skipSetActive) {
3265
- _this.doSetGroupAndPanelActive(targetGroup);
3266
- }
3267
- try {
3268
- for (var removedPanels_2 = __values(removedPanels), removedPanels_2_1 = removedPanels_2.next(); !removedPanels_2_1.done; removedPanels_2_1 = removedPanels_2.next()) {
3269
- var panel = removedPanels_2_1.value;
3270
- _this._onDidMovePanel.fire({
3271
- panel: panel,
3272
- from: sourceGroup,
3273
- });
3274
- }
3275
- }
3276
- catch (e_30_1) { e_30 = { error: e_30_1 }; }
3277
- finally {
3278
- try {
3279
- if (removedPanels_2_1 && !removedPanels_2_1.done && (_b = removedPanels_2.return)) _b.call(removedPanels_2);
3280
- }
3281
- finally { if (e_30) throw e_30.error; }
3282
- }
3283
- };
3284
- var targetGroup;
3285
- if (!destinationTarget ||
3286
- destinationTarget === 'center' ||
3287
- !referenceLocation) {
3288
- targetGroup = destinationGroup;
3289
- }
3290
- else {
3291
- var dropLocation = (0, gridview_1.getRelativeLocation)(this.gridview.orientation, referenceLocation, destinationTarget);
3292
- targetGroup = this.createGroupAtLocation(dropLocation);
3293
- }
3294
- // Remove the source group if it became empty. We compare against
3295
- // the actual targetGroup (which is a freshly-created group for
3296
- // edge drops) rather than the originally-passed destinationGroup,
3297
- // so a tab-group drag onto its own group's edge still cleans up
3298
- // the now-empty source.
3299
- if (!options.keepEmptyGroups &&
3300
- sourceGroup.model.size === 0 &&
3301
- sourceGroup !== targetGroup) {
3302
- this.doRemoveGroup(sourceGroup, { skipActive: true });
3303
- }
3304
- addPanelsToGroup(targetGroup);
3305
- };
3306
- DockviewComponent.prototype.moveGroup = function (options) {
3307
- var _this = this;
3308
- this.mutation('move', function () { return _this._doMoveGroup(options); });
3309
- };
3310
- // Bracket maximize/restore as a 'maximize' transaction. The maximized node
3311
- // is serialized by the gridview (`SerializedGridview.maximizedNode`), so
3312
- // the state round-trips through toJSON/fromJSON and is restorable on undo.
3313
- // When the exit is a side-effect of another bracketed operation (e.g. a
3314
- // move that activates a different group) the depth counter folds it in.
3315
- DockviewComponent.prototype.maximizeGroup = function (panel) {
3316
- var _this = this;
3317
- this.mutation('maximize', function () { return _super.prototype.maximizeGroup.call(_this, panel); });
3318
- };
3319
- DockviewComponent.prototype.exitMaximizedGroup = function () {
3320
- var _this = this;
3321
- this.mutation('maximize', function () { return _super.prototype.exitMaximizedGroup.call(_this); });
3322
- };
3323
- DockviewComponent.prototype._doMoveGroup = function (options) {
3324
- var e_32, _a, e_33, _b, e_34, _c, e_35, _d;
3325
- var _this = this;
3326
- var _e, _f, _g;
3327
- var from = options.from.group;
3328
- var to = options.to.group;
3329
- var target = options.to.position;
3330
- // The group whose panels end up at the target. For non-edge moves
3331
- // we relocate `from` itself; for edge moves we move panels into a
3332
- // freshly created group so the edge slot stays anchored.
3333
- var source = from;
3334
- if (target === 'center') {
3335
- var activePanel_1 = from.activePanel;
3336
- // Snapshot tab group metadata before removing panels so we
3337
- // can recreate the tab groups in the destination after the
3338
- // panels are merged in.
3339
- var tabGroupSnapshots = from.model.getTabGroups().map(function (tg) { return ({
3340
- label: tg.label,
3341
- color: tg.color,
3342
- collapsed: tg.collapsed,
3343
- componentParams: tg.componentParams,
3344
- panelIds: __spreadArray([], __read(tg.panelIds), false),
3345
- }); });
3346
- var panels_3 = this.movingLock(function () {
3347
- return __spreadArray([], __read(from.panels), false).map(function (p) {
3348
- return from.model.removePanel(p.id, {
3349
- skipSetActive: true,
3350
- });
3351
- });
3352
- });
3353
- if ((from === null || from === void 0 ? void 0 : from.model.size) === 0) {
3354
- this.doRemoveGroup(from, { skipActive: true });
3355
- }
3356
- this.movingLock(function () {
3357
- var e_36, _a;
3358
- try {
3359
- for (var panels_4 = __values(panels_3), panels_4_1 = panels_4.next(); !panels_4_1.done; panels_4_1 = panels_4.next()) {
3360
- var panel = panels_4_1.value;
3361
- to.model.openPanel(panel, {
3362
- skipSetActive: panel !== activePanel_1,
3363
- skipSetGroupActive: true,
3364
- });
3365
- }
3366
- }
3367
- catch (e_36_1) { e_36 = { error: e_36_1 }; }
3368
- finally {
3369
- try {
3370
- if (panels_4_1 && !panels_4_1.done && (_a = panels_4.return)) _a.call(panels_4);
3371
- }
3372
- finally { if (e_36) throw e_36.error; }
3373
- }
3374
- });
3375
- try {
3376
- for (var tabGroupSnapshots_1 = __values(tabGroupSnapshots), tabGroupSnapshots_1_1 = tabGroupSnapshots_1.next(); !tabGroupSnapshots_1_1.done; tabGroupSnapshots_1_1 = tabGroupSnapshots_1.next()) {
3377
- var snapshot = tabGroupSnapshots_1_1.value;
3378
- var newTabGroup = to.model.createTabGroup({
3379
- label: snapshot.label,
3380
- color: snapshot.color,
3381
- collapsed: snapshot.collapsed,
3382
- componentParams: snapshot.componentParams,
3383
- });
3384
- try {
3385
- for (var _h = (e_33 = void 0, __values(snapshot.panelIds)), _j = _h.next(); !_j.done; _j = _h.next()) {
3386
- var panelId = _j.value;
3387
- to.model.addPanelToTabGroup(newTabGroup.id, panelId);
3388
- }
3389
- }
3390
- catch (e_33_1) { e_33 = { error: e_33_1 }; }
3391
- finally {
3392
- try {
3393
- if (_j && !_j.done && (_b = _h.return)) _b.call(_h);
3394
- }
3395
- finally { if (e_33) throw e_33.error; }
3396
- }
3397
- }
3398
- }
3399
- catch (e_32_1) { e_32 = { error: e_32_1 }; }
3400
- finally {
3401
- try {
3402
- if (tabGroupSnapshots_1_1 && !tabGroupSnapshots_1_1.done && (_a = tabGroupSnapshots_1.return)) _a.call(tabGroupSnapshots_1);
3403
- }
3404
- finally { if (e_32) throw e_32.error; }
3405
- }
3406
- // Ensure group becomes active after move
3407
- if (options.skipSetActive !== true) {
3408
- // For center moves (merges), we need to ensure the target group is active
3409
- // unless explicitly told not to (skipSetActive: true)
3410
- this.doSetGroupAndPanelActive(to);
3411
- }
3412
- else if (!this.activePanel) {
3413
- // Even with skipSetActive: true, ensure there's an active panel if none exists
3414
- // This maintains basic functionality while respecting skipSetActive
3415
- this.doSetGroupAndPanelActive(to);
3416
- }
3417
- }
3418
- else {
3419
- if (from.api.location.type === 'edge') {
3420
- /**
3421
- * Edge groups are permanent structural elements and must
3422
- * stay anchored in their edge slot. Move the panels into a
3423
- * new group; the auto-collapse listener registered in
3424
- * addEdgeGroup will collapse the now-empty edge slot once
3425
- * the last panel leaves. The placement code below then
3426
- * positions `source` like any other moved group.
3427
- */
3428
- var activePanel_2 = from.activePanel;
3429
- // Snapshot tab group metadata so the new group inherits
3430
- // the tab grouping from the edge slot.
3431
- var tabGroupSnapshots = from.model
3432
- .getTabGroups()
3433
- .map(function (tg) { return ({
3434
- label: tg.label,
3435
- color: tg.color,
3436
- collapsed: tg.collapsed,
3437
- componentParams: tg.componentParams,
3438
- panelIds: __spreadArray([], __read(tg.panelIds), false),
3439
- }); });
3440
- var movedPanels_1 = this.movingLock(function () {
3441
- return __spreadArray([], __read(from.panels), false).map(function (p) {
3442
- return from.model.removePanel(p.id, { skipSetActive: true });
3443
- });
3444
- });
3445
- source = this.createGroup();
3446
- // The new source group enters the layout via gridview.addView
3447
- // below, which bypasses doAddGroup and so doesn't fire
3448
- // BaseGrid._onDidAdd. Modules (TabGroupChips, etc.) drive
3449
- // per-group attachment off _onDidAddGroup, so we fire it
3450
- // explicitly here — matches the pattern in addFloatingGroup
3451
- // and addEdgeGroup.
3452
- this._onDidAddGroup.fire(source);
3453
- this.movingLock(function () {
3454
- var e_37, _a;
3455
- try {
3456
- for (var movedPanels_2 = __values(movedPanels_1), movedPanels_2_1 = movedPanels_2.next(); !movedPanels_2_1.done; movedPanels_2_1 = movedPanels_2.next()) {
3457
- var panel = movedPanels_2_1.value;
3458
- source.model.openPanel(panel, {
3459
- skipSetActive: panel !== activePanel_2,
3460
- skipSetGroupActive: true,
3461
- });
3462
- }
3463
- }
3464
- catch (e_37_1) { e_37 = { error: e_37_1 }; }
3465
- finally {
3466
- try {
3467
- if (movedPanels_2_1 && !movedPanels_2_1.done && (_a = movedPanels_2.return)) _a.call(movedPanels_2);
3468
- }
3469
- finally { if (e_37) throw e_37.error; }
3470
- }
3471
- });
3472
- try {
3473
- for (var tabGroupSnapshots_2 = __values(tabGroupSnapshots), tabGroupSnapshots_2_1 = tabGroupSnapshots_2.next(); !tabGroupSnapshots_2_1.done; tabGroupSnapshots_2_1 = tabGroupSnapshots_2.next()) {
3474
- var snapshot = tabGroupSnapshots_2_1.value;
3475
- var newTabGroup = source.model.createTabGroup({
3476
- label: snapshot.label,
3477
- color: snapshot.color,
3478
- collapsed: snapshot.collapsed,
3479
- componentParams: snapshot.componentParams,
3480
- });
3481
- try {
3482
- for (var _k = (e_35 = void 0, __values(snapshot.panelIds)), _l = _k.next(); !_l.done; _l = _k.next()) {
3483
- var panelId = _l.value;
3484
- source.model.addPanelToTabGroup(newTabGroup.id, panelId);
3485
- }
3486
- }
3487
- catch (e_35_1) { e_35 = { error: e_35_1 }; }
3488
- finally {
3489
- try {
3490
- if (_l && !_l.done && (_d = _k.return)) _d.call(_k);
3491
- }
3492
- finally { if (e_35) throw e_35.error; }
3493
- }
3494
- }
3495
- }
3496
- catch (e_34_1) { e_34 = { error: e_34_1 }; }
3497
- finally {
3498
- try {
3499
- if (tabGroupSnapshots_2_1 && !tabGroupSnapshots_2_1.done && (_c = tabGroupSnapshots_2.return)) _c.call(tabGroupSnapshots_2);
3500
- }
3501
- finally { if (e_34) throw e_34.error; }
3502
- }
3503
- }
3504
- else {
3505
- switch (from.api.location.type) {
3506
- case 'grid':
3507
- this.gridview.removeView((0, gridview_1.getGridLocation)(from.element));
3508
- break;
3509
- case 'floating': {
3510
- var selectedFloatingGroup = (_e = this._floatingGroupService) === null || _e === void 0 ? void 0 : _e.findByGroup(from);
3511
- if (!selectedFloatingGroup) {
3512
- throw new Error('dockview: failed to find floating group');
3513
- }
3514
- // Detach just this group from the floating window's
3515
- // nested gridview, keeping the window (and its other
3516
- // groups) alive. If it was the only member, dispose the
3517
- // whole window.
3518
- if (!this.detachFromNestedWindow(from)) {
3519
- selectedFloatingGroup.dispose();
3520
- }
3521
- break;
3522
- }
3523
- case 'popout': {
3524
- var selectedPopoutGroup = (_f = this._popoutWindowService) === null || _f === void 0 ? void 0 : _f.findByGroup(from);
3525
- if (!selectedPopoutGroup) {
3526
- throw new Error('dockview: failed to find popout group');
3527
- }
3528
- // Detach just this group from the popout window's
3529
- // nested gridview, keeping the window + its other groups
3530
- // alive. Destination containers/location are applied by
3531
- // the placement block below.
3532
- if (this.detachFromNestedWindow(from)) {
3533
- break;
3534
- }
3535
- // Last group leaving — tear the window down. Remove from
3536
- // the service first to prevent automatic restoration.
3537
- (_g = this._popoutWindowService) === null || _g === void 0 ? void 0 : _g.remove(selectedPopoutGroup);
3538
- // Clean up the reference group (ghost) if it exists and is hidden
3539
- if (selectedPopoutGroup.referenceGroup) {
3540
- var referenceGroup = this.getPanel(selectedPopoutGroup.referenceGroup);
3541
- if (referenceGroup &&
3542
- !referenceGroup.api.isVisible) {
3543
- this.doRemoveGroup(referenceGroup, {
3544
- skipActive: true,
3545
- });
3546
- }
3547
- }
3548
- // Dispose the window without triggering restoration. The
3549
- // placement block below applies the destination
3550
- // location and containers to `from`.
3551
- selectedPopoutGroup.window.dispose();
3552
- break;
3553
- }
3554
- }
3555
- }
3556
- // Place `source` next to `to`, in whichever gridview root `to`
3557
- // lives in. When `to` is inside a floating / popout window this
3558
- // splits that window's nested layout rather than spawning a new one.
3559
- if (to.api.location.type === 'grid' ||
3560
- to.api.location.type === 'floating' ||
3561
- to.api.location.type === 'popout') {
3562
- var destGridview = this.getGridviewForGroup(to);
3563
- var referenceLocation = (0, gridview_1.getGridLocation)(to.element);
3564
- var dropLocation = (0, gridview_1.getRelativeLocation)(destGridview.orientation, referenceLocation, target);
3565
- var size = void 0;
3566
- switch (destGridview.orientation) {
3567
- case splitview_1.Orientation.VERTICAL:
3568
- size =
3569
- referenceLocation.length % 2 == 0
3570
- ? from.api.width
3571
- : from.api.height;
3572
- break;
3573
- case splitview_1.Orientation.HORIZONTAL:
3574
- size =
3575
- referenceLocation.length % 2 == 0
3576
- ? from.api.height
3577
- : from.api.width;
3578
- break;
3579
- }
3580
- destGridview.addView(source, size, dropLocation);
3581
- this.setGroupLocationForRoot(source, destGridview);
3582
- }
3583
- }
3584
- source.panels.forEach(function (panel) {
3585
- _this._onDidMovePanel.fire({ panel: panel, from: from });
3586
- });
3587
- this.debouncedUpdateAllPositions();
3588
- // Ensure group becomes active after move
3589
- if (options.skipSetActive === false) {
3590
- // Only activate when explicitly requested (skipSetActive: false)
3591
- // Use 'to' group for non-center moves since 'from' may have been destroyed
3592
- var targetGroup = to !== null && to !== void 0 ? to : from;
3593
- this.doSetGroupAndPanelActive(targetGroup);
3594
- }
3595
- else if (source !== from && options.skipSetActive !== true) {
3596
- // Edge group moves create a fresh `source` group; activate it
3597
- // by default so the moved panels receive focus.
3598
- this.doSetGroupAndPanelActive(source);
3599
- }
3600
- };
3601
- DockviewComponent.prototype.doSetGroupActive = function (group) {
3602
- var _a;
3603
- _super.prototype.doSetGroupActive.call(this, group);
3604
- var activePanel = this.activePanel;
3605
- if (!this._moving &&
3606
- activePanel !== ((_a = this._onDidActivePanelChange.value) === null || _a === void 0 ? void 0 : _a.panel)) {
3607
- this.fireActivePanelChange(activePanel);
3608
- }
3609
- };
3610
- DockviewComponent.prototype.doSetGroupAndPanelActive = function (group) {
3611
- var _a;
3612
- _super.prototype.doSetGroupActive.call(this, group);
3613
- var activePanel = this.activePanel;
3614
- if (group &&
3615
- this.hasMaximizedGroup() &&
3616
- !this.isMaximizedGroup(group)) {
3617
- this.exitMaximizedGroup();
3618
- }
3619
- if (!this._moving &&
3620
- activePanel !== ((_a = this._onDidActivePanelChange.value) === null || _a === void 0 ? void 0 : _a.panel)) {
3621
- this.fireActivePanelChange(activePanel);
3622
- }
3623
- };
3624
- DockviewComponent.prototype.getNextGroupId = function () {
3625
- var id = this.nextGroupId.next();
3626
- while (this._groups.has(id)) {
3627
- id = this.nextGroupId.next();
3628
- }
3629
- return id;
3630
- };
3631
- DockviewComponent.prototype.createGroup = function (options) {
3632
- var _this = this;
3633
- options !== null && options !== void 0 ? options : (options = {});
3634
- var id = options === null || options === void 0 ? void 0 : options.id;
3635
- if (id && this._groups.has(options.id)) {
3636
- console.warn("dockview: Duplicate group id ".concat(options === null || options === void 0 ? void 0 : options.id, ". reassigning group id to avoid errors"));
3637
- id = undefined;
3638
- }
3639
- if (!id) {
3640
- id = this.nextGroupId.next();
3641
- while (this._groups.has(id)) {
3642
- id = this.nextGroupId.next();
3643
- }
3644
- }
3645
- var view = new dockviewGroupPanel_1.DockviewGroupPanel(this, id, options);
3646
- view.init({ params: {}, accessor: this });
3647
- if (!this._groups.has(view.id)) {
3648
- var disposable = new lifecycle_1.CompositeDisposable(view.model.onTabDragStart(function (event) {
3649
- var _a;
3650
- (_a = _this._advancedDnDService) === null || _a === void 0 ? void 0 : _a.dispatchWillDragPanel(event);
3651
- }), view.model.onGroupDragStart(function (event) {
3652
- var _a;
3653
- (_a = _this._advancedDnDService) === null || _a === void 0 ? void 0 : _a.dispatchWillDragGroup(event);
3654
- }), view.model.onMove(function (event) {
3655
- var groupId = event.groupId, itemId = event.itemId, target = event.target, index = event.index, tabGroupId = event.tabGroupId;
3656
- _this.moveGroupOrPanel({
3657
- from: {
3658
- groupId: groupId,
3659
- panelId: itemId,
3660
- tabGroupId: tabGroupId,
3661
- },
3662
- to: {
3663
- group: view,
3664
- position: target,
3665
- index: index,
3666
- },
3667
- });
3668
- }), view.model.onDidDrop(function (event) {
3669
- _this._onDidDrop.fire(event);
3670
- }), view.model.onWillDrop(function (event) {
3671
- var _a;
3672
- (_a = _this._advancedDnDService) === null || _a === void 0 ? void 0 : _a.dispatchWillDrop(event);
3673
- }), view.model.onWillShowOverlay(function (event) {
3674
- var _a;
3675
- if (_this.options.disableDnd) {
3676
- // Engine policy — stays in core, ahead of any
3677
- // customisation dispatch.
3678
- event.preventDefault();
3679
- return;
3680
- }
3681
- (_a = _this._advancedDnDService) === null || _a === void 0 ? void 0 : _a.dispatchWillShowOverlay(event);
3682
- }), view.model.onUnhandledDragOver(function (event) {
3683
- _this._onUnhandledDragOver.fire(event);
3684
- }), view.model.onDidAddPanel(function (event) {
3685
- if (_this._moving) {
3686
- return;
3687
- }
3688
- _this._onDidAddPanel.fire(event.panel);
3689
- }), view.model.onDidRemovePanel(function (event) {
3690
- if (_this._moving) {
3691
- return;
3692
- }
3693
- _this._onDidRemovePanel.fire(event.panel);
3694
- }), view.model.onDidActivePanelChange(function (event) {
3695
- var _a;
3696
- if (_this._moving) {
3697
- return;
3698
- }
3699
- if (event.panel !== _this.activePanel) {
3700
- return;
3701
- }
3702
- if (((_a = _this._onDidActivePanelChange.value) === null || _a === void 0 ? void 0 : _a.panel) !==
3703
- event.panel) {
3704
- _this.fireActivePanelChange(event.panel);
3705
- }
3706
- }), events_1.Event.any(view.model.onDidPanelTitleChange, view.model.onDidPanelParametersChange)(function () {
3707
- _this._bufferOnDidLayoutChange.fire();
3708
- }));
3709
- this._groups.set(view.id, { value: view, disposable: disposable });
3710
- }
3711
- // TODO: must be called after the above listeners have been setup, not an ideal pattern
3712
- view.initialize();
3713
- return view;
3714
- };
3715
- DockviewComponent.prototype.createPanel = function (options, group) {
3716
- var _a, _b, _c;
3717
- var contentComponent = options.component;
3718
- var tabComponent = (_a = options.tabComponent) !== null && _a !== void 0 ? _a : this.options.defaultTabComponent;
3719
- var view = new dockviewPanelModel_1.DockviewPanelModel(this, options.id, contentComponent, tabComponent);
3720
- var panel = new dockviewPanel_1.DockviewPanel(options.id, contentComponent, tabComponent, this, this._api, group, view, {
3721
- renderer: options.renderer,
3722
- minimumWidth: options.minimumWidth,
3723
- minimumHeight: options.minimumHeight,
3724
- maximumWidth: options.maximumWidth,
3725
- maximumHeight: options.maximumHeight,
3726
- });
3727
- panel.init({
3728
- title: (_b = options.title) !== null && _b !== void 0 ? _b : options.id,
3729
- params: (_c = options === null || options === void 0 ? void 0 : options.params) !== null && _c !== void 0 ? _c : {},
3730
- });
3731
- return panel;
3732
- };
3733
- DockviewComponent.prototype.createGroupAtLocation = function (location, size, options, gridview) {
3734
- if (gridview === void 0) { gridview = this.gridview; }
3735
- var group = this.createGroup(options);
3736
- this.doAddGroup(group, location, size, gridview);
3737
- this.setGroupLocationForRoot(group, gridview);
3738
- return group;
3739
- };
3740
- /**
3741
- * Tag a group with the location and render / drop-target containers
3742
- * matching the gridview root it now lives in: the main grid, a floating
3743
- * window (shares the main containers), or a popout window (uses its own
3744
- * window-local containers).
3745
- */
3746
- DockviewComponent.prototype.setGroupLocationForRoot = function (group, gridview) {
3747
- var _a;
3748
- var popout = (_a = this._popoutWindowService) === null || _a === void 0 ? void 0 : _a.entries.find(function (entry) { return entry.gridview === gridview; });
3749
- if (popout) {
3750
- if (group.model.renderContainer !== popout.overlayRenderContainer) {
3751
- group.model.renderContainer = popout.overlayRenderContainer;
3752
- }
3753
- group.model.dropTargetContainer = popout.dropTargetContainer;
3754
- group.model.location = {
3755
- type: 'popout',
3756
- getWindow: popout.getWindow,
3757
- popoutUrl: popout.popoutUrl,
3758
- };
3759
- return;
3760
- }
3761
- // grid / floating both render through the main containers
3762
- if (group.model.renderContainer !== this.overlayRenderContainer) {
3763
- group.model.renderContainer = this.overlayRenderContainer;
3764
- }
3765
- group.model.dropTargetContainer = this.rootDropTargetContainer;
3766
- group.model.location =
3767
- gridview === this.gridview
3768
- ? { type: 'grid' }
3769
- : { type: 'floating' };
3770
- };
3771
- /**
3772
- * Resolve which gridview root currently owns a group: the main grid, or
3773
- * the nested gridview of the floating / popout window it lives in.
3774
- */
3775
- DockviewComponent.prototype.getGridviewForGroup = function (group) {
3776
- var _a, _b;
3777
- var floating = (_a = this._floatingGroupService) === null || _a === void 0 ? void 0 : _a.findByGroup(group);
3778
- if (floating) {
3779
- return floating.gridview;
3780
- }
3781
- // Use findByGroup (anchor-identity OR containment) for symmetry with
3782
- // the floating branch — it also resolves an anchor whose element is
3783
- // briefly detached from the gridview during a move/restore.
3784
- var popout = (_b = this._popoutWindowService) === null || _b === void 0 ? void 0 : _b.findByGroup(group);
3785
- if (popout) {
3786
- return popout.gridview;
3787
- }
3788
- return this.gridview;
3789
- };
3790
- /**
3791
- * The groups that live within the same floating / popout window as `group`
3792
- * (including `group` itself). Empty when `group` is in the main grid.
3793
- */
3794
- DockviewComponent.prototype.nestedWindowMembers = function (group) {
3795
- var gridview = this.getGridviewForGroup(group);
3796
- if (gridview === this.gridview) {
3797
- return [];
3798
- }
3799
- return this.groups.filter(function (candidate) {
3800
- return gridview.element.contains(candidate.element);
3801
- });
3802
- };
3803
- DockviewComponent.prototype.findGroup = function (panel) {
3804
- var _a;
3805
- return (_a = Array.from(this._groups.values()).find(function (group) {
3806
- return group.value.model.containsPanel(panel);
3807
- })) === null || _a === void 0 ? void 0 : _a.value;
3808
- };
3809
- DockviewComponent.prototype.orientationAtLocation = function (location) {
3810
- var rootOrientation = this.gridview.orientation;
3811
- return location.length % 2 == 1
3812
- ? rootOrientation
3813
- : (0, gridview_1.orthogonal)(rootOrientation);
3814
- };
3815
- DockviewComponent.prototype.updateTheme = function () {
3816
- var e_38, _a, e_39, _b, e_40, _c;
3817
- var _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
3818
- var theme = (_d = this._options.theme) !== null && _d !== void 0 ? _d : theme_1.themeAbyss;
3819
- // Apply the theme class only to the shell so edge groups and the
3820
- // main grid both inherit its CSS custom properties via the cascade.
3821
- // Re-declaring it on `.dv-dockview` would block consumer overrides
3822
- // set on the shell from reaching the dockview subtree.
3823
- (_e = this._shellThemeClassnames) === null || _e === void 0 ? void 0 : _e.setClassNames(theme.className);
3824
- var gap = (_f = theme.gap) !== null && _f !== void 0 ? _f : 0;
3825
- this.gridview.margin = gap;
3826
- try {
3827
- // Floating / popout windows host their own nested gridviews; keep their
3828
- // gap in sync with the main grid when the theme changes at runtime.
3829
- for (var _p = __values(this.floatingGroups), _q = _p.next(); !_q.done; _q = _p.next()) {
3830
- var floating = _q.value;
3831
- floating.gridview.margin = gap;
3832
- }
3833
- }
3834
- catch (e_38_1) { e_38 = { error: e_38_1 }; }
3835
- finally {
3836
- try {
3837
- if (_q && !_q.done && (_a = _p.return)) _a.call(_p);
3838
- }
3839
- finally { if (e_38) throw e_38.error; }
3840
- }
3841
- try {
3842
- for (var _r = __values((_h = (_g = this._popoutWindowService) === null || _g === void 0 ? void 0 : _g.entries) !== null && _h !== void 0 ? _h : []), _s = _r.next(); !_s.done; _s = _r.next()) {
3843
- var entry = _s.value;
3844
- entry.gridview.margin = gap;
3845
- }
3846
- }
3847
- catch (e_39_1) { e_39 = { error: e_39_1 }; }
3848
- finally {
3849
- try {
3850
- if (_s && !_s.done && (_b = _r.return)) _b.call(_r);
3851
- }
3852
- finally { if (e_39) throw e_39.error; }
3853
- }
3854
- (_j = this._shellManager) === null || _j === void 0 ? void 0 : _j.updateTheme(gap, (_k = theme.edgeGroupCollapsedSize) !== null && _k !== void 0 ? _k : 35);
3855
- if (theme.dndOverlayBorder === undefined) {
3856
- this.element.style.removeProperty('--dv-drag-over-border');
3857
- (_l = this._shellManager) === null || _l === void 0 ? void 0 : _l.element.style.removeProperty('--dv-drag-over-border');
3858
- }
3859
- else {
3860
- this.element.style.setProperty('--dv-drag-over-border', theme.dndOverlayBorder);
3861
- (_m = this._shellManager) === null || _m === void 0 ? void 0 : _m.element.style.setProperty('--dv-drag-over-border', theme.dndOverlayBorder);
3862
- }
3863
- switch (theme.dndOverlayMounting) {
3864
- case 'absolute':
3865
- this.rootDropTargetContainer.disabled = false;
3866
- break;
3867
- case 'relative':
3868
- default:
3869
- this.rootDropTargetContainer.disabled = true;
3870
- break;
3871
- }
3872
- // Toggle a CSS class so theme stylesheets can scope pure-CSS
3873
- // tab group indicator rules to the 'none' mode only.
3874
- var indicatorNone = ((_o = theme.tabGroupIndicator) !== null && _o !== void 0 ? _o : 'wrap') === 'none';
3875
- (0, dom_1.toggleClass)(this.element, 'dv-tab-group-indicator-none', indicatorNone);
3876
- if (this._shellManager) {
3877
- (0, dom_1.toggleClass)(this._shellManager.element, 'dv-tab-group-indicator-none', indicatorNone);
3878
- }
3879
- try {
3880
- // Re-render tab group indicators so the new tabGroupIndicator mode takes effect
3881
- for (var _t = __values(this.groups), _u = _t.next(); !_u.done; _u = _t.next()) {
3882
- var group = _u.value;
3883
- group.model.updateTabGroups();
3884
- }
3885
- }
3886
- catch (e_40_1) { e_40 = { error: e_40_1 }; }
3887
- finally {
3888
- try {
3889
- if (_u && !_u.done && (_c = _t.return)) _c.call(_t);
3890
- }
3891
- finally { if (e_40) throw e_40.error; }
3892
- }
3893
- };
3894
- return DockviewComponent;
3895
- }(baseComponentGridview_1.BaseGrid));
3896
- exports.DockviewComponent = DockviewComponent;