dockview-core 1.6.0 → 1.7.1

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 (428) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +50 -52
  3. package/dist/cjs/api/component.api.d.ts +144 -145
  4. package/dist/cjs/api/component.api.d.ts.map +1 -0
  5. package/dist/cjs/api/component.api.js +572 -578
  6. package/dist/cjs/api/component.api.js.map +1 -1
  7. package/dist/cjs/api/dockviewPanelApi.d.ts +35 -34
  8. package/dist/cjs/api/dockviewPanelApi.d.ts.map +1 -0
  9. package/dist/cjs/api/dockviewPanelApi.js +83 -83
  10. package/dist/cjs/api/gridviewPanelApi.d.ts +38 -37
  11. package/dist/cjs/api/gridviewPanelApi.d.ts.map +1 -0
  12. package/dist/cjs/api/gridviewPanelApi.js +47 -47
  13. package/dist/cjs/api/panelApi.d.ts +89 -88
  14. package/dist/cjs/api/panelApi.d.ts.map +1 -0
  15. package/dist/cjs/api/panelApi.js +137 -137
  16. package/dist/cjs/api/paneviewPanelApi.d.ts +27 -26
  17. package/dist/cjs/api/paneviewPanelApi.d.ts.map +1 -0
  18. package/dist/cjs/api/paneviewPanelApi.js +57 -57
  19. package/dist/cjs/api/splitviewPanelApi.d.ts +33 -32
  20. package/dist/cjs/api/splitviewPanelApi.d.ts.map +1 -0
  21. package/dist/cjs/api/splitviewPanelApi.js +47 -47
  22. package/dist/cjs/array.d.ts +13 -12
  23. package/dist/cjs/array.d.ts.map +1 -0
  24. package/dist/cjs/array.js +58 -58
  25. package/dist/cjs/dnd/abstractDragHandler.d.ts +12 -11
  26. package/dist/cjs/dnd/abstractDragHandler.d.ts.map +1 -0
  27. package/dist/cjs/dnd/abstractDragHandler.js +125 -125
  28. package/dist/cjs/dnd/dataTransfer.d.ts +32 -31
  29. package/dist/cjs/dnd/dataTransfer.d.ts.map +1 -0
  30. package/dist/cjs/dnd/dataTransfer.js +100 -100
  31. package/dist/cjs/dnd/dnd.d.ts +28 -27
  32. package/dist/cjs/dnd/dnd.d.ts.map +1 -0
  33. package/dist/cjs/dnd/dnd.js +59 -59
  34. package/dist/cjs/dnd/droptarget.d.ts +43 -42
  35. package/dist/cjs/dnd/droptarget.d.ts.map +1 -0
  36. package/dist/cjs/dnd/droptarget.js +280 -280
  37. package/dist/cjs/dnd/ghost.d.ts +2 -1
  38. package/dist/cjs/dnd/ghost.d.ts.map +1 -0
  39. package/dist/cjs/dnd/ghost.js +15 -15
  40. package/dist/cjs/dnd/groupDragHandler.d.ts +12 -11
  41. package/dist/cjs/dnd/groupDragHandler.d.ts.map +1 -0
  42. package/dist/cjs/dnd/groupDragHandler.js +61 -61
  43. package/dist/cjs/dockview/components/panel/content.d.ts +31 -30
  44. package/dist/cjs/dockview/components/panel/content.d.ts.map +1 -0
  45. package/dist/cjs/dockview/components/panel/content.js +100 -100
  46. package/dist/cjs/dockview/components/tab/defaultTab.d.ts +22 -21
  47. package/dist/cjs/dockview/components/tab/defaultTab.d.ts.map +1 -0
  48. package/dist/cjs/dockview/components/tab/defaultTab.js +105 -105
  49. package/dist/cjs/dockview/components/tab/tab.d.ts +32 -31
  50. package/dist/cjs/dockview/components/tab/tab.d.ts.map +1 -0
  51. package/dist/cjs/dockview/components/tab/tab.js +124 -124
  52. package/dist/cjs/dockview/components/titlebar/tabsContainer.d.ts +60 -63
  53. package/dist/cjs/dockview/components/titlebar/tabsContainer.d.ts.map +1 -0
  54. package/dist/cjs/dockview/components/titlebar/tabsContainer.js +230 -247
  55. package/dist/cjs/dockview/components/titlebar/tabsContainer.js.map +1 -1
  56. package/dist/cjs/dockview/components/titlebar/voidContainer.d.ts +16 -15
  57. package/dist/cjs/dockview/components/titlebar/voidContainer.d.ts.map +1 -0
  58. package/dist/cjs/dockview/components/titlebar/voidContainer.js +73 -73
  59. package/dist/cjs/dockview/components/watermark/watermark.d.ts +19 -18
  60. package/dist/cjs/dockview/components/watermark/watermark.d.ts.map +1 -0
  61. package/dist/cjs/dockview/components/watermark/watermark.js +87 -86
  62. package/dist/cjs/dockview/components/watermark/watermark.js.map +1 -1
  63. package/dist/cjs/dockview/deserializer.d.ts +13 -12
  64. package/dist/cjs/dockview/deserializer.d.ts.map +1 -0
  65. package/dist/cjs/dockview/deserializer.js +45 -45
  66. package/dist/cjs/dockview/dockviewComponent.d.ts +121 -126
  67. package/dist/cjs/dockview/dockviewComponent.d.ts.map +1 -0
  68. package/dist/cjs/dockview/dockviewComponent.js +749 -771
  69. package/dist/cjs/dockview/dockviewComponent.js.map +1 -1
  70. package/dist/cjs/dockview/dockviewGroupPanel.d.ts +32 -31
  71. package/dist/cjs/dockview/dockviewGroupPanel.d.ts.map +1 -0
  72. package/dist/cjs/dockview/dockviewGroupPanel.js +96 -96
  73. package/dist/cjs/dockview/dockviewGroupPanelModel.d.ts +175 -176
  74. package/dist/cjs/dockview/dockviewGroupPanelModel.d.ts.map +1 -0
  75. package/dist/cjs/dockview/dockviewGroupPanelModel.js +578 -578
  76. package/dist/cjs/dockview/dockviewGroupPanelModel.js.map +1 -1
  77. package/dist/cjs/dockview/dockviewPanel.d.ts +41 -40
  78. package/dist/cjs/dockview/dockviewPanel.d.ts.map +1 -0
  79. package/dist/cjs/dockview/dockviewPanel.js +146 -149
  80. package/dist/cjs/dockview/dockviewPanel.js.map +1 -1
  81. package/dist/cjs/dockview/dockviewPanelModel.d.ts +35 -34
  82. package/dist/cjs/dockview/dockviewPanelModel.d.ts.map +1 -0
  83. package/dist/cjs/dockview/dockviewPanelModel.js +92 -92
  84. package/dist/cjs/dockview/options.d.ts +117 -116
  85. package/dist/cjs/dockview/options.d.ts.map +1 -0
  86. package/dist/cjs/dockview/options.js +31 -31
  87. package/dist/cjs/dockview/types.d.ts +68 -67
  88. package/dist/cjs/dockview/types.d.ts.map +1 -0
  89. package/dist/cjs/dockview/types.js +10 -10
  90. package/dist/cjs/dom.d.ts +15 -14
  91. package/dist/cjs/dom.d.ts.map +1 -0
  92. package/dist/cjs/dom.js +189 -182
  93. package/dist/cjs/dom.js.map +1 -1
  94. package/dist/cjs/events.d.ts +31 -30
  95. package/dist/cjs/events.d.ts.map +1 -0
  96. package/dist/cjs/events.js +129 -129
  97. package/dist/cjs/gridview/baseComponentGridview.d.ts +88 -87
  98. package/dist/cjs/gridview/baseComponentGridview.d.ts.map +1 -0
  99. package/dist/cjs/gridview/baseComponentGridview.js +271 -279
  100. package/dist/cjs/gridview/baseComponentGridview.js.map +1 -1
  101. package/dist/cjs/gridview/basePanelView.d.ts +41 -40
  102. package/dist/cjs/gridview/basePanelView.d.ts.map +1 -0
  103. package/dist/cjs/gridview/basePanelView.js +123 -123
  104. package/dist/cjs/gridview/branchNode.d.ts +50 -49
  105. package/dist/cjs/gridview/branchNode.d.ts.map +1 -0
  106. package/dist/cjs/gridview/branchNode.js +342 -342
  107. package/dist/cjs/gridview/gridview.d.ts +134 -133
  108. package/dist/cjs/gridview/gridview.d.ts.map +1 -0
  109. package/dist/cjs/gridview/gridview.js +517 -510
  110. package/dist/cjs/gridview/gridview.js.map +1 -1
  111. package/dist/cjs/gridview/gridviewComponent.d.ts +81 -80
  112. package/dist/cjs/gridview/gridviewComponent.d.ts.map +1 -0
  113. package/dist/cjs/gridview/gridviewComponent.js +325 -324
  114. package/dist/cjs/gridview/gridviewComponent.js.map +1 -1
  115. package/dist/cjs/gridview/gridviewPanel.d.ts +66 -65
  116. package/dist/cjs/gridview/gridviewPanel.d.ts.map +1 -0
  117. package/dist/cjs/gridview/gridviewPanel.js +214 -214
  118. package/dist/cjs/gridview/leafNode.d.ts +35 -34
  119. package/dist/cjs/gridview/leafNode.d.ts.map +1 -0
  120. package/dist/cjs/gridview/leafNode.js +170 -170
  121. package/dist/cjs/gridview/options.d.ts +19 -18
  122. package/dist/cjs/gridview/options.d.ts.map +1 -0
  123. package/dist/cjs/gridview/options.js +2 -2
  124. package/dist/cjs/gridview/types.d.ts +4 -3
  125. package/dist/cjs/gridview/types.d.ts.map +1 -0
  126. package/dist/cjs/gridview/types.js +2 -2
  127. package/dist/cjs/index.d.ts +42 -41
  128. package/dist/cjs/index.d.ts.map +1 -0
  129. package/dist/cjs/index.js +63 -63
  130. package/dist/cjs/lifecycle.d.ts +25 -22
  131. package/dist/cjs/lifecycle.d.ts.map +1 -0
  132. package/dist/cjs/lifecycle.js +97 -88
  133. package/dist/cjs/lifecycle.js.map +1 -1
  134. package/dist/cjs/math.d.ts +6 -5
  135. package/dist/cjs/math.d.ts.map +1 -0
  136. package/dist/cjs/math.js +34 -34
  137. package/dist/cjs/panel/componentFactory.d.ts +11 -10
  138. package/dist/cjs/panel/componentFactory.d.ts.map +1 -0
  139. package/dist/cjs/panel/componentFactory.js +30 -30
  140. package/dist/cjs/panel/types.d.ts +34 -33
  141. package/dist/cjs/panel/types.d.ts.map +1 -0
  142. package/dist/cjs/panel/types.js +2 -2
  143. package/dist/cjs/paneview/defaultPaneviewHeader.d.ts +22 -21
  144. package/dist/cjs/paneview/defaultPaneviewHeader.d.ts.map +1 -0
  145. package/dist/cjs/paneview/defaultPaneviewHeader.js +90 -90
  146. package/dist/cjs/paneview/draggablePaneviewPanel.d.ts +22 -21
  147. package/dist/cjs/paneview/draggablePaneviewPanel.d.ts.map +1 -0
  148. package/dist/cjs/paneview/draggablePaneviewPanel.js +131 -131
  149. package/dist/cjs/paneview/options.d.ts +29 -27
  150. package/dist/cjs/paneview/options.d.ts.map +1 -0
  151. package/dist/cjs/paneview/options.js +2 -2
  152. package/dist/cjs/paneview/paneview.d.ts +41 -40
  153. package/dist/cjs/paneview/paneview.d.ts.map +1 -0
  154. package/dist/cjs/paneview/paneview.js +201 -201
  155. package/dist/cjs/paneview/paneviewComponent.d.ts +130 -129
  156. package/dist/cjs/paneview/paneviewComponent.d.ts.map +1 -0
  157. package/dist/cjs/paneview/paneviewComponent.js +394 -394
  158. package/dist/cjs/paneview/paneviewComponent.js.map +1 -1
  159. package/dist/cjs/paneview/paneviewPanel.d.ts +93 -92
  160. package/dist/cjs/paneview/paneviewPanel.d.ts.map +1 -0
  161. package/dist/cjs/paneview/paneviewPanel.js +275 -275
  162. package/dist/cjs/resizable.d.ts +8 -0
  163. package/dist/cjs/resizable.d.ts.map +1 -0
  164. package/dist/cjs/resizable.js +57 -0
  165. package/dist/cjs/resizable.js.map +1 -0
  166. package/dist/cjs/splitview/options.d.ts +28 -26
  167. package/dist/cjs/splitview/options.d.ts.map +1 -0
  168. package/dist/cjs/splitview/options.js +2 -2
  169. package/dist/cjs/splitview/splitview.d.ts +128 -127
  170. package/dist/cjs/splitview/splitview.d.ts.map +1 -0
  171. package/dist/cjs/splitview/splitview.js +908 -908
  172. package/dist/cjs/splitview/splitviewComponent.d.ts +102 -101
  173. package/dist/cjs/splitview/splitviewComponent.d.ts.map +1 -0
  174. package/dist/cjs/splitview/splitviewComponent.js +373 -373
  175. package/dist/cjs/splitview/splitviewComponent.js.map +1 -1
  176. package/dist/cjs/splitview/splitviewPanel.d.ts +46 -45
  177. package/dist/cjs/splitview/splitviewPanel.d.ts.map +1 -0
  178. package/dist/cjs/splitview/splitviewPanel.js +179 -179
  179. package/dist/cjs/splitview/viewItem.d.ts +26 -25
  180. package/dist/cjs/splitview/viewItem.d.ts.map +1 -0
  181. package/dist/cjs/splitview/viewItem.js +119 -119
  182. package/dist/cjs/svg.d.ts +4 -3
  183. package/dist/cjs/svg.d.ts.map +1 -0
  184. package/dist/cjs/svg.js +43 -43
  185. package/dist/cjs/types.d.ts +3 -2
  186. package/dist/cjs/types.d.ts.map +1 -0
  187. package/dist/cjs/types.js +2 -2
  188. package/dist/dockview-core.amd.js +6343 -6339
  189. package/dist/dockview-core.amd.min.js +2 -2
  190. package/dist/dockview-core.amd.min.noStyle.js +2 -2
  191. package/dist/dockview-core.amd.noStyle.js +6310 -6306
  192. package/dist/dockview-core.cjs.js +6339 -6335
  193. package/dist/dockview-core.esm.js +6339 -6335
  194. package/dist/dockview-core.esm.min.js +2 -2
  195. package/dist/dockview-core.js +6343 -6339
  196. package/dist/dockview-core.min.js +2 -2
  197. package/dist/dockview-core.min.noStyle.js +2 -2
  198. package/dist/dockview-core.noStyle.js +6310 -6306
  199. package/dist/esm/api/component.api.d.ts +144 -145
  200. package/dist/esm/api/component.api.d.ts.map +1 -0
  201. package/dist/esm/api/component.api.js +324 -329
  202. package/dist/esm/api/component.api.js.map +1 -0
  203. package/dist/esm/api/dockviewPanelApi.d.ts +35 -34
  204. package/dist/esm/api/dockviewPanelApi.d.ts.map +1 -0
  205. package/dist/esm/api/dockviewPanelApi.js +49 -48
  206. package/dist/esm/api/dockviewPanelApi.js.map +1 -0
  207. package/dist/esm/api/gridviewPanelApi.d.ts +38 -37
  208. package/dist/esm/api/gridviewPanelApi.d.ts.map +1 -0
  209. package/dist/esm/api/gridviewPanelApi.js +26 -25
  210. package/dist/esm/api/gridviewPanelApi.js.map +1 -0
  211. package/dist/esm/api/panelApi.d.ts +89 -88
  212. package/dist/esm/api/panelApi.d.ts.map +1 -0
  213. package/dist/esm/api/panelApi.js +96 -95
  214. package/dist/esm/api/panelApi.js.map +1 -0
  215. package/dist/esm/api/paneviewPanelApi.d.ts +27 -26
  216. package/dist/esm/api/paneviewPanelApi.d.ts.map +1 -0
  217. package/dist/esm/api/paneviewPanelApi.js +28 -27
  218. package/dist/esm/api/paneviewPanelApi.js.map +1 -0
  219. package/dist/esm/api/splitviewPanelApi.d.ts +33 -32
  220. package/dist/esm/api/splitviewPanelApi.d.ts.map +1 -0
  221. package/dist/esm/api/splitviewPanelApi.js +26 -25
  222. package/dist/esm/api/splitviewPanelApi.js.map +1 -0
  223. package/dist/esm/array.d.ts +13 -12
  224. package/dist/esm/array.d.ts.map +1 -0
  225. package/dist/esm/array.js +50 -49
  226. package/dist/esm/array.js.map +1 -0
  227. package/dist/esm/dnd/abstractDragHandler.d.ts +12 -11
  228. package/dist/esm/dnd/abstractDragHandler.d.ts.map +1 -0
  229. package/dist/esm/dnd/abstractDragHandler.js +48 -47
  230. package/dist/esm/dnd/abstractDragHandler.js.map +1 -0
  231. package/dist/esm/dnd/dataTransfer.d.ts +32 -31
  232. package/dist/esm/dnd/dataTransfer.d.ts.map +1 -0
  233. package/dist/esm/dnd/dataTransfer.js +70 -69
  234. package/dist/esm/dnd/dataTransfer.js.map +1 -0
  235. package/dist/esm/dnd/dnd.d.ts +28 -27
  236. package/dist/esm/dnd/dnd.d.ts.map +1 -0
  237. package/dist/esm/dnd/dnd.js +37 -36
  238. package/dist/esm/dnd/dnd.js.map +1 -0
  239. package/dist/esm/dnd/droptarget.d.ts +43 -42
  240. package/dist/esm/dnd/droptarget.d.ts.map +1 -0
  241. package/dist/esm/dnd/droptarget.js +251 -250
  242. package/dist/esm/dnd/droptarget.js.map +1 -0
  243. package/dist/esm/dnd/ghost.d.ts +2 -1
  244. package/dist/esm/dnd/ghost.d.ts.map +1 -0
  245. package/dist/esm/dnd/ghost.js +12 -11
  246. package/dist/esm/dnd/ghost.js.map +1 -0
  247. package/dist/esm/dnd/groupDragHandler.d.ts +12 -11
  248. package/dist/esm/dnd/groupDragHandler.d.ts.map +1 -0
  249. package/dist/esm/dnd/groupDragHandler.js +39 -38
  250. package/dist/esm/dnd/groupDragHandler.js.map +1 -0
  251. package/dist/esm/dockview/components/panel/content.d.ts +31 -30
  252. package/dist/esm/dockview/components/panel/content.d.ts.map +1 -0
  253. package/dist/esm/dockview/components/panel/content.js +74 -73
  254. package/dist/esm/dockview/components/panel/content.js.map +1 -0
  255. package/dist/esm/dockview/components/tab/defaultTab.d.ts +22 -21
  256. package/dist/esm/dockview/components/tab/defaultTab.d.ts.map +1 -0
  257. package/dist/esm/dockview/components/tab/defaultTab.js +68 -67
  258. package/dist/esm/dockview/components/tab/defaultTab.js.map +1 -0
  259. package/dist/esm/dockview/components/tab/tab.d.ts +32 -31
  260. package/dist/esm/dockview/components/tab/tab.d.ts.map +1 -0
  261. package/dist/esm/dockview/components/tab/tab.js +95 -94
  262. package/dist/esm/dockview/components/tab/tab.js.map +1 -0
  263. package/dist/esm/dockview/components/titlebar/tabsContainer.d.ts +60 -63
  264. package/dist/esm/dockview/components/titlebar/tabsContainer.d.ts.map +1 -0
  265. package/dist/esm/dockview/components/titlebar/tabsContainer.js +167 -179
  266. package/dist/esm/dockview/components/titlebar/tabsContainer.js.map +1 -0
  267. package/dist/esm/dockview/components/titlebar/voidContainer.d.ts +16 -15
  268. package/dist/esm/dockview/components/titlebar/voidContainer.d.ts.map +1 -0
  269. package/dist/esm/dockview/components/titlebar/voidContainer.js +48 -47
  270. package/dist/esm/dockview/components/titlebar/voidContainer.js.map +1 -0
  271. package/dist/esm/dockview/components/watermark/watermark.d.ts +19 -18
  272. package/dist/esm/dockview/components/watermark/watermark.d.ts.map +1 -0
  273. package/dist/esm/dockview/components/watermark/watermark.js +62 -60
  274. package/dist/esm/dockview/components/watermark/watermark.js.map +1 -0
  275. package/dist/esm/dockview/deserializer.d.ts +13 -12
  276. package/dist/esm/dockview/deserializer.d.ts.map +1 -0
  277. package/dist/esm/dockview/deserializer.js +41 -40
  278. package/dist/esm/dockview/deserializer.js.map +1 -0
  279. package/dist/esm/dockview/dockviewComponent.d.ts +121 -126
  280. package/dist/esm/dockview/dockviewComponent.d.ts.map +1 -0
  281. package/dist/esm/dockview/dockviewComponent.js +595 -612
  282. package/dist/esm/dockview/dockviewComponent.js.map +1 -0
  283. package/dist/esm/dockview/dockviewGroupPanel.d.ts +32 -31
  284. package/dist/esm/dockview/dockviewGroupPanel.d.ts.map +1 -0
  285. package/dist/esm/dockview/dockviewGroupPanel.js +51 -50
  286. package/dist/esm/dockview/dockviewGroupPanel.js.map +1 -0
  287. package/dist/esm/dockview/dockviewGroupPanelModel.d.ts +175 -176
  288. package/dist/esm/dockview/dockviewGroupPanelModel.d.ts.map +1 -0
  289. package/dist/esm/dockview/dockviewGroupPanelModel.js +450 -449
  290. package/dist/esm/dockview/dockviewGroupPanelModel.js.map +1 -0
  291. package/dist/esm/dockview/dockviewPanel.d.ts +41 -40
  292. package/dist/esm/dockview/dockviewPanel.d.ts.map +1 -0
  293. package/dist/esm/dockview/dockviewPanel.js +102 -104
  294. package/dist/esm/dockview/dockviewPanel.js.map +1 -0
  295. package/dist/esm/dockview/dockviewPanelModel.d.ts +35 -34
  296. package/dist/esm/dockview/dockviewPanelModel.d.ts.map +1 -0
  297. package/dist/esm/dockview/dockviewPanelModel.js +69 -68
  298. package/dist/esm/dockview/dockviewPanelModel.js.map +1 -0
  299. package/dist/esm/dockview/options.d.ts +117 -116
  300. package/dist/esm/dockview/options.d.ts.map +1 -0
  301. package/dist/esm/dockview/options.js +25 -24
  302. package/dist/esm/dockview/options.js.map +1 -0
  303. package/dist/esm/dockview/types.d.ts +68 -67
  304. package/dist/esm/dockview/types.d.ts.map +1 -0
  305. package/dist/esm/dockview/types.js +8 -7
  306. package/dist/esm/dockview/types.js.map +1 -0
  307. package/dist/esm/dom.d.ts +15 -14
  308. package/dist/esm/dom.d.ts.map +1 -0
  309. package/dist/esm/dom.js +121 -113
  310. package/dist/esm/dom.js.map +1 -0
  311. package/dist/esm/events.d.ts +31 -30
  312. package/dist/esm/events.d.ts.map +1 -0
  313. package/dist/esm/events.js +89 -88
  314. package/dist/esm/events.js.map +1 -0
  315. package/dist/esm/gridview/baseComponentGridview.d.ts +88 -87
  316. package/dist/esm/gridview/baseComponentGridview.d.ts.map +1 -0
  317. package/dist/esm/gridview/baseComponentGridview.js +186 -189
  318. package/dist/esm/gridview/baseComponentGridview.js.map +1 -0
  319. package/dist/esm/gridview/basePanelView.d.ts +41 -40
  320. package/dist/esm/gridview/basePanelView.d.ts.map +1 -0
  321. package/dist/esm/gridview/basePanelView.js +75 -74
  322. package/dist/esm/gridview/basePanelView.js.map +1 -0
  323. package/dist/esm/gridview/branchNode.d.ts +50 -49
  324. package/dist/esm/gridview/branchNode.d.ts.map +1 -0
  325. package/dist/esm/gridview/branchNode.js +219 -218
  326. package/dist/esm/gridview/branchNode.js.map +1 -0
  327. package/dist/esm/gridview/gridview.d.ts +134 -133
  328. package/dist/esm/gridview/gridview.d.ts.map +1 -0
  329. package/dist/esm/gridview/gridview.js +431 -423
  330. package/dist/esm/gridview/gridview.js.map +1 -0
  331. package/dist/esm/gridview/gridviewComponent.d.ts +81 -80
  332. package/dist/esm/gridview/gridviewComponent.d.ts.map +1 -0
  333. package/dist/esm/gridview/gridviewComponent.js +239 -237
  334. package/dist/esm/gridview/gridviewComponent.js.map +1 -0
  335. package/dist/esm/gridview/gridviewPanel.d.ts +66 -65
  336. package/dist/esm/gridview/gridviewPanel.d.ts.map +1 -0
  337. package/dist/esm/gridview/gridviewPanel.js +152 -151
  338. package/dist/esm/gridview/gridviewPanel.js.map +1 -0
  339. package/dist/esm/gridview/leafNode.d.ts +35 -34
  340. package/dist/esm/gridview/leafNode.d.ts.map +1 -0
  341. package/dist/esm/gridview/leafNode.js +104 -103
  342. package/dist/esm/gridview/leafNode.js.map +1 -0
  343. package/dist/esm/gridview/options.d.ts +19 -18
  344. package/dist/esm/gridview/options.d.ts.map +1 -0
  345. package/dist/esm/gridview/options.js +2 -1
  346. package/dist/esm/gridview/options.js.map +1 -0
  347. package/dist/esm/gridview/types.d.ts +4 -3
  348. package/dist/esm/gridview/types.d.ts.map +1 -0
  349. package/dist/esm/gridview/types.js +2 -1
  350. package/dist/esm/gridview/types.js.map +1 -0
  351. package/dist/esm/index.d.ts +42 -41
  352. package/dist/esm/index.d.ts.map +1 -0
  353. package/dist/esm/index.js +36 -35
  354. package/dist/esm/index.js.map +1 -0
  355. package/dist/esm/lifecycle.d.ts +25 -22
  356. package/dist/esm/lifecycle.d.ts.map +1 -0
  357. package/dist/esm/lifecycle.js +45 -39
  358. package/dist/esm/lifecycle.js.map +1 -0
  359. package/dist/esm/math.d.ts +6 -5
  360. package/dist/esm/math.d.ts.map +1 -0
  361. package/dist/esm/math.js +29 -28
  362. package/dist/esm/math.js.map +1 -0
  363. package/dist/esm/panel/componentFactory.d.ts +11 -10
  364. package/dist/esm/panel/componentFactory.d.ts.map +1 -0
  365. package/dist/esm/panel/componentFactory.js +25 -24
  366. package/dist/esm/panel/componentFactory.js.map +1 -0
  367. package/dist/esm/panel/types.d.ts +34 -33
  368. package/dist/esm/panel/types.d.ts.map +1 -0
  369. package/dist/esm/panel/types.js +2 -1
  370. package/dist/esm/panel/types.js.map +1 -0
  371. package/dist/esm/paneview/defaultPaneviewHeader.d.ts +22 -21
  372. package/dist/esm/paneview/defaultPaneviewHeader.d.ts.map +1 -0
  373. package/dist/esm/paneview/defaultPaneviewHeader.js +64 -63
  374. package/dist/esm/paneview/defaultPaneviewHeader.js.map +1 -0
  375. package/dist/esm/paneview/draggablePaneviewPanel.d.ts +22 -21
  376. package/dist/esm/paneview/draggablePaneviewPanel.d.ts.map +1 -0
  377. package/dist/esm/paneview/draggablePaneviewPanel.js +93 -92
  378. package/dist/esm/paneview/draggablePaneviewPanel.js.map +1 -0
  379. package/dist/esm/paneview/options.d.ts +29 -27
  380. package/dist/esm/paneview/options.d.ts.map +1 -0
  381. package/dist/esm/paneview/options.js +2 -1
  382. package/dist/esm/paneview/options.js.map +1 -0
  383. package/dist/esm/paneview/paneview.d.ts +41 -40
  384. package/dist/esm/paneview/paneview.d.ts.map +1 -0
  385. package/dist/esm/paneview/paneview.js +146 -145
  386. package/dist/esm/paneview/paneview.js.map +1 -0
  387. package/dist/esm/paneview/paneviewComponent.d.ts +130 -129
  388. package/dist/esm/paneview/paneviewComponent.d.ts.map +1 -0
  389. package/dist/esm/paneview/paneviewComponent.js +271 -270
  390. package/dist/esm/paneview/paneviewComponent.js.map +1 -0
  391. package/dist/esm/paneview/paneviewPanel.d.ts +93 -92
  392. package/dist/esm/paneview/paneviewPanel.d.ts.map +1 -0
  393. package/dist/esm/paneview/paneviewPanel.js +193 -192
  394. package/dist/esm/paneview/paneviewPanel.js.map +1 -0
  395. package/dist/esm/resizable.d.ts +8 -0
  396. package/dist/esm/resizable.d.ts.map +1 -0
  397. package/dist/esm/resizable.js +31 -0
  398. package/dist/esm/resizable.js.map +1 -0
  399. package/dist/esm/splitview/options.d.ts +28 -26
  400. package/dist/esm/splitview/options.d.ts.map +1 -0
  401. package/dist/esm/splitview/options.js +2 -1
  402. package/dist/esm/splitview/options.js.map +1 -0
  403. package/dist/esm/splitview/splitview.d.ts +128 -127
  404. package/dist/esm/splitview/splitview.d.ts.map +1 -0
  405. package/dist/esm/splitview/splitview.js +690 -689
  406. package/dist/esm/splitview/splitview.js.map +1 -0
  407. package/dist/esm/splitview/splitviewComponent.d.ts +102 -101
  408. package/dist/esm/splitview/splitviewComponent.d.ts.map +1 -0
  409. package/dist/esm/splitview/splitviewComponent.js +250 -249
  410. package/dist/esm/splitview/splitviewComponent.js.map +1 -0
  411. package/dist/esm/splitview/splitviewPanel.d.ts +46 -45
  412. package/dist/esm/splitview/splitviewPanel.d.ts.map +1 -0
  413. package/dist/esm/splitview/splitviewPanel.js +109 -108
  414. package/dist/esm/splitview/splitviewPanel.js.map +1 -0
  415. package/dist/esm/splitview/viewItem.d.ts +26 -25
  416. package/dist/esm/splitview/viewItem.d.ts.map +1 -0
  417. package/dist/esm/splitview/viewItem.js +75 -74
  418. package/dist/esm/splitview/viewItem.js.map +1 -0
  419. package/dist/esm/svg.d.ts +4 -3
  420. package/dist/esm/svg.d.ts.map +1 -0
  421. package/dist/esm/svg.js +32 -31
  422. package/dist/esm/svg.js.map +1 -0
  423. package/dist/esm/types.d.ts +3 -2
  424. package/dist/esm/types.d.ts.map +1 -0
  425. package/dist/esm/types.js +2 -1
  426. package/dist/esm/types.js.map +1 -0
  427. package/dist/styles/dockview.css +54 -54
  428. package/package.json +6 -5
@@ -1,423 +1,431 @@
1
- /*---------------------------------------------------------------------------------------------
2
- * Accreditation: This file is largly based upon the MIT licenced VSCode sourcecode found at:
3
- * https://github.com/microsoft/vscode/tree/main/src/vs/base/browser/ui/grid
4
- *--------------------------------------------------------------------------------------------*/
5
- import { Orientation, Sizing, } from '../splitview/splitview';
6
- import { tail } from '../array';
7
- import { LeafNode } from './leafNode';
8
- import { BranchNode } from './branchNode';
9
- import { Emitter } from '../events';
10
- import { MutableDisposable } from '../lifecycle';
11
- function findLeaf(candiateNode, last) {
12
- if (candiateNode instanceof LeafNode) {
13
- return candiateNode;
14
- }
15
- if (candiateNode instanceof BranchNode) {
16
- return findLeaf(candiateNode.children[last ? candiateNode.children.length - 1 : 0], last);
17
- }
18
- throw new Error('invalid node');
19
- }
20
- function flipNode(node, size, orthogonalSize) {
21
- if (node instanceof BranchNode) {
22
- const result = new BranchNode(orthogonal(node.orientation), node.proportionalLayout, node.styles, size, orthogonalSize);
23
- let totalSize = 0;
24
- for (let i = node.children.length - 1; i >= 0; i--) {
25
- const child = node.children[i];
26
- const childSize = child instanceof BranchNode ? child.orthogonalSize : child.size;
27
- let newSize = node.size === 0
28
- ? 0
29
- : Math.round((size * childSize) / node.size);
30
- totalSize += newSize;
31
- // The last view to add should adjust to rounding errors
32
- if (i === 0) {
33
- newSize += size - totalSize;
34
- }
35
- result.addChild(flipNode(child, orthogonalSize, newSize), newSize, 0, true);
36
- }
37
- return result;
38
- }
39
- else {
40
- return new LeafNode(node.view, orthogonal(node.orientation), orthogonalSize);
41
- }
42
- }
43
- export function indexInParent(element) {
44
- const parentElement = element.parentElement;
45
- if (!parentElement) {
46
- throw new Error('Invalid grid element');
47
- }
48
- let el = parentElement.firstElementChild;
49
- let index = 0;
50
- while (el !== element && el !== parentElement.lastElementChild && el) {
51
- el = el.nextElementSibling;
52
- index++;
53
- }
54
- return index;
55
- }
56
- /**
57
- * Find the grid location of a specific DOM element by traversing the parent
58
- * chain and finding each child index on the way.
59
- *
60
- * This will break as soon as DOM structures of the Splitview or Gridview change.
61
- */
62
- export function getGridLocation(element) {
63
- const parentElement = element.parentElement;
64
- if (!parentElement) {
65
- throw new Error('Invalid grid element');
66
- }
67
- if (/\bgrid-view\b/.test(parentElement.className)) {
68
- return [];
69
- }
70
- const index = indexInParent(parentElement);
71
- const ancestor = parentElement.parentElement.parentElement.parentElement;
72
- return [...getGridLocation(ancestor), index];
73
- }
74
- export function getRelativeLocation(rootOrientation, location, direction) {
75
- const orientation = getLocationOrientation(rootOrientation, location);
76
- const directionOrientation = getDirectionOrientation(direction);
77
- if (orientation === directionOrientation) {
78
- const [rest, _index] = tail(location);
79
- let index = _index;
80
- if (direction === 'right' || direction === 'bottom') {
81
- index += 1;
82
- }
83
- return [...rest, index];
84
- }
85
- else {
86
- const index = direction === 'right' || direction === 'bottom' ? 1 : 0;
87
- return [...location, index];
88
- }
89
- }
90
- export function getDirectionOrientation(direction) {
91
- return direction === 'top' || direction === 'bottom'
92
- ? Orientation.VERTICAL
93
- : Orientation.HORIZONTAL;
94
- }
95
- export function getLocationOrientation(rootOrientation, location) {
96
- return location.length % 2 === 0
97
- ? orthogonal(rootOrientation)
98
- : rootOrientation;
99
- }
100
- export const orthogonal = (orientation) => orientation === Orientation.HORIZONTAL
101
- ? Orientation.VERTICAL
102
- : Orientation.HORIZONTAL;
103
- export function isGridBranchNode(node) {
104
- return !!node.children;
105
- }
106
- const serializeBranchNode = (node, orientation) => {
107
- const size = orientation === Orientation.VERTICAL ? node.box.width : node.box.height;
108
- if (!isGridBranchNode(node)) {
109
- if (typeof node.cachedVisibleSize === 'number') {
110
- return {
111
- type: 'leaf',
112
- data: node.view.toJSON(),
113
- size: node.cachedVisibleSize,
114
- visible: false,
115
- };
116
- }
117
- return { type: 'leaf', data: node.view.toJSON(), size };
118
- }
119
- return {
120
- type: 'branch',
121
- data: node.children.map((c) => serializeBranchNode(c, orthogonal(orientation))),
122
- size,
123
- };
124
- };
125
- export class Gridview {
126
- get length() {
127
- return this._root ? this._root.children.length : 0;
128
- }
129
- get orientation() {
130
- return this.root.orientation;
131
- }
132
- set orientation(orientation) {
133
- if (this.root.orientation === orientation) {
134
- return;
135
- }
136
- const { size, orthogonalSize } = this.root;
137
- this.root = flipNode(this.root, orthogonalSize, size);
138
- this.root.layout(size, orthogonalSize);
139
- }
140
- get width() {
141
- return this.root.width;
142
- }
143
- get height() {
144
- return this.root.height;
145
- }
146
- get minimumWidth() {
147
- return this.root.minimumWidth;
148
- }
149
- get minimumHeight() {
150
- return this.root.minimumHeight;
151
- }
152
- get maximumWidth() {
153
- return this.root.maximumHeight;
154
- }
155
- get maximumHeight() {
156
- return this.root.maximumHeight;
157
- }
158
- serialize() {
159
- const root = serializeBranchNode(this.getView(), this.orientation);
160
- return {
161
- root,
162
- width: this.width,
163
- height: this.height,
164
- orientation: this.orientation,
165
- };
166
- }
167
- dispose() {
168
- this.disposable.dispose();
169
- this._onDidChange.dispose();
170
- this.root.dispose();
171
- this.element.remove();
172
- }
173
- clear() {
174
- const orientation = this.root.orientation;
175
- this.root = new BranchNode(orientation, this.proportionalLayout, this.styles, this.root.size, this.root.orthogonalSize);
176
- }
177
- deserialize(json, deserializer) {
178
- const orientation = json.orientation;
179
- const height = orientation === Orientation.VERTICAL ? json.height : json.width;
180
- this._deserialize(json.root, orientation, deserializer, height);
181
- }
182
- _deserialize(root, orientation, deserializer, orthogonalSize) {
183
- this.root = this._deserializeNode(root, orientation, deserializer, orthogonalSize, true);
184
- }
185
- _deserializeNode(node, orientation, deserializer, orthogonalSize, isRoot = false) {
186
- let result;
187
- if (node.type === 'branch') {
188
- const serializedChildren = node.data;
189
- const children = serializedChildren.map((serializedChild) => {
190
- return {
191
- node: this._deserializeNode(serializedChild, orthogonal(orientation), deserializer, node.size),
192
- visible: serializedChild.visible,
193
- };
194
- });
195
- // HORIZONTAL => height=orthogonalsize width=size
196
- // VERTICAL => height=size width=orthogonalsize
197
- result = new BranchNode(orientation, this.proportionalLayout, this.styles, isRoot ? orthogonalSize : node.size, isRoot ? node.size : orthogonalSize, children);
198
- }
199
- else {
200
- result = new LeafNode(deserializer.fromJSON(node), orientation, orthogonalSize, node.size);
201
- }
202
- return result;
203
- }
204
- get root() {
205
- return this._root;
206
- }
207
- set root(root) {
208
- const oldRoot = this._root;
209
- if (oldRoot) {
210
- oldRoot.dispose();
211
- this.element.removeChild(oldRoot.element);
212
- }
213
- this._root = root;
214
- this.element.appendChild(this._root.element);
215
- this.disposable.value = this._root.onDidChange((e) => {
216
- this._onDidChange.fire(e);
217
- });
218
- }
219
- /**
220
- * If the root is orientated as a VERTICAL node then nest the existing root within a new HORIZIONTAL root node
221
- * If the root is orientated as a HORIZONTAL node then nest the existing root within a new VERITCAL root node
222
- */
223
- insertOrthogonalSplitviewAtRoot() {
224
- if (!this._root) {
225
- return;
226
- }
227
- const oldRoot = this.root;
228
- oldRoot.element.remove();
229
- this._root = new BranchNode(orthogonal(oldRoot.orientation), this.proportionalLayout, this.styles, this.root.orthogonalSize, this.root.size);
230
- if (oldRoot.children.length === 1) {
231
- // can remove one level of redundant branching if there is only a single child
232
- const childReference = oldRoot.children[0];
233
- oldRoot.removeChild(0); // remove to prevent disposal when disposing of unwanted root
234
- oldRoot.dispose();
235
- this._root.addChild(childReference, Sizing.Distribute, 0);
236
- }
237
- else {
238
- this._root.addChild(oldRoot, Sizing.Distribute, 0);
239
- }
240
- this.element.appendChild(this._root.element);
241
- this.disposable.value = this._root.onDidChange((e) => {
242
- this._onDidChange.fire(e);
243
- });
244
- }
245
- next(location) {
246
- return this.progmaticSelect(location);
247
- }
248
- previous(location) {
249
- return this.progmaticSelect(location, true);
250
- }
251
- getView(location) {
252
- const node = location ? this.getNode(location)[1] : this.root;
253
- return this._getViews(node, this.orientation);
254
- }
255
- _getViews(node, orientation, cachedVisibleSize) {
256
- const box = { height: node.height, width: node.width };
257
- if (node instanceof LeafNode) {
258
- return { box, view: node.view, cachedVisibleSize };
259
- }
260
- const children = [];
261
- for (let i = 0; i < node.children.length; i++) {
262
- const child = node.children[i];
263
- const nodeCachedVisibleSize = node.getChildCachedVisibleSize(i);
264
- children.push(this._getViews(child, orthogonal(orientation), nodeCachedVisibleSize));
265
- }
266
- return { box, children };
267
- }
268
- progmaticSelect(location, reverse = false) {
269
- const [path, node] = this.getNode(location);
270
- if (!(node instanceof LeafNode)) {
271
- throw new Error('invalid location');
272
- }
273
- for (let i = path.length - 1; i > -1; i--) {
274
- const n = path[i];
275
- const l = location[i] || 0;
276
- const canProgressInCurrentLevel = reverse
277
- ? l - 1 > -1
278
- : l + 1 < n.children.length;
279
- if (canProgressInCurrentLevel) {
280
- return findLeaf(n.children[reverse ? l - 1 : l + 1], reverse);
281
- }
282
- }
283
- return findLeaf(this.root, reverse);
284
- }
285
- constructor(proportionalLayout, styles, orientation) {
286
- this.proportionalLayout = proportionalLayout;
287
- this.styles = styles;
288
- this.disposable = new MutableDisposable();
289
- this._onDidChange = new Emitter();
290
- this.onDidChange = this._onDidChange.event;
291
- this.element = document.createElement('div');
292
- this.element.className = 'grid-view';
293
- this.root = new BranchNode(orientation, proportionalLayout, styles, 0, 0);
294
- }
295
- isViewVisible(location) {
296
- const [rest, index] = tail(location);
297
- const [, parent] = this.getNode(rest);
298
- if (!(parent instanceof BranchNode)) {
299
- throw new Error('Invalid from location');
300
- }
301
- return parent.isChildVisible(index);
302
- }
303
- setViewVisible(location, visible) {
304
- const [rest, index] = tail(location);
305
- const [, parent] = this.getNode(rest);
306
- if (!(parent instanceof BranchNode)) {
307
- throw new Error('Invalid from location');
308
- }
309
- parent.setChildVisible(index, visible);
310
- }
311
- moveView(parentLocation, from, to) {
312
- const [, parent] = this.getNode(parentLocation);
313
- if (!(parent instanceof BranchNode)) {
314
- throw new Error('Invalid location');
315
- }
316
- parent.moveChild(from, to);
317
- }
318
- addView(view, size, location) {
319
- const [rest, index] = tail(location);
320
- const [pathToParent, parent] = this.getNode(rest);
321
- if (parent instanceof BranchNode) {
322
- const node = new LeafNode(view, orthogonal(parent.orientation), parent.orthogonalSize);
323
- parent.addChild(node, size, index);
324
- }
325
- else {
326
- const [grandParent, ..._] = [...pathToParent].reverse();
327
- const [parentIndex, ...__] = [...rest].reverse();
328
- let newSiblingSize = 0;
329
- const newSiblingCachedVisibleSize = grandParent.getChildCachedVisibleSize(parentIndex);
330
- if (typeof newSiblingCachedVisibleSize === 'number') {
331
- newSiblingSize = Sizing.Invisible(newSiblingCachedVisibleSize);
332
- }
333
- grandParent.removeChild(parentIndex);
334
- const newParent = new BranchNode(parent.orientation, this.proportionalLayout, this.styles, parent.size, parent.orthogonalSize);
335
- grandParent.addChild(newParent, parent.size, parentIndex);
336
- const newSibling = new LeafNode(parent.view, grandParent.orientation, parent.size);
337
- newParent.addChild(newSibling, newSiblingSize, 0);
338
- if (typeof size !== 'number' && size.type === 'split') {
339
- size = { type: 'split', index: 0 };
340
- }
341
- const node = new LeafNode(view, grandParent.orientation, parent.size);
342
- newParent.addChild(node, size, index);
343
- }
344
- }
345
- remove(view, sizing) {
346
- const location = getGridLocation(view.element);
347
- return this.removeView(location, sizing);
348
- }
349
- removeView(location, sizing) {
350
- const [rest, index] = tail(location);
351
- const [pathToParent, parent] = this.getNode(rest);
352
- if (!(parent instanceof BranchNode)) {
353
- throw new Error('Invalid location');
354
- }
355
- const node = parent.children[index];
356
- if (!(node instanceof LeafNode)) {
357
- throw new Error('Invalid location');
358
- }
359
- parent.removeChild(index, sizing);
360
- if (parent.children.length === 0) {
361
- return node.view;
362
- }
363
- if (parent.children.length > 1) {
364
- return node.view;
365
- }
366
- const sibling = parent.children[0];
367
- if (pathToParent.length === 0) {
368
- // parent is root
369
- if (sibling instanceof LeafNode) {
370
- return node.view;
371
- }
372
- // we must promote sibling to be the new root
373
- parent.removeChild(0, sizing);
374
- this.root = sibling;
375
- return node.view;
376
- }
377
- const [grandParent, ..._] = [...pathToParent].reverse();
378
- const [parentIndex, ...__] = [...rest].reverse();
379
- const isSiblingVisible = parent.isChildVisible(0);
380
- parent.removeChild(0, sizing);
381
- const sizes = grandParent.children.map((_size, i) => grandParent.getChildSize(i));
382
- grandParent.removeChild(parentIndex, sizing);
383
- if (sibling instanceof BranchNode) {
384
- sizes.splice(parentIndex, 1, ...sibling.children.map((c) => c.size));
385
- for (let i = 0; i < sibling.children.length; i++) {
386
- const child = sibling.children[i];
387
- grandParent.addChild(child, child.size, parentIndex + i);
388
- }
389
- }
390
- else {
391
- const newSibling = new LeafNode(sibling.view, orthogonal(sibling.orientation), sibling.size);
392
- const siblingSizing = isSiblingVisible
393
- ? sibling.orthogonalSize
394
- : Sizing.Invisible(sibling.orthogonalSize);
395
- grandParent.addChild(newSibling, siblingSizing, parentIndex);
396
- }
397
- for (let i = 0; i < sizes.length; i++) {
398
- grandParent.resizeChild(i, sizes[i]);
399
- }
400
- return node.view;
401
- }
402
- layout(width, height) {
403
- const [size, orthogonalSize] = this.root.orientation === Orientation.HORIZONTAL
404
- ? [height, width]
405
- : [width, height];
406
- this.root.layout(size, orthogonalSize);
407
- }
408
- getNode(location, node = this.root, path = []) {
409
- if (location.length === 0) {
410
- return [path, node];
411
- }
412
- if (!(node instanceof BranchNode)) {
413
- throw new Error('Invalid location');
414
- }
415
- const [index, ...rest] = location;
416
- if (index < 0 || index >= node.children.length) {
417
- throw new Error('Invalid location');
418
- }
419
- const child = node.children[index];
420
- path.push(node);
421
- return this.getNode(rest, child, path);
422
- }
423
- }
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Accreditation: This file is largly based upon the MIT licenced VSCode sourcecode found at:
3
+ * https://github.com/microsoft/vscode/tree/main/src/vs/base/browser/ui/grid
4
+ *--------------------------------------------------------------------------------------------*/
5
+ import { Orientation, Sizing, } from '../splitview/splitview';
6
+ import { tail } from '../array';
7
+ import { LeafNode } from './leafNode';
8
+ import { BranchNode } from './branchNode';
9
+ import { Emitter } from '../events';
10
+ import { MutableDisposable } from '../lifecycle';
11
+ function findLeaf(candiateNode, last) {
12
+ if (candiateNode instanceof LeafNode) {
13
+ return candiateNode;
14
+ }
15
+ if (candiateNode instanceof BranchNode) {
16
+ return findLeaf(candiateNode.children[last ? candiateNode.children.length - 1 : 0], last);
17
+ }
18
+ throw new Error('invalid node');
19
+ }
20
+ function flipNode(node, size, orthogonalSize) {
21
+ if (node instanceof BranchNode) {
22
+ const result = new BranchNode(orthogonal(node.orientation), node.proportionalLayout, node.styles, size, orthogonalSize);
23
+ let totalSize = 0;
24
+ for (let i = node.children.length - 1; i >= 0; i--) {
25
+ const child = node.children[i];
26
+ const childSize = child instanceof BranchNode ? child.orthogonalSize : child.size;
27
+ let newSize = node.size === 0
28
+ ? 0
29
+ : Math.round((size * childSize) / node.size);
30
+ totalSize += newSize;
31
+ // The last view to add should adjust to rounding errors
32
+ if (i === 0) {
33
+ newSize += size - totalSize;
34
+ }
35
+ result.addChild(flipNode(child, orthogonalSize, newSize), newSize, 0, true);
36
+ }
37
+ return result;
38
+ }
39
+ else {
40
+ return new LeafNode(node.view, orthogonal(node.orientation), orthogonalSize);
41
+ }
42
+ }
43
+ export function indexInParent(element) {
44
+ const parentElement = element.parentElement;
45
+ if (!parentElement) {
46
+ throw new Error('Invalid grid element');
47
+ }
48
+ let el = parentElement.firstElementChild;
49
+ let index = 0;
50
+ while (el !== element && el !== parentElement.lastElementChild && el) {
51
+ el = el.nextElementSibling;
52
+ index++;
53
+ }
54
+ return index;
55
+ }
56
+ /**
57
+ * Find the grid location of a specific DOM element by traversing the parent
58
+ * chain and finding each child index on the way.
59
+ *
60
+ * This will break as soon as DOM structures of the Splitview or Gridview change.
61
+ */
62
+ export function getGridLocation(element) {
63
+ const parentElement = element.parentElement;
64
+ if (!parentElement) {
65
+ throw new Error('Invalid grid element');
66
+ }
67
+ if (/\bgrid-view\b/.test(parentElement.className)) {
68
+ return [];
69
+ }
70
+ const index = indexInParent(parentElement);
71
+ const ancestor = parentElement.parentElement.parentElement.parentElement;
72
+ return [...getGridLocation(ancestor), index];
73
+ }
74
+ export function getRelativeLocation(rootOrientation, location, direction) {
75
+ const orientation = getLocationOrientation(rootOrientation, location);
76
+ const directionOrientation = getDirectionOrientation(direction);
77
+ if (orientation === directionOrientation) {
78
+ const [rest, _index] = tail(location);
79
+ let index = _index;
80
+ if (direction === 'right' || direction === 'bottom') {
81
+ index += 1;
82
+ }
83
+ return [...rest, index];
84
+ }
85
+ else {
86
+ const index = direction === 'right' || direction === 'bottom' ? 1 : 0;
87
+ return [...location, index];
88
+ }
89
+ }
90
+ export function getDirectionOrientation(direction) {
91
+ return direction === 'top' || direction === 'bottom'
92
+ ? Orientation.VERTICAL
93
+ : Orientation.HORIZONTAL;
94
+ }
95
+ export function getLocationOrientation(rootOrientation, location) {
96
+ return location.length % 2 === 0
97
+ ? orthogonal(rootOrientation)
98
+ : rootOrientation;
99
+ }
100
+ export const orthogonal = (orientation) => orientation === Orientation.HORIZONTAL
101
+ ? Orientation.VERTICAL
102
+ : Orientation.HORIZONTAL;
103
+ export function isGridBranchNode(node) {
104
+ return !!node.children;
105
+ }
106
+ const serializeBranchNode = (node, orientation) => {
107
+ const size = orientation === Orientation.VERTICAL ? node.box.width : node.box.height;
108
+ if (!isGridBranchNode(node)) {
109
+ if (typeof node.cachedVisibleSize === 'number') {
110
+ return {
111
+ type: 'leaf',
112
+ data: node.view.toJSON(),
113
+ size: node.cachedVisibleSize,
114
+ visible: false,
115
+ };
116
+ }
117
+ return { type: 'leaf', data: node.view.toJSON(), size };
118
+ }
119
+ return {
120
+ type: 'branch',
121
+ data: node.children.map((c) => serializeBranchNode(c, orthogonal(orientation))),
122
+ size,
123
+ };
124
+ };
125
+ export class Gridview {
126
+ get length() {
127
+ return this._root ? this._root.children.length : 0;
128
+ }
129
+ get orientation() {
130
+ return this.root.orientation;
131
+ }
132
+ set orientation(orientation) {
133
+ if (this.root.orientation === orientation) {
134
+ return;
135
+ }
136
+ const { size, orthogonalSize } = this.root;
137
+ this.root = flipNode(this.root, orthogonalSize, size);
138
+ this.root.layout(size, orthogonalSize);
139
+ }
140
+ get width() {
141
+ return this.root.width;
142
+ }
143
+ get height() {
144
+ return this.root.height;
145
+ }
146
+ get minimumWidth() {
147
+ return this.root.minimumWidth;
148
+ }
149
+ get minimumHeight() {
150
+ return this.root.minimumHeight;
151
+ }
152
+ get maximumWidth() {
153
+ return this.root.maximumHeight;
154
+ }
155
+ get maximumHeight() {
156
+ return this.root.maximumHeight;
157
+ }
158
+ serialize() {
159
+ const root = serializeBranchNode(this.getView(), this.orientation);
160
+ return {
161
+ root,
162
+ width: this.width,
163
+ height: this.height,
164
+ orientation: this.orientation,
165
+ };
166
+ }
167
+ dispose() {
168
+ this.disposable.dispose();
169
+ this._onDidChange.dispose();
170
+ this.root.dispose();
171
+ this.element.remove();
172
+ }
173
+ clear() {
174
+ const orientation = this.root.orientation;
175
+ this.root = new BranchNode(orientation, this.proportionalLayout, this.styles, this.root.size, this.root.orthogonalSize);
176
+ }
177
+ deserialize(json, deserializer) {
178
+ const orientation = json.orientation;
179
+ const height = orientation === Orientation.VERTICAL ? json.height : json.width;
180
+ this._deserialize(json.root, orientation, deserializer, height);
181
+ }
182
+ _deserialize(root, orientation, deserializer, orthogonalSize) {
183
+ this.root = this._deserializeNode(root, orientation, deserializer, orthogonalSize, true);
184
+ }
185
+ _deserializeNode(node, orientation, deserializer, orthogonalSize, isRoot = false) {
186
+ let result;
187
+ if (node.type === 'branch') {
188
+ const serializedChildren = node.data;
189
+ const children = serializedChildren.map((serializedChild) => {
190
+ return {
191
+ node: this._deserializeNode(serializedChild, orthogonal(orientation), deserializer, node.size),
192
+ visible: serializedChild.visible,
193
+ };
194
+ });
195
+ // HORIZONTAL => height=orthogonalsize width=size
196
+ // VERTICAL => height=size width=orthogonalsize
197
+ result = new BranchNode(orientation, this.proportionalLayout, this.styles, isRoot ? orthogonalSize : node.size, isRoot ? node.size : orthogonalSize, children);
198
+ }
199
+ else {
200
+ result = new LeafNode(deserializer.fromJSON(node), orientation, orthogonalSize, node.size);
201
+ }
202
+ return result;
203
+ }
204
+ get root() {
205
+ return this._root;
206
+ }
207
+ set root(root) {
208
+ const oldRoot = this._root;
209
+ if (oldRoot) {
210
+ oldRoot.dispose();
211
+ this.element.removeChild(oldRoot.element);
212
+ }
213
+ this._root = root;
214
+ this.element.appendChild(this._root.element);
215
+ this.disposable.value = this._root.onDidChange((e) => {
216
+ this._onDidChange.fire(e);
217
+ });
218
+ }
219
+ /**
220
+ * If the root is orientated as a VERTICAL node then nest the existing root within a new HORIZIONTAL root node
221
+ * If the root is orientated as a HORIZONTAL node then nest the existing root within a new VERITCAL root node
222
+ */
223
+ insertOrthogonalSplitviewAtRoot() {
224
+ if (!this._root) {
225
+ return;
226
+ }
227
+ const oldRoot = this.root;
228
+ oldRoot.element.remove();
229
+ this._root = new BranchNode(orthogonal(oldRoot.orientation), this.proportionalLayout, this.styles, this.root.orthogonalSize, this.root.size);
230
+ if (oldRoot.children.length === 1) {
231
+ // can remove one level of redundant branching if there is only a single child
232
+ const childReference = oldRoot.children[0];
233
+ oldRoot.removeChild(0); // remove to prevent disposal when disposing of unwanted root
234
+ oldRoot.dispose();
235
+ this._root.addChild(
236
+ /**
237
+ * the child node will have the same orientation as the new root since
238
+ * we are removing the inbetween node.
239
+ * the entire 'tree' must be flipped recursively to ensure that the orientation
240
+ * flips at each level
241
+ */
242
+ flipNode(childReference, childReference.orthogonalSize, childReference.size), Sizing.Distribute, 0);
243
+ }
244
+ else {
245
+ this._root.addChild(oldRoot, Sizing.Distribute, 0);
246
+ }
247
+ this.element.appendChild(this._root.element);
248
+ this.disposable.value = this._root.onDidChange((e) => {
249
+ this._onDidChange.fire(e);
250
+ });
251
+ }
252
+ next(location) {
253
+ return this.progmaticSelect(location);
254
+ }
255
+ previous(location) {
256
+ return this.progmaticSelect(location, true);
257
+ }
258
+ getView(location) {
259
+ const node = location ? this.getNode(location)[1] : this.root;
260
+ return this._getViews(node, this.orientation);
261
+ }
262
+ _getViews(node, orientation, cachedVisibleSize) {
263
+ const box = { height: node.height, width: node.width };
264
+ if (node instanceof LeafNode) {
265
+ return { box, view: node.view, cachedVisibleSize };
266
+ }
267
+ const children = [];
268
+ for (let i = 0; i < node.children.length; i++) {
269
+ const child = node.children[i];
270
+ const nodeCachedVisibleSize = node.getChildCachedVisibleSize(i);
271
+ children.push(this._getViews(child, orthogonal(orientation), nodeCachedVisibleSize));
272
+ }
273
+ return { box, children };
274
+ }
275
+ progmaticSelect(location, reverse = false) {
276
+ const [path, node] = this.getNode(location);
277
+ if (!(node instanceof LeafNode)) {
278
+ throw new Error('invalid location');
279
+ }
280
+ for (let i = path.length - 1; i > -1; i--) {
281
+ const n = path[i];
282
+ const l = location[i] || 0;
283
+ const canProgressInCurrentLevel = reverse
284
+ ? l - 1 > -1
285
+ : l + 1 < n.children.length;
286
+ if (canProgressInCurrentLevel) {
287
+ return findLeaf(n.children[reverse ? l - 1 : l + 1], reverse);
288
+ }
289
+ }
290
+ return findLeaf(this.root, reverse);
291
+ }
292
+ constructor(proportionalLayout, styles, orientation) {
293
+ this.proportionalLayout = proportionalLayout;
294
+ this.styles = styles;
295
+ this.disposable = new MutableDisposable();
296
+ this._onDidChange = new Emitter();
297
+ this.onDidChange = this._onDidChange.event;
298
+ this.element = document.createElement('div');
299
+ this.element.className = 'grid-view';
300
+ this.root = new BranchNode(orientation, proportionalLayout, styles, 0, 0);
301
+ }
302
+ isViewVisible(location) {
303
+ const [rest, index] = tail(location);
304
+ const [, parent] = this.getNode(rest);
305
+ if (!(parent instanceof BranchNode)) {
306
+ throw new Error('Invalid from location');
307
+ }
308
+ return parent.isChildVisible(index);
309
+ }
310
+ setViewVisible(location, visible) {
311
+ const [rest, index] = tail(location);
312
+ const [, parent] = this.getNode(rest);
313
+ if (!(parent instanceof BranchNode)) {
314
+ throw new Error('Invalid from location');
315
+ }
316
+ parent.setChildVisible(index, visible);
317
+ }
318
+ moveView(parentLocation, from, to) {
319
+ const [, parent] = this.getNode(parentLocation);
320
+ if (!(parent instanceof BranchNode)) {
321
+ throw new Error('Invalid location');
322
+ }
323
+ parent.moveChild(from, to);
324
+ }
325
+ addView(view, size, location) {
326
+ const [rest, index] = tail(location);
327
+ const [pathToParent, parent] = this.getNode(rest);
328
+ if (parent instanceof BranchNode) {
329
+ const node = new LeafNode(view, orthogonal(parent.orientation), parent.orthogonalSize);
330
+ parent.addChild(node, size, index);
331
+ }
332
+ else {
333
+ const [grandParent, ..._] = [...pathToParent].reverse();
334
+ const [parentIndex, ...__] = [...rest].reverse();
335
+ let newSiblingSize = 0;
336
+ const newSiblingCachedVisibleSize = grandParent.getChildCachedVisibleSize(parentIndex);
337
+ if (typeof newSiblingCachedVisibleSize === 'number') {
338
+ newSiblingSize = Sizing.Invisible(newSiblingCachedVisibleSize);
339
+ }
340
+ grandParent.removeChild(parentIndex);
341
+ const newParent = new BranchNode(parent.orientation, this.proportionalLayout, this.styles, parent.size, parent.orthogonalSize);
342
+ grandParent.addChild(newParent, parent.size, parentIndex);
343
+ const newSibling = new LeafNode(parent.view, grandParent.orientation, parent.size);
344
+ newParent.addChild(newSibling, newSiblingSize, 0);
345
+ if (typeof size !== 'number' && size.type === 'split') {
346
+ size = { type: 'split', index: 0 };
347
+ }
348
+ const node = new LeafNode(view, grandParent.orientation, parent.size);
349
+ newParent.addChild(node, size, index);
350
+ }
351
+ }
352
+ remove(view, sizing) {
353
+ const location = getGridLocation(view.element);
354
+ return this.removeView(location, sizing);
355
+ }
356
+ removeView(location, sizing) {
357
+ const [rest, index] = tail(location);
358
+ const [pathToParent, parent] = this.getNode(rest);
359
+ if (!(parent instanceof BranchNode)) {
360
+ throw new Error('Invalid location');
361
+ }
362
+ const node = parent.children[index];
363
+ if (!(node instanceof LeafNode)) {
364
+ throw new Error('Invalid location');
365
+ }
366
+ parent.removeChild(index, sizing);
367
+ if (parent.children.length === 0) {
368
+ return node.view;
369
+ }
370
+ if (parent.children.length > 1) {
371
+ return node.view;
372
+ }
373
+ const sibling = parent.children[0];
374
+ if (pathToParent.length === 0) {
375
+ // parent is root
376
+ if (sibling instanceof LeafNode) {
377
+ return node.view;
378
+ }
379
+ // we must promote sibling to be the new root
380
+ parent.removeChild(0, sizing);
381
+ this.root = sibling;
382
+ return node.view;
383
+ }
384
+ const [grandParent, ..._] = [...pathToParent].reverse();
385
+ const [parentIndex, ...__] = [...rest].reverse();
386
+ const isSiblingVisible = parent.isChildVisible(0);
387
+ parent.removeChild(0, sizing);
388
+ const sizes = grandParent.children.map((_size, i) => grandParent.getChildSize(i));
389
+ grandParent.removeChild(parentIndex, sizing);
390
+ if (sibling instanceof BranchNode) {
391
+ sizes.splice(parentIndex, 1, ...sibling.children.map((c) => c.size));
392
+ for (let i = 0; i < sibling.children.length; i++) {
393
+ const child = sibling.children[i];
394
+ grandParent.addChild(child, child.size, parentIndex + i);
395
+ }
396
+ }
397
+ else {
398
+ const newSibling = new LeafNode(sibling.view, orthogonal(sibling.orientation), sibling.size);
399
+ const siblingSizing = isSiblingVisible
400
+ ? sibling.orthogonalSize
401
+ : Sizing.Invisible(sibling.orthogonalSize);
402
+ grandParent.addChild(newSibling, siblingSizing, parentIndex);
403
+ }
404
+ for (let i = 0; i < sizes.length; i++) {
405
+ grandParent.resizeChild(i, sizes[i]);
406
+ }
407
+ return node.view;
408
+ }
409
+ layout(width, height) {
410
+ const [size, orthogonalSize] = this.root.orientation === Orientation.HORIZONTAL
411
+ ? [height, width]
412
+ : [width, height];
413
+ this.root.layout(size, orthogonalSize);
414
+ }
415
+ getNode(location, node = this.root, path = []) {
416
+ if (location.length === 0) {
417
+ return [path, node];
418
+ }
419
+ if (!(node instanceof BranchNode)) {
420
+ throw new Error('Invalid location');
421
+ }
422
+ const [index, ...rest] = location;
423
+ if (index < 0 || index >= node.children.length) {
424
+ throw new Error('Invalid location');
425
+ }
426
+ const child = node.children[index];
427
+ path.push(node);
428
+ return this.getNode(rest, child, path);
429
+ }
430
+ }
431
+ //# sourceMappingURL=gridview.js.map