dockview-core 1.8.4 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (464) hide show
  1. package/README.md +58 -51
  2. package/dist/cjs/api/component.api.d.ts +467 -152
  3. package/dist/cjs/api/component.api.d.ts.map +1 -1
  4. package/dist/cjs/api/component.api.js +917 -592
  5. package/dist/cjs/api/component.api.js.map +1 -1
  6. package/dist/cjs/api/dockviewGroupPanelApi.d.ts +36 -29
  7. package/dist/cjs/api/dockviewGroupPanelApi.d.ts.map +1 -1
  8. package/dist/cjs/api/dockviewGroupPanelApi.js +83 -53
  9. package/dist/cjs/api/dockviewGroupPanelApi.js.map +1 -1
  10. package/dist/cjs/api/dockviewPanelApi.d.ts +64 -47
  11. package/dist/cjs/api/dockviewPanelApi.d.ts.map +1 -1
  12. package/dist/cjs/api/dockviewPanelApi.js +108 -88
  13. package/dist/cjs/api/dockviewPanelApi.js.map +1 -1
  14. package/dist/cjs/api/gridviewPanelApi.d.ts +37 -37
  15. package/dist/cjs/api/gridviewPanelApi.js +47 -47
  16. package/dist/cjs/api/gridviewPanelApi.js.map +1 -1
  17. package/dist/cjs/api/panelApi.d.ts +88 -88
  18. package/dist/cjs/api/panelApi.js +135 -135
  19. package/dist/cjs/api/panelApi.js.map +1 -1
  20. package/dist/cjs/api/paneviewPanelApi.d.ts +26 -26
  21. package/dist/cjs/api/paneviewPanelApi.js +57 -57
  22. package/dist/cjs/api/paneviewPanelApi.js.map +1 -1
  23. package/dist/cjs/api/splitviewPanelApi.d.ts +32 -32
  24. package/dist/cjs/api/splitviewPanelApi.js +47 -47
  25. package/dist/cjs/api/splitviewPanelApi.js.map +1 -1
  26. package/dist/cjs/array.d.ts +13 -13
  27. package/dist/cjs/array.js +67 -67
  28. package/dist/cjs/array.js.map +1 -1
  29. package/dist/cjs/constants.d.ts +6 -0
  30. package/dist/cjs/constants.d.ts.map +1 -0
  31. package/dist/cjs/constants.js +6 -0
  32. package/dist/cjs/constants.js.map +1 -0
  33. package/dist/cjs/dnd/abstractDragHandler.d.ts +12 -12
  34. package/dist/cjs/dnd/abstractDragHandler.js +141 -141
  35. package/dist/cjs/dnd/abstractDragHandler.js.map +1 -1
  36. package/dist/cjs/dnd/dataTransfer.d.ts +30 -31
  37. package/dist/cjs/dnd/dataTransfer.d.ts.map +1 -1
  38. package/dist/cjs/dnd/dataTransfer.js +99 -100
  39. package/dist/cjs/dnd/dataTransfer.js.map +1 -1
  40. package/dist/cjs/dnd/dnd.d.ts +32 -27
  41. package/dist/cjs/dnd/dnd.d.ts.map +1 -1
  42. package/dist/cjs/dnd/dnd.js +74 -59
  43. package/dist/cjs/dnd/dnd.js.map +1 -1
  44. package/dist/cjs/dnd/droptarget.d.ts +55 -53
  45. package/dist/cjs/dnd/droptarget.d.ts.map +1 -1
  46. package/dist/cjs/dnd/droptarget.js +305 -304
  47. package/dist/cjs/dnd/droptarget.js.map +1 -1
  48. package/dist/cjs/dnd/ghost.d.ts +1 -1
  49. package/dist/cjs/dnd/ghost.js +15 -15
  50. package/dist/cjs/dnd/groupDragHandler.d.ts +12 -12
  51. package/dist/cjs/dnd/groupDragHandler.js +77 -77
  52. package/dist/cjs/dnd/groupDragHandler.js.map +1 -1
  53. package/dist/cjs/dnd/overlay.d.ts +30 -43
  54. package/dist/cjs/dnd/overlay.d.ts.map +1 -1
  55. package/dist/cjs/dnd/overlay.js +412 -412
  56. package/dist/cjs/dnd/overlay.js.map +1 -1
  57. package/dist/cjs/dockview/components/panel/content.d.ts +43 -30
  58. package/dist/cjs/dockview/components/panel/content.d.ts.map +1 -1
  59. package/dist/cjs/dockview/components/panel/content.js +159 -100
  60. package/dist/cjs/dockview/components/panel/content.js.map +1 -1
  61. package/dist/cjs/dockview/components/tab/defaultTab.d.ts +21 -21
  62. package/dist/cjs/dockview/components/tab/defaultTab.js +105 -105
  63. package/dist/cjs/dockview/components/tab/defaultTab.js.map +1 -1
  64. package/dist/cjs/dockview/components/tab/tab.d.ts +34 -34
  65. package/dist/cjs/dockview/components/tab/tab.js +120 -120
  66. package/dist/cjs/dockview/components/tab/tab.js.map +1 -1
  67. package/dist/cjs/dockview/components/titlebar/tabsContainer.d.ts +81 -81
  68. package/dist/cjs/dockview/components/titlebar/tabsContainer.js +325 -325
  69. package/dist/cjs/dockview/components/titlebar/tabsContainer.js.map +1 -1
  70. package/dist/cjs/dockview/components/titlebar/voidContainer.d.ts +17 -17
  71. package/dist/cjs/dockview/components/titlebar/voidContainer.js +77 -77
  72. package/dist/cjs/dockview/components/titlebar/voidContainer.js.map +1 -1
  73. package/dist/cjs/dockview/components/watermark/watermark.d.ts +18 -18
  74. package/dist/cjs/dockview/components/watermark/watermark.js +87 -87
  75. package/dist/cjs/dockview/components/watermark/watermark.js.map +1 -1
  76. package/dist/cjs/dockview/deserializer.d.ts +12 -12
  77. package/dist/cjs/dockview/deserializer.d.ts.map +1 -1
  78. package/dist/cjs/dockview/deserializer.js +35 -33
  79. package/dist/cjs/dockview/deserializer.js.map +1 -1
  80. package/dist/cjs/dockview/dockviewComponent.d.ts +171 -159
  81. package/dist/cjs/dockview/dockviewComponent.d.ts.map +1 -1
  82. package/dist/cjs/dockview/dockviewComponent.js +1354 -1156
  83. package/dist/cjs/dockview/dockviewComponent.js.map +1 -1
  84. package/dist/cjs/dockview/dockviewFloatingGroupPanel.d.ts +23 -23
  85. package/dist/cjs/dockview/dockviewFloatingGroupPanel.js +34 -34
  86. package/dist/cjs/dockview/dockviewFloatingGroupPanel.js.map +1 -1
  87. package/dist/cjs/dockview/dockviewGroupPanel.d.ts +30 -30
  88. package/dist/cjs/dockview/dockviewGroupPanel.d.ts.map +1 -1
  89. package/dist/cjs/dockview/dockviewGroupPanel.js +99 -97
  90. package/dist/cjs/dockview/dockviewGroupPanel.js.map +1 -1
  91. package/dist/cjs/dockview/dockviewGroupPanelModel.d.ts +186 -185
  92. package/dist/cjs/dockview/dockviewGroupPanelModel.d.ts.map +1 -1
  93. package/dist/cjs/dockview/dockviewGroupPanelModel.js +626 -631
  94. package/dist/cjs/dockview/dockviewGroupPanelModel.js.map +1 -1
  95. package/dist/cjs/dockview/dockviewPanel.d.ts +48 -41
  96. package/dist/cjs/dockview/dockviewPanel.d.ts.map +1 -1
  97. package/dist/cjs/dockview/dockviewPanel.js +194 -171
  98. package/dist/cjs/dockview/dockviewPanel.js.map +1 -1
  99. package/dist/cjs/dockview/dockviewPanelModel.d.ts +35 -35
  100. package/dist/cjs/dockview/dockviewPanelModel.js +98 -98
  101. package/dist/cjs/dockview/dockviewPanelModel.js.map +1 -1
  102. package/dist/cjs/dockview/dockviewPopoutGroupPanel.d.ts +16 -0
  103. package/dist/cjs/dockview/dockviewPopoutGroupPanel.d.ts.map +1 -0
  104. package/dist/cjs/dockview/dockviewPopoutGroupPanel.js +50 -0
  105. package/dist/cjs/dockview/dockviewPopoutGroupPanel.js.map +1 -0
  106. package/dist/cjs/dockview/options.d.ts +138 -136
  107. package/dist/cjs/dockview/options.d.ts.map +1 -1
  108. package/dist/cjs/dockview/options.js +31 -31
  109. package/dist/cjs/dockview/options.js.map +1 -1
  110. package/dist/cjs/dockview/types.d.ts +65 -63
  111. package/dist/cjs/dockview/types.d.ts.map +1 -1
  112. package/dist/cjs/dockview/types.js +10 -10
  113. package/dist/cjs/dockview/types.js.map +1 -1
  114. package/dist/cjs/dom.d.ts +28 -16
  115. package/dist/cjs/dom.d.ts.map +1 -1
  116. package/dist/cjs/dom.js +276 -197
  117. package/dist/cjs/dom.js.map +1 -1
  118. package/dist/cjs/events.d.ts +47 -47
  119. package/dist/cjs/events.js +216 -216
  120. package/dist/cjs/events.js.map +1 -1
  121. package/dist/cjs/gridview/baseComponentGridview.d.ts +98 -87
  122. package/dist/cjs/gridview/baseComponentGridview.d.ts.map +1 -1
  123. package/dist/cjs/gridview/baseComponentGridview.js +289 -270
  124. package/dist/cjs/gridview/baseComponentGridview.js.map +1 -1
  125. package/dist/cjs/gridview/basePanelView.d.ts +40 -40
  126. package/dist/cjs/gridview/basePanelView.js +156 -156
  127. package/dist/cjs/gridview/basePanelView.js.map +1 -1
  128. package/dist/cjs/gridview/branchNode.d.ts +51 -49
  129. package/dist/cjs/gridview/branchNode.d.ts.map +1 -1
  130. package/dist/cjs/gridview/branchNode.js +370 -343
  131. package/dist/cjs/gridview/branchNode.js.map +1 -1
  132. package/dist/cjs/gridview/gridview.d.ts +140 -133
  133. package/dist/cjs/gridview/gridview.d.ts.map +1 -1
  134. package/dist/cjs/gridview/gridview.js +627 -547
  135. package/dist/cjs/gridview/gridview.js.map +1 -1
  136. package/dist/cjs/gridview/gridviewComponent.d.ts +80 -80
  137. package/dist/cjs/gridview/gridviewComponent.d.ts.map +1 -1
  138. package/dist/cjs/gridview/gridviewComponent.js +362 -360
  139. package/dist/cjs/gridview/gridviewComponent.js.map +1 -1
  140. package/dist/cjs/gridview/gridviewPanel.d.ts +65 -65
  141. package/dist/cjs/gridview/gridviewPanel.js +214 -214
  142. package/dist/cjs/gridview/gridviewPanel.js.map +1 -1
  143. package/dist/cjs/gridview/leafNode.d.ts +34 -34
  144. package/dist/cjs/gridview/leafNode.d.ts.map +1 -1
  145. package/dist/cjs/gridview/leafNode.js +169 -170
  146. package/dist/cjs/gridview/leafNode.js.map +1 -1
  147. package/dist/cjs/gridview/options.d.ts +17 -18
  148. package/dist/cjs/gridview/options.d.ts.map +1 -1
  149. package/dist/cjs/gridview/options.js +2 -2
  150. package/dist/cjs/gridview/types.d.ts +3 -3
  151. package/dist/cjs/gridview/types.js +2 -2
  152. package/dist/cjs/index.d.ts +43 -42
  153. package/dist/cjs/index.d.ts.map +1 -1
  154. package/dist/cjs/index.js +61 -61
  155. package/dist/cjs/index.js.map +1 -1
  156. package/dist/cjs/lifecycle.d.ts +24 -23
  157. package/dist/cjs/lifecycle.d.ts.map +1 -1
  158. package/dist/cjs/lifecycle.js +73 -65
  159. package/dist/cjs/lifecycle.js.map +1 -1
  160. package/dist/cjs/math.d.ts +5 -5
  161. package/dist/cjs/math.js +34 -34
  162. package/dist/cjs/math.js.map +1 -1
  163. package/dist/cjs/overlayRenderContainer.d.ts +19 -0
  164. package/dist/cjs/overlayRenderContainer.d.ts.map +1 -0
  165. package/dist/cjs/overlayRenderContainer.js +170 -0
  166. package/dist/cjs/overlayRenderContainer.js.map +1 -0
  167. package/dist/cjs/panel/componentFactory.d.ts +11 -10
  168. package/dist/cjs/panel/componentFactory.d.ts.map +1 -1
  169. package/dist/cjs/panel/componentFactory.js +30 -30
  170. package/dist/cjs/panel/componentFactory.js.map +1 -1
  171. package/dist/cjs/panel/types.d.ts +33 -33
  172. package/dist/cjs/panel/types.js +2 -2
  173. package/dist/cjs/paneview/defaultPaneviewHeader.d.ts +21 -21
  174. package/dist/cjs/paneview/defaultPaneviewHeader.js +90 -90
  175. package/dist/cjs/paneview/defaultPaneviewHeader.js.map +1 -1
  176. package/dist/cjs/paneview/draggablePaneviewPanel.d.ts +21 -21
  177. package/dist/cjs/paneview/draggablePaneviewPanel.js +131 -131
  178. package/dist/cjs/paneview/draggablePaneviewPanel.js.map +1 -1
  179. package/dist/cjs/paneview/options.d.ts +25 -28
  180. package/dist/cjs/paneview/options.d.ts.map +1 -1
  181. package/dist/cjs/paneview/options.js +2 -2
  182. package/dist/cjs/paneview/paneview.d.ts +40 -40
  183. package/dist/cjs/paneview/paneview.d.ts.map +1 -1
  184. package/dist/cjs/paneview/paneview.js +200 -201
  185. package/dist/cjs/paneview/paneview.js.map +1 -1
  186. package/dist/cjs/paneview/paneviewComponent.d.ts +128 -128
  187. package/dist/cjs/paneview/paneviewComponent.js +400 -397
  188. package/dist/cjs/paneview/paneviewComponent.js.map +1 -1
  189. package/dist/cjs/paneview/paneviewPanel.d.ts +92 -92
  190. package/dist/cjs/paneview/paneviewPanel.d.ts.map +1 -1
  191. package/dist/cjs/paneview/paneviewPanel.js +275 -275
  192. package/dist/cjs/paneview/paneviewPanel.js.map +1 -1
  193. package/dist/cjs/popoutWindow.d.ts +18 -0
  194. package/dist/cjs/popoutWindow.d.ts.map +1 -0
  195. package/dist/cjs/popoutWindow.js +130 -0
  196. package/dist/cjs/popoutWindow.js.map +1 -0
  197. package/dist/cjs/resizable.d.ts +10 -7
  198. package/dist/cjs/resizable.d.ts.map +1 -1
  199. package/dist/cjs/resizable.js +79 -64
  200. package/dist/cjs/resizable.js.map +1 -1
  201. package/dist/cjs/splitview/options.d.ts +26 -27
  202. package/dist/cjs/splitview/options.d.ts.map +1 -1
  203. package/dist/cjs/splitview/options.js +2 -2
  204. package/dist/cjs/splitview/splitview.d.ts +129 -128
  205. package/dist/cjs/splitview/splitview.d.ts.map +1 -1
  206. package/dist/cjs/splitview/splitview.js +959 -936
  207. package/dist/cjs/splitview/splitview.js.map +1 -1
  208. package/dist/cjs/splitview/splitviewComponent.d.ts +101 -101
  209. package/dist/cjs/splitview/splitviewComponent.js +395 -392
  210. package/dist/cjs/splitview/splitviewComponent.js.map +1 -1
  211. package/dist/cjs/splitview/splitviewPanel.d.ts +45 -45
  212. package/dist/cjs/splitview/splitviewPanel.d.ts.map +1 -1
  213. package/dist/cjs/splitview/splitviewPanel.js +179 -179
  214. package/dist/cjs/splitview/splitviewPanel.js.map +1 -1
  215. package/dist/cjs/splitview/viewItem.d.ts +25 -25
  216. package/dist/cjs/splitview/viewItem.js +119 -119
  217. package/dist/cjs/splitview/viewItem.js.map +1 -1
  218. package/dist/cjs/svg.d.ts +3 -3
  219. package/dist/cjs/svg.js +43 -43
  220. package/dist/cjs/types.d.ts +8 -2
  221. package/dist/cjs/types.d.ts.map +1 -1
  222. package/dist/cjs/types.js +2 -2
  223. package/dist/dockview-core.amd.js +8374 -7314
  224. package/dist/dockview-core.amd.js.map +1 -1
  225. package/dist/dockview-core.amd.min.js +2 -2
  226. package/dist/dockview-core.amd.min.js.map +1 -1
  227. package/dist/dockview-core.amd.min.noStyle.js +2 -2
  228. package/dist/dockview-core.amd.min.noStyle.js.map +1 -1
  229. package/dist/dockview-core.amd.noStyle.js +8328 -7268
  230. package/dist/dockview-core.amd.noStyle.js.map +1 -1
  231. package/dist/dockview-core.cjs.js +8374 -7314
  232. package/dist/dockview-core.cjs.js.map +1 -1
  233. package/dist/dockview-core.esm.js +8374 -7314
  234. package/dist/dockview-core.esm.js.map +1 -1
  235. package/dist/dockview-core.esm.min.js +2 -2
  236. package/dist/dockview-core.esm.min.js.map +1 -1
  237. package/dist/dockview-core.js +8374 -7314
  238. package/dist/dockview-core.js.map +1 -1
  239. package/dist/dockview-core.min.js +2 -2
  240. package/dist/dockview-core.min.js.map +1 -1
  241. package/dist/dockview-core.min.noStyle.js +2 -2
  242. package/dist/dockview-core.min.noStyle.js.map +1 -1
  243. package/dist/dockview-core.noStyle.js +8328 -7268
  244. package/dist/dockview-core.noStyle.js.map +1 -1
  245. package/dist/esm/api/component.api.d.ts +467 -152
  246. package/dist/esm/api/component.api.d.ts.map +1 -1
  247. package/dist/esm/api/component.api.js +656 -335
  248. package/dist/esm/api/component.api.js.map +1 -1
  249. package/dist/esm/api/dockviewGroupPanelApi.d.ts +36 -29
  250. package/dist/esm/api/dockviewGroupPanelApi.d.ts.map +1 -1
  251. package/dist/esm/api/dockviewGroupPanelApi.js +57 -27
  252. package/dist/esm/api/dockviewGroupPanelApi.js.map +1 -1
  253. package/dist/esm/api/dockviewPanelApi.d.ts +64 -47
  254. package/dist/esm/api/dockviewPanelApi.d.ts.map +1 -1
  255. package/dist/esm/api/dockviewPanelApi.js +69 -53
  256. package/dist/esm/api/dockviewPanelApi.js.map +1 -1
  257. package/dist/esm/api/gridviewPanelApi.d.ts +37 -37
  258. package/dist/esm/api/gridviewPanelApi.js +25 -25
  259. package/dist/esm/api/gridviewPanelApi.js.map +1 -1
  260. package/dist/esm/api/panelApi.d.ts +88 -88
  261. package/dist/esm/api/panelApi.js +93 -93
  262. package/dist/esm/api/paneviewPanelApi.d.ts +26 -26
  263. package/dist/esm/api/paneviewPanelApi.js +27 -27
  264. package/dist/esm/api/splitviewPanelApi.d.ts +32 -32
  265. package/dist/esm/api/splitviewPanelApi.js +25 -25
  266. package/dist/esm/array.d.ts +13 -13
  267. package/dist/esm/array.js +57 -57
  268. package/dist/esm/array.js.map +1 -1
  269. package/dist/esm/constants.d.ts +6 -0
  270. package/dist/esm/constants.d.ts.map +1 -0
  271. package/dist/esm/constants.js +3 -0
  272. package/dist/esm/constants.js.map +1 -0
  273. package/dist/esm/dnd/abstractDragHandler.d.ts +12 -12
  274. package/dist/esm/dnd/abstractDragHandler.js +63 -63
  275. package/dist/esm/dnd/abstractDragHandler.js.map +1 -1
  276. package/dist/esm/dnd/dataTransfer.d.ts +30 -31
  277. package/dist/esm/dnd/dataTransfer.d.ts.map +1 -1
  278. package/dist/esm/dnd/dataTransfer.js +66 -69
  279. package/dist/esm/dnd/dataTransfer.js.map +1 -1
  280. package/dist/esm/dnd/dnd.d.ts +32 -27
  281. package/dist/esm/dnd/dnd.d.ts.map +1 -1
  282. package/dist/esm/dnd/dnd.js +51 -36
  283. package/dist/esm/dnd/dnd.js.map +1 -1
  284. package/dist/esm/dnd/droptarget.d.ts +55 -53
  285. package/dist/esm/dnd/droptarget.d.ts.map +1 -1
  286. package/dist/esm/dnd/droptarget.js +275 -274
  287. package/dist/esm/dnd/droptarget.js.map +1 -1
  288. package/dist/esm/dnd/ghost.d.ts +1 -1
  289. package/dist/esm/dnd/ghost.js +11 -11
  290. package/dist/esm/dnd/groupDragHandler.d.ts +12 -12
  291. package/dist/esm/dnd/groupDragHandler.js +54 -54
  292. package/dist/esm/dnd/groupDragHandler.js.map +1 -1
  293. package/dist/esm/dnd/overlay.d.ts +30 -43
  294. package/dist/esm/dnd/overlay.d.ts.map +1 -1
  295. package/dist/esm/dnd/overlay.js +304 -304
  296. package/dist/esm/dnd/overlay.js.map +1 -1
  297. package/dist/esm/dockview/components/panel/content.d.ts +43 -30
  298. package/dist/esm/dockview/components/panel/content.d.ts.map +1 -1
  299. package/dist/esm/dockview/components/panel/content.js +131 -73
  300. package/dist/esm/dockview/components/panel/content.js.map +1 -1
  301. package/dist/esm/dockview/components/tab/defaultTab.d.ts +21 -21
  302. package/dist/esm/dockview/components/tab/defaultTab.js +67 -67
  303. package/dist/esm/dockview/components/tab/defaultTab.js.map +1 -1
  304. package/dist/esm/dockview/components/tab/tab.d.ts +34 -34
  305. package/dist/esm/dockview/components/tab/tab.js +90 -90
  306. package/dist/esm/dockview/components/tab/tab.js.map +1 -1
  307. package/dist/esm/dockview/components/titlebar/tabsContainer.d.ts +81 -81
  308. package/dist/esm/dockview/components/titlebar/tabsContainer.js +239 -239
  309. package/dist/esm/dockview/components/titlebar/tabsContainer.js.map +1 -1
  310. package/dist/esm/dockview/components/titlebar/voidContainer.d.ts +17 -17
  311. package/dist/esm/dockview/components/titlebar/voidContainer.js +51 -51
  312. package/dist/esm/dockview/components/titlebar/voidContainer.js.map +1 -1
  313. package/dist/esm/dockview/components/watermark/watermark.d.ts +18 -18
  314. package/dist/esm/dockview/components/watermark/watermark.js +61 -61
  315. package/dist/esm/dockview/components/watermark/watermark.js.map +1 -1
  316. package/dist/esm/dockview/deserializer.d.ts +12 -12
  317. package/dist/esm/dockview/deserializer.d.ts.map +1 -1
  318. package/dist/esm/dockview/deserializer.js +30 -28
  319. package/dist/esm/dockview/deserializer.js.map +1 -1
  320. package/dist/esm/dockview/dockviewComponent.d.ts +171 -159
  321. package/dist/esm/dockview/dockviewComponent.d.ts.map +1 -1
  322. package/dist/esm/dockview/dockviewComponent.js +1078 -918
  323. package/dist/esm/dockview/dockviewComponent.js.map +1 -1
  324. package/dist/esm/dockview/dockviewFloatingGroupPanel.d.ts +23 -23
  325. package/dist/esm/dockview/dockviewFloatingGroupPanel.js +12 -12
  326. package/dist/esm/dockview/dockviewGroupPanel.d.ts +30 -30
  327. package/dist/esm/dockview/dockviewGroupPanel.d.ts.map +1 -1
  328. package/dist/esm/dockview/dockviewGroupPanel.js +53 -51
  329. package/dist/esm/dockview/dockviewGroupPanel.js.map +1 -1
  330. package/dist/esm/dockview/dockviewGroupPanelModel.d.ts +186 -185
  331. package/dist/esm/dockview/dockviewGroupPanelModel.d.ts.map +1 -1
  332. package/dist/esm/dockview/dockviewGroupPanelModel.js +493 -498
  333. package/dist/esm/dockview/dockviewGroupPanelModel.js.map +1 -1
  334. package/dist/esm/dockview/dockviewPanel.d.ts +48 -41
  335. package/dist/esm/dockview/dockviewPanel.d.ts.map +1 -1
  336. package/dist/esm/dockview/dockviewPanel.js +123 -104
  337. package/dist/esm/dockview/dockviewPanel.js.map +1 -1
  338. package/dist/esm/dockview/dockviewPanelModel.d.ts +35 -35
  339. package/dist/esm/dockview/dockviewPanelModel.js +74 -74
  340. package/dist/esm/dockview/dockviewPanelModel.js.map +1 -1
  341. package/dist/esm/dockview/dockviewPopoutGroupPanel.d.ts +16 -0
  342. package/dist/esm/dockview/dockviewPopoutGroupPanel.d.ts.map +1 -0
  343. package/dist/esm/dockview/dockviewPopoutGroupPanel.js +28 -0
  344. package/dist/esm/dockview/dockviewPopoutGroupPanel.js.map +1 -0
  345. package/dist/esm/dockview/options.d.ts +138 -136
  346. package/dist/esm/dockview/options.d.ts.map +1 -1
  347. package/dist/esm/dockview/options.js +24 -24
  348. package/dist/esm/dockview/options.js.map +1 -1
  349. package/dist/esm/dockview/types.d.ts +65 -63
  350. package/dist/esm/dockview/types.d.ts.map +1 -1
  351. package/dist/esm/dockview/types.js +7 -7
  352. package/dist/esm/dockview/types.js.map +1 -1
  353. package/dist/esm/dom.d.ts +28 -16
  354. package/dist/esm/dom.d.ts.map +1 -1
  355. package/dist/esm/dom.js +181 -126
  356. package/dist/esm/dom.js.map +1 -1
  357. package/dist/esm/events.d.ts +47 -47
  358. package/dist/esm/events.js +156 -156
  359. package/dist/esm/events.js.map +1 -1
  360. package/dist/esm/gridview/baseComponentGridview.d.ts +98 -87
  361. package/dist/esm/gridview/baseComponentGridview.d.ts.map +1 -1
  362. package/dist/esm/gridview/baseComponentGridview.js +199 -184
  363. package/dist/esm/gridview/baseComponentGridview.js.map +1 -1
  364. package/dist/esm/gridview/basePanelView.d.ts +40 -40
  365. package/dist/esm/gridview/basePanelView.js +85 -85
  366. package/dist/esm/gridview/basePanelView.js.map +1 -1
  367. package/dist/esm/gridview/branchNode.d.ts +51 -49
  368. package/dist/esm/gridview/branchNode.d.ts.map +1 -1
  369. package/dist/esm/gridview/branchNode.js +240 -219
  370. package/dist/esm/gridview/branchNode.js.map +1 -1
  371. package/dist/esm/gridview/gridview.d.ts +140 -133
  372. package/dist/esm/gridview/gridview.d.ts.map +1 -1
  373. package/dist/esm/gridview/gridview.js +541 -461
  374. package/dist/esm/gridview/gridview.js.map +1 -1
  375. package/dist/esm/gridview/gridviewComponent.d.ts +80 -80
  376. package/dist/esm/gridview/gridviewComponent.d.ts.map +1 -1
  377. package/dist/esm/gridview/gridviewComponent.js +264 -262
  378. package/dist/esm/gridview/gridviewComponent.js.map +1 -1
  379. package/dist/esm/gridview/gridviewPanel.d.ts +65 -65
  380. package/dist/esm/gridview/gridviewPanel.js +151 -151
  381. package/dist/esm/gridview/gridviewPanel.js.map +1 -1
  382. package/dist/esm/gridview/leafNode.d.ts +34 -34
  383. package/dist/esm/gridview/leafNode.d.ts.map +1 -1
  384. package/dist/esm/gridview/leafNode.js +102 -103
  385. package/dist/esm/gridview/leafNode.js.map +1 -1
  386. package/dist/esm/gridview/options.d.ts +17 -18
  387. package/dist/esm/gridview/options.d.ts.map +1 -1
  388. package/dist/esm/gridview/options.js +1 -1
  389. package/dist/esm/gridview/types.d.ts +3 -3
  390. package/dist/esm/gridview/types.js +1 -1
  391. package/dist/esm/index.d.ts +43 -42
  392. package/dist/esm/index.d.ts.map +1 -1
  393. package/dist/esm/index.js +34 -34
  394. package/dist/esm/index.js.map +1 -1
  395. package/dist/esm/lifecycle.d.ts +24 -23
  396. package/dist/esm/lifecycle.d.ts.map +1 -1
  397. package/dist/esm/lifecycle.js +49 -41
  398. package/dist/esm/lifecycle.js.map +1 -1
  399. package/dist/esm/math.d.ts +5 -5
  400. package/dist/esm/math.js +28 -28
  401. package/dist/esm/math.js.map +1 -1
  402. package/dist/esm/overlayRenderContainer.d.ts +19 -0
  403. package/dist/esm/overlayRenderContainer.d.ts.map +1 -0
  404. package/dist/esm/overlayRenderContainer.js +125 -0
  405. package/dist/esm/overlayRenderContainer.js.map +1 -0
  406. package/dist/esm/panel/componentFactory.d.ts +11 -10
  407. package/dist/esm/panel/componentFactory.d.ts.map +1 -1
  408. package/dist/esm/panel/componentFactory.js +24 -24
  409. package/dist/esm/panel/componentFactory.js.map +1 -1
  410. package/dist/esm/panel/types.d.ts +33 -33
  411. package/dist/esm/panel/types.js +1 -1
  412. package/dist/esm/paneview/defaultPaneviewHeader.d.ts +21 -21
  413. package/dist/esm/paneview/defaultPaneviewHeader.js +63 -63
  414. package/dist/esm/paneview/defaultPaneviewHeader.js.map +1 -1
  415. package/dist/esm/paneview/draggablePaneviewPanel.d.ts +21 -21
  416. package/dist/esm/paneview/draggablePaneviewPanel.js +92 -92
  417. package/dist/esm/paneview/draggablePaneviewPanel.js.map +1 -1
  418. package/dist/esm/paneview/options.d.ts +25 -28
  419. package/dist/esm/paneview/options.d.ts.map +1 -1
  420. package/dist/esm/paneview/options.js +1 -1
  421. package/dist/esm/paneview/paneview.d.ts +40 -40
  422. package/dist/esm/paneview/paneview.d.ts.map +1 -1
  423. package/dist/esm/paneview/paneview.js +145 -145
  424. package/dist/esm/paneview/paneview.js.map +1 -1
  425. package/dist/esm/paneview/paneviewComponent.d.ts +128 -128
  426. package/dist/esm/paneview/paneviewComponent.js +276 -273
  427. package/dist/esm/paneview/paneviewComponent.js.map +1 -1
  428. package/dist/esm/paneview/paneviewPanel.d.ts +92 -92
  429. package/dist/esm/paneview/paneviewPanel.d.ts.map +1 -1
  430. package/dist/esm/paneview/paneviewPanel.js +192 -192
  431. package/dist/esm/paneview/paneviewPanel.js.map +1 -1
  432. package/dist/esm/popoutWindow.d.ts +18 -0
  433. package/dist/esm/popoutWindow.d.ts.map +1 -0
  434. package/dist/esm/popoutWindow.js +88 -0
  435. package/dist/esm/popoutWindow.js.map +1 -0
  436. package/dist/esm/resizable.d.ts +10 -7
  437. package/dist/esm/resizable.d.ts.map +1 -1
  438. package/dist/esm/resizable.js +48 -38
  439. package/dist/esm/resizable.js.map +1 -1
  440. package/dist/esm/splitview/options.d.ts +26 -27
  441. package/dist/esm/splitview/options.d.ts.map +1 -1
  442. package/dist/esm/splitview/options.js +1 -1
  443. package/dist/esm/splitview/splitview.d.ts +129 -128
  444. package/dist/esm/splitview/splitview.d.ts.map +1 -1
  445. package/dist/esm/splitview/splitview.js +721 -704
  446. package/dist/esm/splitview/splitview.js.map +1 -1
  447. package/dist/esm/splitview/splitviewComponent.d.ts +101 -101
  448. package/dist/esm/splitview/splitviewComponent.js +261 -258
  449. package/dist/esm/splitview/splitviewComponent.js.map +1 -1
  450. package/dist/esm/splitview/splitviewPanel.d.ts +45 -45
  451. package/dist/esm/splitview/splitviewPanel.d.ts.map +1 -1
  452. package/dist/esm/splitview/splitviewPanel.js +108 -108
  453. package/dist/esm/splitview/splitviewPanel.js.map +1 -1
  454. package/dist/esm/splitview/viewItem.d.ts +25 -25
  455. package/dist/esm/splitview/viewItem.js +74 -74
  456. package/dist/esm/splitview/viewItem.js.map +1 -1
  457. package/dist/esm/svg.d.ts +3 -3
  458. package/dist/esm/svg.js +31 -31
  459. package/dist/esm/types.d.ts +8 -2
  460. package/dist/esm/types.d.ts.map +1 -1
  461. package/dist/esm/types.js +1 -1
  462. package/dist/styles/dockview.css +33 -2
  463. package/package.json +30 -42
  464. package/LICENSE +0 -21
@@ -1,548 +1,628 @@
1
- "use strict";
2
- /*---------------------------------------------------------------------------------------------
3
- * Accreditation: This file is largly based upon the MIT licenced VSCode sourcecode found at:
4
- * https://github.com/microsoft/vscode/tree/main/src/vs/base/browser/ui/grid
5
- *--------------------------------------------------------------------------------------------*/
6
- var __read = (this && this.__read) || function (o, n) {
7
- var m = typeof Symbol === "function" && o[Symbol.iterator];
8
- if (!m) return o;
9
- var i = m.call(o), r, ar = [], e;
10
- try {
11
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
12
- }
13
- catch (error) { e = { error: error }; }
14
- finally {
15
- try {
16
- if (r && !r.done && (m = i["return"])) m.call(i);
17
- }
18
- finally { if (e) throw e.error; }
19
- }
20
- return ar;
21
- };
22
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
23
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
24
- if (ar || !(i in from)) {
25
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
26
- ar[i] = from[i];
27
- }
28
- }
29
- return to.concat(ar || Array.prototype.slice.call(from));
30
- };
31
- Object.defineProperty(exports, "__esModule", { value: true });
32
- exports.Gridview = exports.isGridBranchNode = exports.orthogonal = exports.getLocationOrientation = exports.getDirectionOrientation = exports.getRelativeLocation = exports.getGridLocation = exports.indexInParent = void 0;
33
- var splitview_1 = require("../splitview/splitview");
34
- var array_1 = require("../array");
35
- var leafNode_1 = require("./leafNode");
36
- var branchNode_1 = require("./branchNode");
37
- var events_1 = require("../events");
38
- var lifecycle_1 = require("../lifecycle");
39
- function findLeaf(candiateNode, last) {
40
- if (candiateNode instanceof leafNode_1.LeafNode) {
41
- return candiateNode;
42
- }
43
- if (candiateNode instanceof branchNode_1.BranchNode) {
44
- return findLeaf(candiateNode.children[last ? candiateNode.children.length - 1 : 0], last);
45
- }
46
- throw new Error('invalid node');
47
- }
48
- function flipNode(node, size, orthogonalSize) {
49
- if (node instanceof branchNode_1.BranchNode) {
50
- var result = new branchNode_1.BranchNode((0, exports.orthogonal)(node.orientation), node.proportionalLayout, node.styles, size, orthogonalSize);
51
- var totalSize = 0;
52
- for (var i = node.children.length - 1; i >= 0; i--) {
53
- var child = node.children[i];
54
- var childSize = child instanceof branchNode_1.BranchNode ? child.orthogonalSize : child.size;
55
- var newSize = node.size === 0
56
- ? 0
57
- : Math.round((size * childSize) / node.size);
58
- totalSize += newSize;
59
- // The last view to add should adjust to rounding errors
60
- if (i === 0) {
61
- newSize += size - totalSize;
62
- }
63
- result.addChild(flipNode(child, orthogonalSize, newSize), newSize, 0, true);
64
- }
65
- return result;
66
- }
67
- else {
68
- return new leafNode_1.LeafNode(node.view, (0, exports.orthogonal)(node.orientation), orthogonalSize);
69
- }
70
- }
71
- function indexInParent(element) {
72
- var parentElement = element.parentElement;
73
- if (!parentElement) {
74
- throw new Error('Invalid grid element');
75
- }
76
- var el = parentElement.firstElementChild;
77
- var index = 0;
78
- while (el !== element && el !== parentElement.lastElementChild && el) {
79
- el = el.nextElementSibling;
80
- index++;
81
- }
82
- return index;
83
- }
84
- exports.indexInParent = indexInParent;
85
- /**
86
- * Find the grid location of a specific DOM element by traversing the parent
87
- * chain and finding each child index on the way.
88
- *
89
- * This will break as soon as DOM structures of the Splitview or Gridview change.
90
- */
91
- function getGridLocation(element) {
92
- var parentElement = element.parentElement;
93
- if (!parentElement) {
94
- throw new Error('Invalid grid element');
95
- }
96
- if (/\bgrid-view\b/.test(parentElement.className)) {
97
- return [];
98
- }
99
- var index = indexInParent(parentElement);
100
- var ancestor = parentElement.parentElement.parentElement.parentElement;
101
- return __spreadArray(__spreadArray([], __read(getGridLocation(ancestor)), false), [index], false);
102
- }
103
- exports.getGridLocation = getGridLocation;
104
- function getRelativeLocation(rootOrientation, location, direction) {
105
- var orientation = getLocationOrientation(rootOrientation, location);
106
- var directionOrientation = getDirectionOrientation(direction);
107
- if (orientation === directionOrientation) {
108
- var _a = __read((0, array_1.tail)(location), 2), rest = _a[0], _index = _a[1];
109
- var index = _index;
110
- if (direction === 'right' || direction === 'bottom') {
111
- index += 1;
112
- }
113
- return __spreadArray(__spreadArray([], __read(rest), false), [index], false);
114
- }
115
- else {
116
- var index = direction === 'right' || direction === 'bottom' ? 1 : 0;
117
- return __spreadArray(__spreadArray([], __read(location), false), [index], false);
118
- }
119
- }
120
- exports.getRelativeLocation = getRelativeLocation;
121
- function getDirectionOrientation(direction) {
122
- return direction === 'top' || direction === 'bottom'
123
- ? splitview_1.Orientation.VERTICAL
124
- : splitview_1.Orientation.HORIZONTAL;
125
- }
126
- exports.getDirectionOrientation = getDirectionOrientation;
127
- function getLocationOrientation(rootOrientation, location) {
128
- return location.length % 2 === 0
129
- ? (0, exports.orthogonal)(rootOrientation)
130
- : rootOrientation;
131
- }
132
- exports.getLocationOrientation = getLocationOrientation;
133
- var orthogonal = function (orientation) {
134
- return orientation === splitview_1.Orientation.HORIZONTAL
135
- ? splitview_1.Orientation.VERTICAL
136
- : splitview_1.Orientation.HORIZONTAL;
137
- };
138
- exports.orthogonal = orthogonal;
139
- function isGridBranchNode(node) {
140
- return !!node.children;
141
- }
142
- exports.isGridBranchNode = isGridBranchNode;
143
- var serializeBranchNode = function (node, orientation) {
144
- var size = orientation === splitview_1.Orientation.VERTICAL ? node.box.width : node.box.height;
145
- if (!isGridBranchNode(node)) {
146
- if (typeof node.cachedVisibleSize === 'number') {
147
- return {
148
- type: 'leaf',
149
- data: node.view.toJSON(),
150
- size: node.cachedVisibleSize,
151
- visible: false,
152
- };
153
- }
154
- return { type: 'leaf', data: node.view.toJSON(), size: size };
155
- }
156
- return {
157
- type: 'branch',
158
- data: node.children.map(function (c) {
159
- return serializeBranchNode(c, (0, exports.orthogonal)(orientation));
160
- }),
161
- size: size,
162
- };
163
- };
164
- var Gridview = /** @class */ (function () {
165
- function Gridview(proportionalLayout, styles, orientation) {
166
- this.proportionalLayout = proportionalLayout;
167
- this.styles = styles;
168
- this.disposable = new lifecycle_1.MutableDisposable();
169
- this._onDidChange = new events_1.Emitter();
170
- this.onDidChange = this._onDidChange.event;
171
- this.element = document.createElement('div');
172
- this.element.className = 'grid-view';
173
- this.root = new branchNode_1.BranchNode(orientation, proportionalLayout, styles, 0, 0);
174
- }
175
- Object.defineProperty(Gridview.prototype, "length", {
176
- get: function () {
177
- return this._root ? this._root.children.length : 0;
178
- },
179
- enumerable: false,
180
- configurable: true
181
- });
182
- Object.defineProperty(Gridview.prototype, "orientation", {
183
- get: function () {
184
- return this.root.orientation;
185
- },
186
- set: function (orientation) {
187
- if (this.root.orientation === orientation) {
188
- return;
189
- }
190
- var _a = this.root, size = _a.size, orthogonalSize = _a.orthogonalSize;
191
- this.root = flipNode(this.root, orthogonalSize, size);
192
- this.root.layout(size, orthogonalSize);
193
- },
194
- enumerable: false,
195
- configurable: true
196
- });
197
- Object.defineProperty(Gridview.prototype, "width", {
198
- get: function () {
199
- return this.root.width;
200
- },
201
- enumerable: false,
202
- configurable: true
203
- });
204
- Object.defineProperty(Gridview.prototype, "height", {
205
- get: function () {
206
- return this.root.height;
207
- },
208
- enumerable: false,
209
- configurable: true
210
- });
211
- Object.defineProperty(Gridview.prototype, "minimumWidth", {
212
- get: function () {
213
- return this.root.minimumWidth;
214
- },
215
- enumerable: false,
216
- configurable: true
217
- });
218
- Object.defineProperty(Gridview.prototype, "minimumHeight", {
219
- get: function () {
220
- return this.root.minimumHeight;
221
- },
222
- enumerable: false,
223
- configurable: true
224
- });
225
- Object.defineProperty(Gridview.prototype, "maximumWidth", {
226
- get: function () {
227
- return this.root.maximumHeight;
228
- },
229
- enumerable: false,
230
- configurable: true
231
- });
232
- Object.defineProperty(Gridview.prototype, "maximumHeight", {
233
- get: function () {
234
- return this.root.maximumHeight;
235
- },
236
- enumerable: false,
237
- configurable: true
238
- });
239
- Gridview.prototype.serialize = function () {
240
- var root = serializeBranchNode(this.getView(), this.orientation);
241
- return {
242
- root: root,
243
- width: this.width,
244
- height: this.height,
245
- orientation: this.orientation,
246
- };
247
- };
248
- Gridview.prototype.dispose = function () {
249
- this.disposable.dispose();
250
- this._onDidChange.dispose();
251
- this.root.dispose();
252
- this.element.remove();
253
- };
254
- Gridview.prototype.clear = function () {
255
- var orientation = this.root.orientation;
256
- this.root = new branchNode_1.BranchNode(orientation, this.proportionalLayout, this.styles, this.root.size, this.root.orthogonalSize);
257
- };
258
- Gridview.prototype.deserialize = function (json, deserializer) {
259
- var orientation = json.orientation;
260
- var height = orientation === splitview_1.Orientation.VERTICAL ? json.height : json.width;
261
- this._deserialize(json.root, orientation, deserializer, height);
262
- };
263
- Gridview.prototype._deserialize = function (root, orientation, deserializer, orthogonalSize) {
264
- this.root = this._deserializeNode(root, orientation, deserializer, orthogonalSize);
265
- };
266
- Gridview.prototype._deserializeNode = function (node, orientation, deserializer, orthogonalSize) {
267
- var _this = this;
268
- var result;
269
- if (node.type === 'branch') {
270
- var serializedChildren = node.data;
271
- var children = serializedChildren.map(function (serializedChild) {
272
- return {
273
- node: _this._deserializeNode(serializedChild, (0, exports.orthogonal)(orientation), deserializer, node.size),
274
- visible: serializedChild.visible,
275
- };
276
- });
277
- result = new branchNode_1.BranchNode(orientation, this.proportionalLayout, this.styles, node.size, // <- orthogonal size - flips at each depth
278
- orthogonalSize, // <- size - flips at each depth
279
- children);
280
- }
281
- else {
282
- result = new leafNode_1.LeafNode(deserializer.fromJSON(node), orientation, orthogonalSize, node.size);
283
- }
284
- return result;
285
- };
286
- Object.defineProperty(Gridview.prototype, "root", {
287
- get: function () {
288
- return this._root;
289
- },
290
- set: function (root) {
291
- var _this = this;
292
- var oldRoot = this._root;
293
- if (oldRoot) {
294
- oldRoot.dispose();
295
- this.element.removeChild(oldRoot.element);
296
- }
297
- this._root = root;
298
- this.element.appendChild(this._root.element);
299
- this.disposable.value = this._root.onDidChange(function (e) {
300
- _this._onDidChange.fire(e);
301
- });
302
- },
303
- enumerable: false,
304
- configurable: true
305
- });
306
- /**
307
- * If the root is orientated as a VERTICAL node then nest the existing root within a new HORIZIONTAL root node
308
- * If the root is orientated as a HORIZONTAL node then nest the existing root within a new VERITCAL root node
309
- */
310
- Gridview.prototype.insertOrthogonalSplitviewAtRoot = function () {
311
- var _this = this;
312
- if (!this._root) {
313
- return;
314
- }
315
- var oldRoot = this.root;
316
- oldRoot.element.remove();
317
- this._root = new branchNode_1.BranchNode((0, exports.orthogonal)(oldRoot.orientation), this.proportionalLayout, this.styles, this.root.orthogonalSize, this.root.size);
318
- if (oldRoot.children.length === 0) {
319
- // no data so no need to add anything back in
320
- }
321
- else if (oldRoot.children.length === 1) {
322
- // can remove one level of redundant branching if there is only a single child
323
- var childReference = oldRoot.children[0];
324
- var child = oldRoot.removeChild(0); // remove to prevent disposal when disposing of unwanted root
325
- child.dispose();
326
- oldRoot.dispose();
327
- this._root.addChild(
328
- /**
329
- * the child node will have the same orientation as the new root since
330
- * we are removing the inbetween node.
331
- * the entire 'tree' must be flipped recursively to ensure that the orientation
332
- * flips at each level
333
- */
334
- flipNode(childReference, childReference.orthogonalSize, childReference.size), splitview_1.Sizing.Distribute, 0);
335
- }
336
- else {
337
- this._root.addChild(oldRoot, splitview_1.Sizing.Distribute, 0);
338
- }
339
- this.element.appendChild(this._root.element);
340
- this.disposable.value = this._root.onDidChange(function (e) {
341
- _this._onDidChange.fire(e);
342
- });
343
- };
344
- Gridview.prototype.next = function (location) {
345
- return this.progmaticSelect(location);
346
- };
347
- Gridview.prototype.previous = function (location) {
348
- return this.progmaticSelect(location, true);
349
- };
350
- Gridview.prototype.getView = function (location) {
351
- var node = location ? this.getNode(location)[1] : this.root;
352
- return this._getViews(node, this.orientation);
353
- };
354
- Gridview.prototype._getViews = function (node, orientation, cachedVisibleSize) {
355
- var box = { height: node.height, width: node.width };
356
- if (node instanceof leafNode_1.LeafNode) {
357
- return { box: box, view: node.view, cachedVisibleSize: cachedVisibleSize };
358
- }
359
- var children = [];
360
- for (var i = 0; i < node.children.length; i++) {
361
- var child = node.children[i];
362
- var nodeCachedVisibleSize = node.getChildCachedVisibleSize(i);
363
- children.push(this._getViews(child, (0, exports.orthogonal)(orientation), nodeCachedVisibleSize));
364
- }
365
- return { box: box, children: children };
366
- };
367
- Gridview.prototype.progmaticSelect = function (location, reverse) {
368
- if (reverse === void 0) { reverse = false; }
369
- var _a = __read(this.getNode(location), 2), path = _a[0], node = _a[1];
370
- if (!(node instanceof leafNode_1.LeafNode)) {
371
- throw new Error('invalid location');
372
- }
373
- for (var i = path.length - 1; i > -1; i--) {
374
- var n = path[i];
375
- var l = location[i] || 0;
376
- var canProgressInCurrentLevel = reverse
377
- ? l - 1 > -1
378
- : l + 1 < n.children.length;
379
- if (canProgressInCurrentLevel) {
380
- return findLeaf(n.children[reverse ? l - 1 : l + 1], reverse);
381
- }
382
- }
383
- return findLeaf(this.root, reverse);
384
- };
385
- Gridview.prototype.isViewVisible = function (location) {
386
- var _a = __read((0, array_1.tail)(location), 2), rest = _a[0], index = _a[1];
387
- var _b = __read(this.getNode(rest), 2), parent = _b[1];
388
- if (!(parent instanceof branchNode_1.BranchNode)) {
389
- throw new Error('Invalid from location');
390
- }
391
- return parent.isChildVisible(index);
392
- };
393
- Gridview.prototype.setViewVisible = function (location, visible) {
394
- var _a = __read((0, array_1.tail)(location), 2), rest = _a[0], index = _a[1];
395
- var _b = __read(this.getNode(rest), 2), parent = _b[1];
396
- if (!(parent instanceof branchNode_1.BranchNode)) {
397
- throw new Error('Invalid from location');
398
- }
399
- parent.setChildVisible(index, visible);
400
- };
401
- Gridview.prototype.moveView = function (parentLocation, from, to) {
402
- var _a = __read(this.getNode(parentLocation), 2), parent = _a[1];
403
- if (!(parent instanceof branchNode_1.BranchNode)) {
404
- throw new Error('Invalid location');
405
- }
406
- parent.moveChild(from, to);
407
- };
408
- Gridview.prototype.addView = function (view, size, location) {
409
- var _a = __read((0, array_1.tail)(location), 2), rest = _a[0], index = _a[1];
410
- var _b = __read(this.getNode(rest), 2), pathToParent = _b[0], parent = _b[1];
411
- if (parent instanceof branchNode_1.BranchNode) {
412
- var node = new leafNode_1.LeafNode(view, (0, exports.orthogonal)(parent.orientation), parent.orthogonalSize);
413
- parent.addChild(node, size, index);
414
- }
415
- else {
416
- var _c = __read(__spreadArray([], __read(pathToParent), false).reverse()), grandParent = _c[0], _ = _c.slice(1);
417
- var _d = __read(__spreadArray([], __read(rest), false).reverse()), parentIndex = _d[0], __ = _d.slice(1);
418
- var newSiblingSize = 0;
419
- var newSiblingCachedVisibleSize = grandParent.getChildCachedVisibleSize(parentIndex);
420
- if (typeof newSiblingCachedVisibleSize === 'number') {
421
- newSiblingSize = splitview_1.Sizing.Invisible(newSiblingCachedVisibleSize);
422
- }
423
- var child = grandParent.removeChild(parentIndex);
424
- child.dispose();
425
- var newParent = new branchNode_1.BranchNode(parent.orientation, this.proportionalLayout, this.styles, parent.size, parent.orthogonalSize);
426
- grandParent.addChild(newParent, parent.size, parentIndex);
427
- var newSibling = new leafNode_1.LeafNode(parent.view, grandParent.orientation, parent.size);
428
- newParent.addChild(newSibling, newSiblingSize, 0);
429
- if (typeof size !== 'number' && size.type === 'split') {
430
- size = { type: 'split', index: 0 };
431
- }
432
- var node = new leafNode_1.LeafNode(view, grandParent.orientation, parent.size);
433
- newParent.addChild(node, size, index);
434
- }
435
- };
436
- Gridview.prototype.remove = function (view, sizing) {
437
- var location = getGridLocation(view.element);
438
- return this.removeView(location, sizing);
439
- };
440
- Gridview.prototype.removeView = function (location, sizing) {
441
- var _a = __read((0, array_1.tail)(location), 2), rest = _a[0], index = _a[1];
442
- var _b = __read(this.getNode(rest), 2), pathToParent = _b[0], parent = _b[1];
443
- if (!(parent instanceof branchNode_1.BranchNode)) {
444
- throw new Error('Invalid location');
445
- }
446
- var nodeToRemove = parent.children[index];
447
- if (!(nodeToRemove instanceof leafNode_1.LeafNode)) {
448
- throw new Error('Invalid location');
449
- }
450
- parent.removeChild(index, sizing);
451
- nodeToRemove.dispose();
452
- if (parent.children.length !== 1) {
453
- return nodeToRemove.view;
454
- }
455
- // if the parent has only one child and we know the parent is a BranchNode we can make the tree
456
- // more efficiently spaced by replacing the parent BranchNode with the child.
457
- // if that child is a LeafNode then we simply replace the BranchNode with the child otherwise if the child
458
- // is a BranchNode too we should spread it's children into the grandparent.
459
- // refer to the remaining child as the sibling
460
- var sibling = parent.children[0];
461
- if (pathToParent.length === 0) {
462
- // if the parent is root
463
- if (sibling instanceof leafNode_1.LeafNode) {
464
- // if the sibling is a leaf node no action is required
465
- return nodeToRemove.view;
466
- }
467
- // otherwise the sibling is a branch node. since the parent is the root and the root has only one child
468
- // which is a branch node we can just set this branch node to be the new root node
469
- // for good housekeeping we'll removing the sibling from it's existing tree
470
- parent.removeChild(0, sizing);
471
- // and set that sibling node to be root
472
- this.root = sibling;
473
- return nodeToRemove.view;
474
- }
475
- // otherwise the parent is apart of a large sub-tree
476
- var _c = __read(__spreadArray([], __read(pathToParent), false).reverse()), grandParent = _c[0], _ = _c.slice(1);
477
- var _d = __read(__spreadArray([], __read(rest), false).reverse()), parentIndex = _d[0], __ = _d.slice(1);
478
- var isSiblingVisible = parent.isChildVisible(0);
479
- // either way we need to remove the sibling from it's existing tree
480
- parent.removeChild(0, sizing);
481
- // note the sizes of all of the grandparents children
482
- var sizes = grandParent.children.map(function (_size, i) {
483
- return grandParent.getChildSize(i);
484
- });
485
- // remove the parent from the grandparent since we are moving the sibling to take the parents place
486
- // this parent is no longer used and can be disposed of
487
- grandParent.removeChild(parentIndex, sizing).dispose();
488
- if (sibling instanceof branchNode_1.BranchNode) {
489
- // replace the parent with the siblings children
490
- sizes.splice.apply(sizes, __spreadArray([parentIndex,
491
- 1], __read(sibling.children.map(function (c) { return c.size; })), false));
492
- // and add those siblings to the grandparent
493
- for (var i = 0; i < sibling.children.length; i++) {
494
- var child = sibling.children[i];
495
- grandParent.addChild(child, child.size, parentIndex + i);
496
- }
497
- /**
498
- * clean down the branch node since we need to dipose of it and
499
- * when .dispose() it called on a branch it will dispose of any
500
- * views it is holding onto.
501
- */
502
- while (sibling.children.length > 0) {
503
- sibling.removeChild(0);
504
- }
505
- }
506
- else {
507
- // otherwise create a new leaf node and add that to the grandparent
508
- var newSibling = new leafNode_1.LeafNode(sibling.view, (0, exports.orthogonal)(sibling.orientation), sibling.size);
509
- var siblingSizing = isSiblingVisible
510
- ? sibling.orthogonalSize
511
- : splitview_1.Sizing.Invisible(sibling.orthogonalSize);
512
- grandParent.addChild(newSibling, siblingSizing, parentIndex);
513
- }
514
- // the containing node of the sibling is no longer required and can be disposed of
515
- sibling.dispose();
516
- // resize everything
517
- for (var i = 0; i < sizes.length; i++) {
518
- grandParent.resizeChild(i, sizes[i]);
519
- }
520
- return nodeToRemove.view;
521
- };
522
- Gridview.prototype.layout = function (width, height) {
523
- var _a = __read(this.root.orientation === splitview_1.Orientation.HORIZONTAL
524
- ? [height, width]
525
- : [width, height], 2), size = _a[0], orthogonalSize = _a[1];
526
- this.root.layout(size, orthogonalSize);
527
- };
528
- Gridview.prototype.getNode = function (location, node, path) {
529
- if (node === void 0) { node = this.root; }
530
- if (path === void 0) { path = []; }
531
- if (location.length === 0) {
532
- return [path, node];
533
- }
534
- if (!(node instanceof branchNode_1.BranchNode)) {
535
- throw new Error('Invalid location');
536
- }
537
- var _a = __read(location), index = _a[0], rest = _a.slice(1);
538
- if (index < 0 || index >= node.children.length) {
539
- throw new Error('Invalid location');
540
- }
541
- var child = node.children[index];
542
- path.push(node);
543
- return this.getNode(rest, child, path);
544
- };
545
- return Gridview;
546
- }());
547
- exports.Gridview = Gridview;
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Accreditation: This file is largly based upon the MIT licenced VSCode sourcecode found at:
4
+ * https://github.com/microsoft/vscode/tree/main/src/vs/base/browser/ui/grid
5
+ *--------------------------------------------------------------------------------------------*/
6
+ var __read = (this && this.__read) || function (o, n) {
7
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
8
+ if (!m) return o;
9
+ var i = m.call(o), r, ar = [], e;
10
+ try {
11
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
12
+ }
13
+ catch (error) { e = { error: error }; }
14
+ finally {
15
+ try {
16
+ if (r && !r.done && (m = i["return"])) m.call(i);
17
+ }
18
+ finally { if (e) throw e.error; }
19
+ }
20
+ return ar;
21
+ };
22
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
23
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
24
+ if (ar || !(i in from)) {
25
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
26
+ ar[i] = from[i];
27
+ }
28
+ }
29
+ return to.concat(ar || Array.prototype.slice.call(from));
30
+ };
31
+ Object.defineProperty(exports, "__esModule", { value: true });
32
+ exports.Gridview = exports.isGridBranchNode = exports.orthogonal = exports.getLocationOrientation = exports.getDirectionOrientation = exports.getRelativeLocation = exports.getGridLocation = exports.indexInParent = void 0;
33
+ var splitview_1 = require("../splitview/splitview");
34
+ var array_1 = require("../array");
35
+ var leafNode_1 = require("./leafNode");
36
+ var branchNode_1 = require("./branchNode");
37
+ var events_1 = require("../events");
38
+ var lifecycle_1 = require("../lifecycle");
39
+ function findLeaf(candiateNode, last) {
40
+ if (candiateNode instanceof leafNode_1.LeafNode) {
41
+ return candiateNode;
42
+ }
43
+ if (candiateNode instanceof branchNode_1.BranchNode) {
44
+ return findLeaf(candiateNode.children[last ? candiateNode.children.length - 1 : 0], last);
45
+ }
46
+ throw new Error('invalid node');
47
+ }
48
+ function flipNode(node, size, orthogonalSize) {
49
+ if (node instanceof branchNode_1.BranchNode) {
50
+ var result = new branchNode_1.BranchNode((0, exports.orthogonal)(node.orientation), node.proportionalLayout, node.styles, size, orthogonalSize);
51
+ var totalSize = 0;
52
+ for (var i = node.children.length - 1; i >= 0; i--) {
53
+ var child = node.children[i];
54
+ var childSize = child instanceof branchNode_1.BranchNode ? child.orthogonalSize : child.size;
55
+ var newSize = node.size === 0
56
+ ? 0
57
+ : Math.round((size * childSize) / node.size);
58
+ totalSize += newSize;
59
+ // The last view to add should adjust to rounding errors
60
+ if (i === 0) {
61
+ newSize += size - totalSize;
62
+ }
63
+ result.addChild(flipNode(child, orthogonalSize, newSize), newSize, 0, true);
64
+ }
65
+ return result;
66
+ }
67
+ else {
68
+ return new leafNode_1.LeafNode(node.view, (0, exports.orthogonal)(node.orientation), orthogonalSize);
69
+ }
70
+ }
71
+ function indexInParent(element) {
72
+ var parentElement = element.parentElement;
73
+ if (!parentElement) {
74
+ throw new Error('Invalid grid element');
75
+ }
76
+ var el = parentElement.firstElementChild;
77
+ var index = 0;
78
+ while (el !== element && el !== parentElement.lastElementChild && el) {
79
+ el = el.nextElementSibling;
80
+ index++;
81
+ }
82
+ return index;
83
+ }
84
+ exports.indexInParent = indexInParent;
85
+ /**
86
+ * Find the grid location of a specific DOM element by traversing the parent
87
+ * chain and finding each child index on the way.
88
+ *
89
+ * This will break as soon as DOM structures of the Splitview or Gridview change.
90
+ */
91
+ function getGridLocation(element) {
92
+ var parentElement = element.parentElement;
93
+ if (!parentElement) {
94
+ throw new Error('Invalid grid element');
95
+ }
96
+ if (/\bgrid-view\b/.test(parentElement.className)) {
97
+ return [];
98
+ }
99
+ var index = indexInParent(parentElement);
100
+ var ancestor = parentElement.parentElement.parentElement.parentElement;
101
+ return __spreadArray(__spreadArray([], __read(getGridLocation(ancestor)), false), [index], false);
102
+ }
103
+ exports.getGridLocation = getGridLocation;
104
+ function getRelativeLocation(rootOrientation, location, direction) {
105
+ var orientation = getLocationOrientation(rootOrientation, location);
106
+ var directionOrientation = getDirectionOrientation(direction);
107
+ if (orientation === directionOrientation) {
108
+ var _a = __read((0, array_1.tail)(location), 2), rest = _a[0], _index = _a[1];
109
+ var index = _index;
110
+ if (direction === 'right' || direction === 'bottom') {
111
+ index += 1;
112
+ }
113
+ return __spreadArray(__spreadArray([], __read(rest), false), [index], false);
114
+ }
115
+ else {
116
+ var index = direction === 'right' || direction === 'bottom' ? 1 : 0;
117
+ return __spreadArray(__spreadArray([], __read(location), false), [index], false);
118
+ }
119
+ }
120
+ exports.getRelativeLocation = getRelativeLocation;
121
+ function getDirectionOrientation(direction) {
122
+ return direction === 'top' || direction === 'bottom'
123
+ ? splitview_1.Orientation.VERTICAL
124
+ : splitview_1.Orientation.HORIZONTAL;
125
+ }
126
+ exports.getDirectionOrientation = getDirectionOrientation;
127
+ function getLocationOrientation(rootOrientation, location) {
128
+ return location.length % 2 === 0
129
+ ? (0, exports.orthogonal)(rootOrientation)
130
+ : rootOrientation;
131
+ }
132
+ exports.getLocationOrientation = getLocationOrientation;
133
+ var orthogonal = function (orientation) {
134
+ return orientation === splitview_1.Orientation.HORIZONTAL
135
+ ? splitview_1.Orientation.VERTICAL
136
+ : splitview_1.Orientation.HORIZONTAL;
137
+ };
138
+ exports.orthogonal = orthogonal;
139
+ function isGridBranchNode(node) {
140
+ return !!node.children;
141
+ }
142
+ exports.isGridBranchNode = isGridBranchNode;
143
+ var serializeBranchNode = function (node, orientation) {
144
+ var size = orientation === splitview_1.Orientation.VERTICAL ? node.box.width : node.box.height;
145
+ if (!isGridBranchNode(node)) {
146
+ if (typeof node.cachedVisibleSize === 'number') {
147
+ return {
148
+ type: 'leaf',
149
+ data: node.view.toJSON(),
150
+ size: node.cachedVisibleSize,
151
+ visible: false,
152
+ };
153
+ }
154
+ return { type: 'leaf', data: node.view.toJSON(), size: size };
155
+ }
156
+ return {
157
+ type: 'branch',
158
+ data: node.children.map(function (c) {
159
+ return serializeBranchNode(c, (0, exports.orthogonal)(orientation));
160
+ }),
161
+ size: size,
162
+ };
163
+ };
164
+ var Gridview = /** @class */ (function () {
165
+ function Gridview(proportionalLayout, styles, orientation) {
166
+ this.proportionalLayout = proportionalLayout;
167
+ this.styles = styles;
168
+ this._maximizedNode = undefined;
169
+ this.disposable = new lifecycle_1.MutableDisposable();
170
+ this._onDidChange = new events_1.Emitter();
171
+ this.onDidChange = this._onDidChange.event;
172
+ this._onDidMaxmizedNodeChange = new events_1.Emitter();
173
+ this.onDidMaxmizedNodeChange = this._onDidMaxmizedNodeChange.event;
174
+ this.element = document.createElement('div');
175
+ this.element.className = 'grid-view';
176
+ this.root = new branchNode_1.BranchNode(orientation, proportionalLayout, styles, 0, 0);
177
+ }
178
+ Object.defineProperty(Gridview.prototype, "length", {
179
+ get: function () {
180
+ return this._root ? this._root.children.length : 0;
181
+ },
182
+ enumerable: false,
183
+ configurable: true
184
+ });
185
+ Object.defineProperty(Gridview.prototype, "orientation", {
186
+ get: function () {
187
+ return this.root.orientation;
188
+ },
189
+ set: function (orientation) {
190
+ if (this.root.orientation === orientation) {
191
+ return;
192
+ }
193
+ var _a = this.root, size = _a.size, orthogonalSize = _a.orthogonalSize;
194
+ this.root = flipNode(this.root, orthogonalSize, size);
195
+ this.root.layout(size, orthogonalSize);
196
+ },
197
+ enumerable: false,
198
+ configurable: true
199
+ });
200
+ Object.defineProperty(Gridview.prototype, "width", {
201
+ get: function () {
202
+ return this.root.width;
203
+ },
204
+ enumerable: false,
205
+ configurable: true
206
+ });
207
+ Object.defineProperty(Gridview.prototype, "height", {
208
+ get: function () {
209
+ return this.root.height;
210
+ },
211
+ enumerable: false,
212
+ configurable: true
213
+ });
214
+ Object.defineProperty(Gridview.prototype, "minimumWidth", {
215
+ get: function () {
216
+ return this.root.minimumWidth;
217
+ },
218
+ enumerable: false,
219
+ configurable: true
220
+ });
221
+ Object.defineProperty(Gridview.prototype, "minimumHeight", {
222
+ get: function () {
223
+ return this.root.minimumHeight;
224
+ },
225
+ enumerable: false,
226
+ configurable: true
227
+ });
228
+ Object.defineProperty(Gridview.prototype, "maximumWidth", {
229
+ get: function () {
230
+ return this.root.maximumHeight;
231
+ },
232
+ enumerable: false,
233
+ configurable: true
234
+ });
235
+ Object.defineProperty(Gridview.prototype, "maximumHeight", {
236
+ get: function () {
237
+ return this.root.maximumHeight;
238
+ },
239
+ enumerable: false,
240
+ configurable: true
241
+ });
242
+ Gridview.prototype.maximizedView = function () {
243
+ var _a;
244
+ return (_a = this._maximizedNode) === null || _a === void 0 ? void 0 : _a.view;
245
+ };
246
+ Gridview.prototype.hasMaximizedView = function () {
247
+ return this._maximizedNode !== undefined;
248
+ };
249
+ Gridview.prototype.maximizeView = function (view) {
250
+ var location = getGridLocation(view.element);
251
+ var _a = __read(this.getNode(location), 2), _ = _a[0], node = _a[1];
252
+ if (!(node instanceof leafNode_1.LeafNode)) {
253
+ return;
254
+ }
255
+ if (this._maximizedNode === node) {
256
+ return;
257
+ }
258
+ if (this.hasMaximizedView()) {
259
+ this.exitMaximizedView();
260
+ }
261
+ function hideAllViewsBut(parent, exclude) {
262
+ for (var i = 0; i < parent.children.length; i++) {
263
+ var child = parent.children[i];
264
+ if (child instanceof leafNode_1.LeafNode) {
265
+ if (child !== exclude) {
266
+ parent.setChildVisible(i, false);
267
+ }
268
+ }
269
+ else {
270
+ hideAllViewsBut(child, exclude);
271
+ }
272
+ }
273
+ }
274
+ hideAllViewsBut(this.root, node);
275
+ this._maximizedNode = node;
276
+ this._onDidMaxmizedNodeChange.fire();
277
+ };
278
+ Gridview.prototype.exitMaximizedView = function () {
279
+ if (!this._maximizedNode) {
280
+ return;
281
+ }
282
+ function showViewsInReverseOrder(parent) {
283
+ for (var index = parent.children.length - 1; index >= 0; index--) {
284
+ var child = parent.children[index];
285
+ if (child instanceof leafNode_1.LeafNode) {
286
+ parent.setChildVisible(index, true);
287
+ }
288
+ else {
289
+ showViewsInReverseOrder(child);
290
+ }
291
+ }
292
+ }
293
+ showViewsInReverseOrder(this.root);
294
+ this._maximizedNode = undefined;
295
+ this._onDidMaxmizedNodeChange.fire();
296
+ };
297
+ Gridview.prototype.serialize = function () {
298
+ if (this.hasMaximizedView()) {
299
+ /**
300
+ * do not persist maximized view state but we must first exit any maximized views
301
+ * before serialization to ensure the correct dimensions are persisted
302
+ */
303
+ this.exitMaximizedView();
304
+ }
305
+ var root = serializeBranchNode(this.getView(), this.orientation);
306
+ return {
307
+ root: root,
308
+ width: this.width,
309
+ height: this.height,
310
+ orientation: this.orientation,
311
+ };
312
+ };
313
+ Gridview.prototype.dispose = function () {
314
+ this.disposable.dispose();
315
+ this._onDidChange.dispose();
316
+ this._onDidMaxmizedNodeChange.dispose();
317
+ this.root.dispose();
318
+ this._maximizedNode = undefined;
319
+ this.element.remove();
320
+ };
321
+ Gridview.prototype.clear = function () {
322
+ var orientation = this.root.orientation;
323
+ this.root = new branchNode_1.BranchNode(orientation, this.proportionalLayout, this.styles, this.root.size, this.root.orthogonalSize);
324
+ };
325
+ Gridview.prototype.deserialize = function (json, deserializer) {
326
+ var orientation = json.orientation;
327
+ var height = orientation === splitview_1.Orientation.VERTICAL ? json.height : json.width;
328
+ this._deserialize(json.root, orientation, deserializer, height);
329
+ };
330
+ Gridview.prototype._deserialize = function (root, orientation, deserializer, orthogonalSize) {
331
+ this.root = this._deserializeNode(root, orientation, deserializer, orthogonalSize);
332
+ };
333
+ Gridview.prototype._deserializeNode = function (node, orientation, deserializer, orthogonalSize) {
334
+ var _this = this;
335
+ var result;
336
+ if (node.type === 'branch') {
337
+ var serializedChildren = node.data;
338
+ var children = serializedChildren.map(function (serializedChild) {
339
+ return {
340
+ node: _this._deserializeNode(serializedChild, (0, exports.orthogonal)(orientation), deserializer, node.size),
341
+ visible: serializedChild.visible,
342
+ };
343
+ });
344
+ result = new branchNode_1.BranchNode(orientation, this.proportionalLayout, this.styles, node.size, // <- orthogonal size - flips at each depth
345
+ orthogonalSize, // <- size - flips at each depth
346
+ children);
347
+ }
348
+ else {
349
+ result = new leafNode_1.LeafNode(deserializer.fromJSON(node), orientation, orthogonalSize, node.size);
350
+ }
351
+ return result;
352
+ };
353
+ Object.defineProperty(Gridview.prototype, "root", {
354
+ get: function () {
355
+ return this._root;
356
+ },
357
+ set: function (root) {
358
+ var _this = this;
359
+ var oldRoot = this._root;
360
+ if (oldRoot) {
361
+ oldRoot.dispose();
362
+ this._maximizedNode = undefined;
363
+ this.element.removeChild(oldRoot.element);
364
+ }
365
+ this._root = root;
366
+ this.element.appendChild(this._root.element);
367
+ this.disposable.value = this._root.onDidChange(function (e) {
368
+ _this._onDidChange.fire(e);
369
+ });
370
+ },
371
+ enumerable: false,
372
+ configurable: true
373
+ });
374
+ /**
375
+ * If the root is orientated as a VERTICAL node then nest the existing root within a new HORIZIONTAL root node
376
+ * If the root is orientated as a HORIZONTAL node then nest the existing root within a new VERITCAL root node
377
+ */
378
+ Gridview.prototype.insertOrthogonalSplitviewAtRoot = function () {
379
+ var _this = this;
380
+ if (!this._root) {
381
+ return;
382
+ }
383
+ var oldRoot = this.root;
384
+ oldRoot.element.remove();
385
+ this._root = new branchNode_1.BranchNode((0, exports.orthogonal)(oldRoot.orientation), this.proportionalLayout, this.styles, this.root.orthogonalSize, this.root.size);
386
+ if (oldRoot.children.length === 0) {
387
+ // no data so no need to add anything back in
388
+ }
389
+ else if (oldRoot.children.length === 1) {
390
+ // can remove one level of redundant branching if there is only a single child
391
+ var childReference = oldRoot.children[0];
392
+ var child = oldRoot.removeChild(0); // remove to prevent disposal when disposing of unwanted root
393
+ child.dispose();
394
+ oldRoot.dispose();
395
+ this._root.addChild(
396
+ /**
397
+ * the child node will have the same orientation as the new root since
398
+ * we are removing the inbetween node.
399
+ * the entire 'tree' must be flipped recursively to ensure that the orientation
400
+ * flips at each level
401
+ */
402
+ flipNode(childReference, childReference.orthogonalSize, childReference.size), splitview_1.Sizing.Distribute, 0);
403
+ }
404
+ else {
405
+ this._root.addChild(oldRoot, splitview_1.Sizing.Distribute, 0);
406
+ }
407
+ this.element.appendChild(this._root.element);
408
+ this.disposable.value = this._root.onDidChange(function (e) {
409
+ _this._onDidChange.fire(e);
410
+ });
411
+ };
412
+ Gridview.prototype.next = function (location) {
413
+ return this.progmaticSelect(location);
414
+ };
415
+ Gridview.prototype.previous = function (location) {
416
+ return this.progmaticSelect(location, true);
417
+ };
418
+ Gridview.prototype.getView = function (location) {
419
+ var node = location ? this.getNode(location)[1] : this.root;
420
+ return this._getViews(node, this.orientation);
421
+ };
422
+ Gridview.prototype._getViews = function (node, orientation, cachedVisibleSize) {
423
+ var box = { height: node.height, width: node.width };
424
+ if (node instanceof leafNode_1.LeafNode) {
425
+ return { box: box, view: node.view, cachedVisibleSize: cachedVisibleSize };
426
+ }
427
+ var children = [];
428
+ for (var i = 0; i < node.children.length; i++) {
429
+ var child = node.children[i];
430
+ var nodeCachedVisibleSize = node.getChildCachedVisibleSize(i);
431
+ children.push(this._getViews(child, (0, exports.orthogonal)(orientation), nodeCachedVisibleSize));
432
+ }
433
+ return { box: box, children: children };
434
+ };
435
+ Gridview.prototype.progmaticSelect = function (location, reverse) {
436
+ if (reverse === void 0) { reverse = false; }
437
+ var _a = __read(this.getNode(location), 2), path = _a[0], node = _a[1];
438
+ if (!(node instanceof leafNode_1.LeafNode)) {
439
+ throw new Error('invalid location');
440
+ }
441
+ for (var i = path.length - 1; i > -1; i--) {
442
+ var n = path[i];
443
+ var l = location[i] || 0;
444
+ var canProgressInCurrentLevel = reverse
445
+ ? l - 1 > -1
446
+ : l + 1 < n.children.length;
447
+ if (canProgressInCurrentLevel) {
448
+ return findLeaf(n.children[reverse ? l - 1 : l + 1], reverse);
449
+ }
450
+ }
451
+ return findLeaf(this.root, reverse);
452
+ };
453
+ Gridview.prototype.isViewVisible = function (location) {
454
+ var _a = __read((0, array_1.tail)(location), 2), rest = _a[0], index = _a[1];
455
+ var _b = __read(this.getNode(rest), 2), parent = _b[1];
456
+ if (!(parent instanceof branchNode_1.BranchNode)) {
457
+ throw new Error('Invalid from location');
458
+ }
459
+ return parent.isChildVisible(index);
460
+ };
461
+ Gridview.prototype.setViewVisible = function (location, visible) {
462
+ if (this.hasMaximizedView()) {
463
+ this.exitMaximizedView();
464
+ }
465
+ var _a = __read((0, array_1.tail)(location), 2), rest = _a[0], index = _a[1];
466
+ var _b = __read(this.getNode(rest), 2), parent = _b[1];
467
+ if (!(parent instanceof branchNode_1.BranchNode)) {
468
+ throw new Error('Invalid from location');
469
+ }
470
+ parent.setChildVisible(index, visible);
471
+ };
472
+ Gridview.prototype.moveView = function (parentLocation, from, to) {
473
+ if (this.hasMaximizedView()) {
474
+ this.exitMaximizedView();
475
+ }
476
+ var _a = __read(this.getNode(parentLocation), 2), parent = _a[1];
477
+ if (!(parent instanceof branchNode_1.BranchNode)) {
478
+ throw new Error('Invalid location');
479
+ }
480
+ parent.moveChild(from, to);
481
+ };
482
+ Gridview.prototype.addView = function (view, size, location) {
483
+ if (this.hasMaximizedView()) {
484
+ this.exitMaximizedView();
485
+ }
486
+ var _a = __read((0, array_1.tail)(location), 2), rest = _a[0], index = _a[1];
487
+ var _b = __read(this.getNode(rest), 2), pathToParent = _b[0], parent = _b[1];
488
+ if (parent instanceof branchNode_1.BranchNode) {
489
+ var node = new leafNode_1.LeafNode(view, (0, exports.orthogonal)(parent.orientation), parent.orthogonalSize);
490
+ parent.addChild(node, size, index);
491
+ }
492
+ else {
493
+ var _c = __read(__spreadArray([], __read(pathToParent), false).reverse()), grandParent = _c[0], _ = _c.slice(1);
494
+ var _d = __read(__spreadArray([], __read(rest), false).reverse()), parentIndex = _d[0], __ = _d.slice(1);
495
+ var newSiblingSize = 0;
496
+ var newSiblingCachedVisibleSize = grandParent.getChildCachedVisibleSize(parentIndex);
497
+ if (typeof newSiblingCachedVisibleSize === 'number') {
498
+ newSiblingSize = splitview_1.Sizing.Invisible(newSiblingCachedVisibleSize);
499
+ }
500
+ var child = grandParent.removeChild(parentIndex);
501
+ child.dispose();
502
+ var newParent = new branchNode_1.BranchNode(parent.orientation, this.proportionalLayout, this.styles, parent.size, parent.orthogonalSize);
503
+ grandParent.addChild(newParent, parent.size, parentIndex);
504
+ var newSibling = new leafNode_1.LeafNode(parent.view, grandParent.orientation, parent.size);
505
+ newParent.addChild(newSibling, newSiblingSize, 0);
506
+ if (typeof size !== 'number' && size.type === 'split') {
507
+ size = { type: 'split', index: 0 };
508
+ }
509
+ var node = new leafNode_1.LeafNode(view, grandParent.orientation, parent.size);
510
+ newParent.addChild(node, size, index);
511
+ }
512
+ };
513
+ Gridview.prototype.remove = function (view, sizing) {
514
+ var location = getGridLocation(view.element);
515
+ return this.removeView(location, sizing);
516
+ };
517
+ Gridview.prototype.removeView = function (location, sizing) {
518
+ if (this.hasMaximizedView()) {
519
+ this.exitMaximizedView();
520
+ }
521
+ var _a = __read((0, array_1.tail)(location), 2), rest = _a[0], index = _a[1];
522
+ var _b = __read(this.getNode(rest), 2), pathToParent = _b[0], parent = _b[1];
523
+ if (!(parent instanceof branchNode_1.BranchNode)) {
524
+ throw new Error('Invalid location');
525
+ }
526
+ var nodeToRemove = parent.children[index];
527
+ if (!(nodeToRemove instanceof leafNode_1.LeafNode)) {
528
+ throw new Error('Invalid location');
529
+ }
530
+ parent.removeChild(index, sizing);
531
+ nodeToRemove.dispose();
532
+ if (parent.children.length !== 1) {
533
+ return nodeToRemove.view;
534
+ }
535
+ // if the parent has only one child and we know the parent is a BranchNode we can make the tree
536
+ // more efficiently spaced by replacing the parent BranchNode with the child.
537
+ // if that child is a LeafNode then we simply replace the BranchNode with the child otherwise if the child
538
+ // is a BranchNode too we should spread it's children into the grandparent.
539
+ // refer to the remaining child as the sibling
540
+ var sibling = parent.children[0];
541
+ if (pathToParent.length === 0) {
542
+ // if the parent is root
543
+ if (sibling instanceof leafNode_1.LeafNode) {
544
+ // if the sibling is a leaf node no action is required
545
+ return nodeToRemove.view;
546
+ }
547
+ // otherwise the sibling is a branch node. since the parent is the root and the root has only one child
548
+ // which is a branch node we can just set this branch node to be the new root node
549
+ // for good housekeeping we'll removing the sibling from it's existing tree
550
+ parent.removeChild(0, sizing);
551
+ // and set that sibling node to be root
552
+ this.root = sibling;
553
+ return nodeToRemove.view;
554
+ }
555
+ // otherwise the parent is apart of a large sub-tree
556
+ var _c = __read(__spreadArray([], __read(pathToParent), false).reverse()), grandParent = _c[0], _ = _c.slice(1);
557
+ var _d = __read(__spreadArray([], __read(rest), false).reverse()), parentIndex = _d[0], __ = _d.slice(1);
558
+ var isSiblingVisible = parent.isChildVisible(0);
559
+ // either way we need to remove the sibling from it's existing tree
560
+ parent.removeChild(0, sizing);
561
+ // note the sizes of all of the grandparents children
562
+ var sizes = grandParent.children.map(function (_size, i) {
563
+ return grandParent.getChildSize(i);
564
+ });
565
+ // remove the parent from the grandparent since we are moving the sibling to take the parents place
566
+ // this parent is no longer used and can be disposed of
567
+ grandParent.removeChild(parentIndex, sizing).dispose();
568
+ if (sibling instanceof branchNode_1.BranchNode) {
569
+ // replace the parent with the siblings children
570
+ sizes.splice.apply(sizes, __spreadArray([parentIndex,
571
+ 1], __read(sibling.children.map(function (c) { return c.size; })), false));
572
+ // and add those siblings to the grandparent
573
+ for (var i = 0; i < sibling.children.length; i++) {
574
+ var child = sibling.children[i];
575
+ grandParent.addChild(child, child.size, parentIndex + i);
576
+ }
577
+ /**
578
+ * clean down the branch node since we need to dipose of it and
579
+ * when .dispose() it called on a branch it will dispose of any
580
+ * views it is holding onto.
581
+ */
582
+ while (sibling.children.length > 0) {
583
+ sibling.removeChild(0);
584
+ }
585
+ }
586
+ else {
587
+ // otherwise create a new leaf node and add that to the grandparent
588
+ var newSibling = new leafNode_1.LeafNode(sibling.view, (0, exports.orthogonal)(sibling.orientation), sibling.size);
589
+ var siblingSizing = isSiblingVisible
590
+ ? sibling.orthogonalSize
591
+ : splitview_1.Sizing.Invisible(sibling.orthogonalSize);
592
+ grandParent.addChild(newSibling, siblingSizing, parentIndex);
593
+ }
594
+ // the containing node of the sibling is no longer required and can be disposed of
595
+ sibling.dispose();
596
+ // resize everything
597
+ for (var i = 0; i < sizes.length; i++) {
598
+ grandParent.resizeChild(i, sizes[i]);
599
+ }
600
+ return nodeToRemove.view;
601
+ };
602
+ Gridview.prototype.layout = function (width, height) {
603
+ var _a = __read(this.root.orientation === splitview_1.Orientation.HORIZONTAL
604
+ ? [height, width]
605
+ : [width, height], 2), size = _a[0], orthogonalSize = _a[1];
606
+ this.root.layout(size, orthogonalSize);
607
+ };
608
+ Gridview.prototype.getNode = function (location, node, path) {
609
+ if (node === void 0) { node = this.root; }
610
+ if (path === void 0) { path = []; }
611
+ if (location.length === 0) {
612
+ return [path, node];
613
+ }
614
+ if (!(node instanceof branchNode_1.BranchNode)) {
615
+ throw new Error('Invalid location');
616
+ }
617
+ var _a = __read(location), index = _a[0], rest = _a.slice(1);
618
+ if (index < 0 || index >= node.children.length) {
619
+ throw new Error('Invalid location');
620
+ }
621
+ var child = node.children[index];
622
+ path.push(node);
623
+ return this.getNode(rest, child, path);
624
+ };
625
+ return Gridview;
626
+ }());
627
+ exports.Gridview = Gridview;
548
628
  //# sourceMappingURL=gridview.js.map