dockview 1.5.1 → 1.6.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 (378) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +52 -52
  3. package/dist/cjs/actionbar/actionsContainer.d.ts +7 -7
  4. package/dist/cjs/actionbar/actionsContainer.js +26 -26
  5. package/dist/cjs/api/component.api.d.ts +145 -144
  6. package/dist/cjs/api/component.api.js +578 -571
  7. package/dist/cjs/api/component.api.js.map +1 -1
  8. package/dist/cjs/api/{groupPanelApi.d.ts → dockviewPanelApi.d.ts} +34 -34
  9. package/dist/cjs/api/{groupPanelApi.js → dockviewPanelApi.js} +84 -86
  10. package/dist/cjs/api/dockviewPanelApi.js.map +1 -0
  11. package/dist/cjs/api/gridviewPanelApi.d.ts +37 -36
  12. package/dist/cjs/api/gridviewPanelApi.js +47 -47
  13. package/dist/cjs/api/gridviewPanelApi.js.map +1 -1
  14. package/dist/cjs/api/panelApi.d.ts +88 -81
  15. package/dist/cjs/api/panelApi.js +137 -121
  16. package/dist/cjs/api/panelApi.js.map +1 -1
  17. package/dist/cjs/api/paneviewPanelApi.d.ts +26 -26
  18. package/dist/cjs/api/paneviewPanelApi.js +57 -57
  19. package/dist/cjs/api/splitviewPanelApi.d.ts +32 -32
  20. package/dist/cjs/api/splitviewPanelApi.js +47 -47
  21. package/dist/cjs/array.d.ts +13 -13
  22. package/dist/cjs/array.js +77 -77
  23. package/dist/cjs/dnd/abstractDragHandler.d.ts +11 -11
  24. package/dist/cjs/dnd/abstractDragHandler.js +115 -115
  25. package/dist/cjs/dnd/abstractDragHandler.js.map +1 -1
  26. package/dist/cjs/dnd/dataTransfer.d.ts +31 -31
  27. package/dist/cjs/dnd/dataTransfer.js +100 -100
  28. package/dist/cjs/dnd/dataTransfer.js.map +1 -1
  29. package/dist/cjs/dnd/dnd.d.ts +27 -27
  30. package/dist/cjs/dnd/dnd.js +59 -64
  31. package/dist/cjs/dnd/dnd.js.map +1 -1
  32. package/dist/cjs/dnd/droptarget.d.ts +42 -37
  33. package/dist/cjs/dnd/droptarget.js +279 -201
  34. package/dist/cjs/dnd/droptarget.js.map +1 -1
  35. package/dist/cjs/dnd/ghost.d.ts +1 -0
  36. package/dist/cjs/dnd/ghost.js +15 -0
  37. package/dist/cjs/dnd/ghost.js.map +1 -0
  38. package/dist/cjs/dnd/groupDragHandler.d.ts +11 -0
  39. package/dist/cjs/dnd/groupDragHandler.js +62 -0
  40. package/dist/cjs/dnd/groupDragHandler.js.map +1 -0
  41. package/dist/cjs/dockview/components/tab/defaultTab.d.ts +27 -27
  42. package/dist/cjs/dockview/components/tab/defaultTab.js +121 -121
  43. package/dist/cjs/dockview/components/watermark/watermark.d.ts +20 -20
  44. package/dist/cjs/dockview/components/watermark/watermark.js +101 -101
  45. package/dist/cjs/dockview/defaultGroupPanelView.d.ts +29 -29
  46. package/dist/cjs/dockview/defaultGroupPanelView.js +68 -68
  47. package/dist/cjs/dockview/deserializer.d.ts +6 -5
  48. package/dist/cjs/dockview/deserializer.js +2 -2
  49. package/dist/cjs/dockview/dockviewComponent.d.ts +133 -125
  50. package/dist/cjs/dockview/dockviewComponent.js +795 -614
  51. package/dist/cjs/dockview/dockviewComponent.js.map +1 -1
  52. package/dist/{esm/dockview/dockviewGroupPanel.d.ts → cjs/dockview/dockviewPanel.d.ts} +42 -31
  53. package/dist/cjs/dockview/{dockviewGroupPanel.js → dockviewPanel.js} +161 -157
  54. package/dist/cjs/dockview/dockviewPanel.js.map +1 -0
  55. package/dist/cjs/dockview/options.d.ts +110 -88
  56. package/dist/cjs/dockview/options.js +31 -2
  57. package/dist/cjs/dockview/options.js.map +1 -1
  58. package/dist/cjs/dockview/validation.d.ts +2 -0
  59. package/dist/cjs/dockview/validation.js +135 -0
  60. package/dist/cjs/dockview/validation.js.map +1 -0
  61. package/dist/cjs/dom.d.ts +14 -14
  62. package/dist/cjs/dom.js +182 -182
  63. package/dist/cjs/events.d.ts +30 -30
  64. package/dist/cjs/events.js +129 -129
  65. package/dist/cjs/gridview/baseComponentGridview.d.ts +87 -87
  66. package/dist/cjs/gridview/baseComponentGridview.js +278 -279
  67. package/dist/cjs/gridview/baseComponentGridview.js.map +1 -1
  68. package/dist/cjs/gridview/basePanelView.d.ts +43 -43
  69. package/dist/cjs/gridview/basePanelView.js +123 -123
  70. package/dist/cjs/gridview/branchNode.d.ts +49 -46
  71. package/dist/cjs/gridview/branchNode.js +342 -342
  72. package/dist/cjs/gridview/branchNode.js.map +1 -1
  73. package/dist/cjs/gridview/gridview.d.ts +132 -123
  74. package/dist/cjs/gridview/gridview.js +510 -479
  75. package/dist/cjs/gridview/gridview.js.map +1 -1
  76. package/dist/cjs/gridview/gridviewComponent.d.ts +85 -85
  77. package/dist/cjs/gridview/gridviewComponent.js +324 -325
  78. package/dist/cjs/gridview/gridviewComponent.js.map +1 -1
  79. package/dist/cjs/gridview/gridviewPanel.d.ts +60 -60
  80. package/dist/cjs/gridview/gridviewPanel.js +201 -202
  81. package/dist/cjs/gridview/gridviewPanel.js.map +1 -1
  82. package/dist/cjs/gridview/leafNode.d.ts +34 -31
  83. package/dist/cjs/gridview/leafNode.js +170 -165
  84. package/dist/cjs/gridview/leafNode.js.map +1 -1
  85. package/dist/cjs/gridview/options.d.ts +18 -18
  86. package/dist/cjs/gridview/options.js +2 -2
  87. package/dist/cjs/gridview/types.d.ts +3 -3
  88. package/dist/cjs/gridview/types.js +2 -2
  89. package/dist/cjs/groupview/dnd.d.ts +6 -5
  90. package/dist/cjs/groupview/dnd.js +10 -9
  91. package/dist/cjs/groupview/dnd.js.map +1 -1
  92. package/dist/cjs/groupview/groupview.d.ts +177 -177
  93. package/dist/cjs/groupview/groupview.js +607 -589
  94. package/dist/cjs/groupview/groupview.js.map +1 -1
  95. package/dist/cjs/groupview/groupviewPanel.d.ts +35 -35
  96. package/dist/cjs/groupview/groupviewPanel.js +128 -128
  97. package/dist/cjs/groupview/panel/content.d.ts +30 -30
  98. package/dist/cjs/groupview/panel/content.js +100 -100
  99. package/dist/cjs/groupview/tab.d.ts +31 -41
  100. package/dist/cjs/groupview/tab.js +124 -120
  101. package/dist/cjs/groupview/tab.js.map +1 -1
  102. package/dist/cjs/groupview/titlebar/tabsContainer.d.ts +65 -68
  103. package/dist/cjs/groupview/titlebar/tabsContainer.js +251 -258
  104. package/dist/cjs/groupview/titlebar/tabsContainer.js.map +1 -1
  105. package/dist/cjs/groupview/titlebar/voidContainer.d.ts +15 -0
  106. package/dist/cjs/groupview/titlebar/voidContainer.js +74 -0
  107. package/dist/cjs/groupview/titlebar/voidContainer.js.map +1 -0
  108. package/dist/cjs/groupview/types.d.ts +68 -52
  109. package/dist/cjs/groupview/types.js +2 -2
  110. package/dist/cjs/hostedContainer.d.ts +23 -23
  111. package/dist/cjs/hostedContainer.js +73 -73
  112. package/dist/cjs/index.d.ts +30 -30
  113. package/dist/cjs/index.js +47 -46
  114. package/dist/cjs/index.js.map +1 -1
  115. package/dist/cjs/lifecycle.d.ts +22 -22
  116. package/dist/cjs/lifecycle.js +88 -88
  117. package/dist/cjs/math.d.ts +4 -4
  118. package/dist/cjs/math.js +15 -15
  119. package/dist/cjs/panel/componentFactory.d.ts +8 -8
  120. package/dist/cjs/panel/componentFactory.js +30 -30
  121. package/dist/cjs/panel/types.d.ts +33 -33
  122. package/dist/cjs/panel/types.js +2 -2
  123. package/dist/cjs/paneview/defaultPaneviewHeader.d.ts +21 -21
  124. package/dist/cjs/paneview/defaultPaneviewHeader.js +90 -90
  125. package/dist/cjs/paneview/draggablePaneviewPanel.d.ts +19 -19
  126. package/dist/cjs/paneview/draggablePaneviewPanel.js +130 -129
  127. package/dist/cjs/paneview/draggablePaneviewPanel.js.map +1 -1
  128. package/dist/cjs/paneview/options.d.ts +27 -27
  129. package/dist/cjs/paneview/options.js +2 -2
  130. package/dist/cjs/paneview/paneview.d.ts +40 -40
  131. package/dist/cjs/paneview/paneview.js +201 -201
  132. package/dist/cjs/paneview/paneviewComponent.d.ts +129 -129
  133. package/dist/cjs/paneview/paneviewComponent.js +394 -394
  134. package/dist/cjs/paneview/paneviewComponent.js.map +1 -1
  135. package/dist/cjs/paneview/paneviewPanel.d.ts +92 -89
  136. package/dist/cjs/paneview/paneviewPanel.js +275 -274
  137. package/dist/cjs/paneview/paneviewPanel.js.map +1 -1
  138. package/dist/cjs/react/deserializer.d.ts +10 -9
  139. package/dist/cjs/react/deserializer.js +43 -43
  140. package/dist/cjs/react/deserializer.js.map +1 -1
  141. package/dist/cjs/react/dockview/defaultTab.d.ts +4 -4
  142. package/dist/cjs/react/dockview/defaultTab.js +72 -72
  143. package/dist/cjs/react/dockview/dockview.d.ts +35 -34
  144. package/dist/cjs/react/dockview/dockview.js +213 -212
  145. package/dist/cjs/react/dockview/dockview.js.map +1 -1
  146. package/dist/cjs/react/dockview/groupControlsRenderer.d.ts +43 -43
  147. package/dist/cjs/react/dockview/groupControlsRenderer.js +86 -86
  148. package/dist/cjs/react/dockview/reactContentPart.d.ts +30 -30
  149. package/dist/cjs/react/dockview/reactContentPart.js +58 -58
  150. package/dist/cjs/react/dockview/reactHeaderPart.d.ts +26 -26
  151. package/dist/cjs/react/dockview/reactHeaderPart.js +55 -55
  152. package/dist/cjs/react/dockview/reactWatermarkPart.d.ts +29 -29
  153. package/dist/cjs/react/dockview/reactWatermarkPart.js +65 -65
  154. package/dist/cjs/react/dockview/v2/reactContentRenderer.d.ts +29 -29
  155. package/dist/cjs/react/dockview/v2/reactContentRenderer.js +87 -87
  156. package/dist/cjs/react/dockview/v2/reactGroupPanelView.d.ts +7 -7
  157. package/dist/cjs/react/dockview/v2/reactGroupPanelView.js +34 -34
  158. package/dist/cjs/react/dockview/v2/webviewContentRenderer.d.ts +18 -18
  159. package/dist/cjs/react/dockview/v2/webviewContentRenderer.js +45 -45
  160. package/dist/cjs/react/gridview/gridview.d.ts +24 -24
  161. package/dist/cjs/react/gridview/gridview.js +112 -112
  162. package/dist/cjs/react/gridview/view.d.ts +11 -11
  163. package/dist/cjs/react/gridview/view.js +41 -40
  164. package/dist/cjs/react/gridview/view.js.map +1 -1
  165. package/dist/cjs/react/index.d.ts +9 -9
  166. package/dist/cjs/react/index.js +23 -23
  167. package/dist/cjs/react/paneview/paneview.d.ts +30 -30
  168. package/dist/cjs/react/paneview/paneview.js +155 -155
  169. package/dist/cjs/react/paneview/view.d.ts +20 -20
  170. package/dist/cjs/react/paneview/view.js +44 -44
  171. package/dist/cjs/react/react.d.ts +36 -36
  172. package/dist/cjs/react/react.js +194 -194
  173. package/dist/cjs/react/splitview/splitview.d.ts +24 -24
  174. package/dist/cjs/react/splitview/splitview.js +108 -108
  175. package/dist/cjs/react/splitview/view.d.ts +10 -10
  176. package/dist/cjs/react/splitview/view.js +40 -40
  177. package/dist/cjs/react/svg.d.ts +3 -3
  178. package/dist/cjs/react/svg.js +35 -35
  179. package/dist/cjs/react/types.d.ts +7 -7
  180. package/dist/cjs/react/types.js +2 -2
  181. package/dist/cjs/splitview/core/options.d.ts +26 -26
  182. package/dist/cjs/splitview/core/options.js +2 -2
  183. package/dist/cjs/splitview/core/splitview.d.ts +127 -124
  184. package/dist/cjs/splitview/core/splitview.js +908 -908
  185. package/dist/cjs/splitview/core/splitview.js.map +1 -1
  186. package/dist/cjs/splitview/core/viewItem.d.ts +25 -25
  187. package/dist/cjs/splitview/core/viewItem.js +124 -124
  188. package/dist/cjs/splitview/splitviewComponent.d.ts +101 -101
  189. package/dist/cjs/splitview/splitviewComponent.js +373 -373
  190. package/dist/cjs/splitview/splitviewComponent.js.map +1 -1
  191. package/dist/cjs/splitview/splitviewPanel.d.ts +45 -42
  192. package/dist/cjs/splitview/splitviewPanel.js +179 -178
  193. package/dist/cjs/splitview/splitviewPanel.js.map +1 -1
  194. package/dist/cjs/svg.d.ts +3 -3
  195. package/dist/cjs/svg.js +43 -43
  196. package/dist/cjs/types.d.ts +8 -7
  197. package/dist/cjs/types.js +7 -2
  198. package/dist/cjs/types.js.map +1 -1
  199. package/dist/dockview.amd.js +7168 -6739
  200. package/dist/dockview.amd.min.js +2 -2
  201. package/dist/dockview.amd.min.noStyle.js +2 -2
  202. package/dist/dockview.amd.noStyle.js +7176 -6747
  203. package/dist/dockview.cjs.js +7167 -6738
  204. package/dist/dockview.esm.js +7152 -6726
  205. package/dist/dockview.esm.min.js +2 -2
  206. package/dist/dockview.js +7168 -6739
  207. package/dist/dockview.min.js +2 -2
  208. package/dist/dockview.min.noStyle.js +2 -2
  209. package/dist/dockview.noStyle.js +7176 -6747
  210. package/dist/esm/actionbar/actionsContainer.d.ts +7 -7
  211. package/dist/esm/actionbar/actionsContainer.js +17 -17
  212. package/dist/esm/api/component.api.d.ts +145 -144
  213. package/dist/esm/api/component.api.js +329 -326
  214. package/dist/esm/api/{groupPanelApi.d.ts → dockviewPanelApi.d.ts} +34 -34
  215. package/dist/esm/api/{groupPanelApi.js → dockviewPanelApi.js} +48 -50
  216. package/dist/esm/api/gridviewPanelApi.d.ts +37 -36
  217. package/dist/esm/api/gridviewPanelApi.js +25 -25
  218. package/dist/esm/api/panelApi.d.ts +88 -81
  219. package/dist/esm/api/panelApi.js +95 -79
  220. package/dist/esm/api/paneviewPanelApi.d.ts +26 -26
  221. package/dist/esm/api/paneviewPanelApi.js +27 -27
  222. package/dist/esm/api/splitviewPanelApi.d.ts +32 -32
  223. package/dist/esm/api/splitviewPanelApi.js +25 -25
  224. package/dist/esm/array.d.ts +13 -13
  225. package/dist/esm/array.js +67 -67
  226. package/dist/esm/dnd/abstractDragHandler.d.ts +11 -11
  227. package/dist/esm/dnd/abstractDragHandler.js +37 -37
  228. package/dist/esm/dnd/dataTransfer.d.ts +31 -31
  229. package/dist/esm/dnd/dataTransfer.js +69 -69
  230. package/dist/esm/dnd/dnd.d.ts +27 -27
  231. package/dist/esm/dnd/dnd.js +36 -41
  232. package/dist/esm/dnd/droptarget.d.ts +42 -37
  233. package/dist/esm/dnd/droptarget.js +249 -167
  234. package/dist/esm/dnd/ghost.d.ts +1 -0
  235. package/dist/esm/dnd/ghost.js +10 -0
  236. package/dist/esm/dnd/groupDragHandler.d.ts +11 -0
  237. package/dist/esm/dnd/groupDragHandler.js +38 -0
  238. package/dist/esm/dockview/components/tab/defaultTab.d.ts +27 -27
  239. package/dist/esm/dockview/components/tab/defaultTab.js +79 -79
  240. package/dist/esm/dockview/components/watermark/watermark.d.ts +20 -20
  241. package/dist/esm/dockview/components/watermark/watermark.js +70 -70
  242. package/dist/esm/dockview/defaultGroupPanelView.d.ts +29 -29
  243. package/dist/esm/dockview/defaultGroupPanelView.js +44 -44
  244. package/dist/esm/dockview/deserializer.d.ts +6 -5
  245. package/dist/esm/dockview/deserializer.js +1 -1
  246. package/dist/esm/dockview/dockviewComponent.d.ts +133 -125
  247. package/dist/esm/dockview/dockviewComponent.js +632 -468
  248. package/dist/{cjs/dockview/dockviewGroupPanel.d.ts → esm/dockview/dockviewPanel.d.ts} +42 -31
  249. package/dist/esm/dockview/{dockviewGroupPanel.js → dockviewPanel.js} +111 -107
  250. package/dist/esm/dockview/options.d.ts +110 -88
  251. package/dist/esm/dockview/options.js +24 -1
  252. package/dist/esm/dockview/validation.d.ts +2 -0
  253. package/dist/esm/dockview/validation.js +86 -0
  254. package/dist/esm/dom.d.ts +14 -14
  255. package/dist/esm/dom.js +113 -113
  256. package/dist/esm/events.d.ts +30 -30
  257. package/dist/esm/events.js +88 -88
  258. package/dist/esm/gridview/baseComponentGridview.d.ts +87 -87
  259. package/dist/esm/gridview/baseComponentGridview.js +188 -189
  260. package/dist/esm/gridview/basePanelView.d.ts +43 -43
  261. package/dist/esm/gridview/basePanelView.js +74 -74
  262. package/dist/esm/gridview/branchNode.d.ts +49 -46
  263. package/dist/esm/gridview/branchNode.js +218 -218
  264. package/dist/esm/gridview/gridview.d.ts +132 -123
  265. package/dist/esm/gridview/gridview.js +423 -397
  266. package/dist/esm/gridview/gridviewComponent.d.ts +85 -85
  267. package/dist/esm/gridview/gridviewComponent.js +237 -238
  268. package/dist/esm/gridview/gridviewPanel.d.ts +60 -60
  269. package/dist/esm/gridview/gridviewPanel.js +138 -138
  270. package/dist/esm/gridview/leafNode.d.ts +34 -31
  271. package/dist/esm/gridview/leafNode.js +103 -98
  272. package/dist/esm/gridview/options.d.ts +18 -18
  273. package/dist/esm/gridview/options.js +1 -1
  274. package/dist/esm/gridview/types.d.ts +3 -3
  275. package/dist/esm/gridview/types.js +1 -1
  276. package/dist/esm/groupview/dnd.d.ts +6 -5
  277. package/dist/esm/groupview/dnd.js +7 -6
  278. package/dist/esm/groupview/groupview.d.ts +177 -177
  279. package/dist/esm/groupview/groupview.js +462 -444
  280. package/dist/esm/groupview/groupviewPanel.d.ts +35 -35
  281. package/dist/esm/groupview/groupviewPanel.js +61 -61
  282. package/dist/esm/groupview/panel/content.d.ts +30 -30
  283. package/dist/esm/groupview/panel/content.js +73 -73
  284. package/dist/esm/groupview/tab.d.ts +31 -41
  285. package/dist/esm/groupview/tab.js +94 -90
  286. package/dist/esm/groupview/titlebar/tabsContainer.d.ts +65 -68
  287. package/dist/esm/groupview/titlebar/tabsContainer.js +183 -190
  288. package/dist/esm/groupview/titlebar/voidContainer.d.ts +15 -0
  289. package/dist/esm/groupview/titlebar/voidContainer.js +47 -0
  290. package/dist/esm/groupview/types.d.ts +68 -52
  291. package/dist/esm/groupview/types.js +1 -1
  292. package/dist/esm/hostedContainer.d.ts +23 -23
  293. package/dist/esm/hostedContainer.js +63 -63
  294. package/dist/esm/index.d.ts +30 -30
  295. package/dist/esm/index.js +23 -23
  296. package/dist/esm/lifecycle.d.ts +22 -22
  297. package/dist/esm/lifecycle.js +39 -39
  298. package/dist/esm/math.d.ts +4 -4
  299. package/dist/esm/math.js +10 -10
  300. package/dist/esm/panel/componentFactory.d.ts +8 -8
  301. package/dist/esm/panel/componentFactory.js +24 -24
  302. package/dist/esm/panel/types.d.ts +33 -33
  303. package/dist/esm/panel/types.js +1 -1
  304. package/dist/esm/paneview/defaultPaneviewHeader.d.ts +21 -21
  305. package/dist/esm/paneview/defaultPaneviewHeader.js +63 -63
  306. package/dist/esm/paneview/draggablePaneviewPanel.d.ts +19 -19
  307. package/dist/esm/paneview/draggablePaneviewPanel.js +91 -90
  308. package/dist/esm/paneview/options.d.ts +27 -27
  309. package/dist/esm/paneview/options.js +1 -1
  310. package/dist/esm/paneview/paneview.d.ts +40 -40
  311. package/dist/esm/paneview/paneview.js +145 -145
  312. package/dist/esm/paneview/paneviewComponent.d.ts +129 -129
  313. package/dist/esm/paneview/paneviewComponent.js +270 -270
  314. package/dist/esm/paneview/paneviewPanel.d.ts +92 -89
  315. package/dist/esm/paneview/paneviewPanel.js +192 -191
  316. package/dist/esm/react/deserializer.d.ts +10 -9
  317. package/dist/esm/react/deserializer.js +38 -38
  318. package/dist/esm/react/dockview/defaultTab.d.ts +4 -4
  319. package/dist/esm/react/dockview/defaultTab.js +34 -34
  320. package/dist/esm/react/dockview/dockview.d.ts +35 -34
  321. package/dist/esm/react/dockview/dockview.js +158 -157
  322. package/dist/esm/react/dockview/groupControlsRenderer.d.ts +43 -43
  323. package/dist/esm/react/dockview/groupControlsRenderer.js +68 -68
  324. package/dist/esm/react/dockview/reactContentPart.d.ts +30 -30
  325. package/dist/esm/react/dockview/reactContentPart.js +49 -49
  326. package/dist/esm/react/dockview/reactHeaderPart.d.ts +26 -26
  327. package/dist/esm/react/dockview/reactHeaderPart.js +46 -46
  328. package/dist/esm/react/dockview/reactWatermarkPart.d.ts +29 -29
  329. package/dist/esm/react/dockview/reactWatermarkPart.js +55 -55
  330. package/dist/esm/react/dockview/v2/reactContentRenderer.d.ts +29 -29
  331. package/dist/esm/react/dockview/v2/reactContentRenderer.js +69 -69
  332. package/dist/esm/react/dockview/v2/reactGroupPanelView.d.ts +7 -7
  333. package/dist/esm/react/dockview/v2/reactGroupPanelView.js +12 -12
  334. package/dist/esm/react/dockview/v2/webviewContentRenderer.d.ts +18 -18
  335. package/dist/esm/react/dockview/v2/webviewContentRenderer.js +36 -36
  336. package/dist/esm/react/gridview/gridview.d.ts +24 -24
  337. package/dist/esm/react/gridview/gridview.js +70 -70
  338. package/dist/esm/react/gridview/view.d.ts +11 -11
  339. package/dist/esm/react/gridview/view.js +19 -18
  340. package/dist/esm/react/index.d.ts +9 -9
  341. package/dist/esm/react/index.js +7 -7
  342. package/dist/esm/react/paneview/paneview.d.ts +30 -30
  343. package/dist/esm/react/paneview/paneview.js +100 -100
  344. package/dist/esm/react/paneview/view.d.ts +20 -20
  345. package/dist/esm/react/paneview/view.js +35 -35
  346. package/dist/esm/react/react.d.ts +36 -36
  347. package/dist/esm/react/react.js +125 -125
  348. package/dist/esm/react/splitview/splitview.d.ts +24 -24
  349. package/dist/esm/react/splitview/splitview.js +66 -66
  350. package/dist/esm/react/splitview/view.d.ts +10 -10
  351. package/dist/esm/react/splitview/view.js +18 -18
  352. package/dist/esm/react/svg.d.ts +3 -3
  353. package/dist/esm/react/svg.js +7 -7
  354. package/dist/esm/react/types.d.ts +7 -7
  355. package/dist/esm/react/types.js +1 -1
  356. package/dist/esm/splitview/core/options.d.ts +26 -26
  357. package/dist/esm/splitview/core/options.js +1 -1
  358. package/dist/esm/splitview/core/splitview.d.ts +127 -124
  359. package/dist/esm/splitview/core/splitview.js +689 -689
  360. package/dist/esm/splitview/core/viewItem.d.ts +25 -25
  361. package/dist/esm/splitview/core/viewItem.js +79 -79
  362. package/dist/esm/splitview/splitviewComponent.d.ts +101 -101
  363. package/dist/esm/splitview/splitviewComponent.js +249 -249
  364. package/dist/esm/splitview/splitviewPanel.d.ts +45 -42
  365. package/dist/esm/splitview/splitviewPanel.js +108 -107
  366. package/dist/esm/svg.d.ts +3 -3
  367. package/dist/esm/svg.js +31 -31
  368. package/dist/esm/types.d.ts +8 -7
  369. package/dist/esm/types.js +3 -1
  370. package/dist/styles/dockview.css +23 -26
  371. package/package.json +12 -16
  372. package/dist/cjs/api/groupPanelApi.js.map +0 -1
  373. package/dist/cjs/dockview/dockviewGroupPanel.js.map +0 -1
  374. package/dist/cjs/groupview/groupPanel.d.ts +0 -32
  375. package/dist/cjs/groupview/groupPanel.js +0 -3
  376. package/dist/cjs/groupview/groupPanel.js.map +0 -1
  377. package/dist/esm/groupview/groupPanel.d.ts +0 -32
  378. package/dist/esm/groupview/groupPanel.js +0 -1
@@ -1,480 +1,511 @@
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/core/splitview");
34
- var droptarget_1 = require("../dnd/droptarget");
35
- var array_1 = require("../array");
36
- var leafNode_1 = require("./leafNode");
37
- var branchNode_1 = require("./branchNode");
38
- var events_1 = require("../events");
39
- var lifecycle_1 = require("../lifecycle");
40
- function findLeaf(candiateNode, last) {
41
- if (candiateNode instanceof leafNode_1.LeafNode) {
42
- return candiateNode;
43
- }
44
- if (candiateNode instanceof branchNode_1.BranchNode) {
45
- return findLeaf(candiateNode.children[last ? candiateNode.children.length - 1 : 0], last);
46
- }
47
- throw new Error('invalid node');
48
- }
49
- function flipNode(node, size, orthogonalSize) {
50
- if (node instanceof branchNode_1.BranchNode) {
51
- var result = new branchNode_1.BranchNode((0, exports.orthogonal)(node.orientation), node.proportionalLayout, node.styles, size, orthogonalSize);
52
- var totalSize = 0;
53
- for (var i = node.children.length - 1; i >= 0; i--) {
54
- var child = node.children[i];
55
- var childSize = child instanceof branchNode_1.BranchNode ? child.orthogonalSize : child.size;
56
- var newSize = node.size === 0
57
- ? 0
58
- : Math.round((size * childSize) / node.size);
59
- totalSize += newSize;
60
- // The last view to add should adjust to rounding errors
61
- if (i === 0) {
62
- newSize += size - totalSize;
63
- }
64
- result.addChild(flipNode(child, orthogonalSize, newSize), newSize, 0, true);
65
- }
66
- return result;
67
- }
68
- else {
69
- return new leafNode_1.LeafNode(node.view, (0, exports.orthogonal)(node.orientation), orthogonalSize);
70
- }
71
- }
72
- function indexInParent(element) {
73
- var parentElement = element.parentElement;
74
- if (!parentElement) {
75
- throw new Error('Invalid grid element');
76
- }
77
- var el = parentElement.firstElementChild;
78
- var index = 0;
79
- while (el !== element && el !== parentElement.lastElementChild && el) {
80
- el = el.nextElementSibling;
81
- index++;
82
- }
83
- return index;
84
- }
85
- exports.indexInParent = indexInParent;
86
- /**
87
- * Find the grid location of a specific DOM element by traversing the parent
88
- * chain and finding each child index on the way.
89
- *
90
- * This will break as soon as DOM structures of the Splitview or Gridview change.
91
- */
92
- function getGridLocation(element) {
93
- var parentElement = element.parentElement;
94
- if (!parentElement) {
95
- throw new Error('Invalid grid element');
96
- }
97
- if (/\bgrid-view\b/.test(parentElement.className)) {
98
- return [];
99
- }
100
- var index = indexInParent(parentElement);
101
- var ancestor = parentElement.parentElement.parentElement.parentElement;
102
- return __spreadArray(__spreadArray([], __read(getGridLocation(ancestor)), false), [index], false);
103
- }
104
- exports.getGridLocation = getGridLocation;
105
- function getRelativeLocation(rootOrientation, location, direction) {
106
- var orientation = getLocationOrientation(rootOrientation, location);
107
- var directionOrientation = getDirectionOrientation(direction);
108
- if (orientation === directionOrientation) {
109
- var _a = __read((0, array_1.tail)(location), 2), rest = _a[0], _index = _a[1];
110
- var index = _index;
111
- if (direction === droptarget_1.Position.Right || direction === droptarget_1.Position.Bottom) {
112
- index += 1;
113
- }
114
- return __spreadArray(__spreadArray([], __read(rest), false), [index], false);
115
- }
116
- else {
117
- var index = direction === droptarget_1.Position.Right || direction === droptarget_1.Position.Bottom
118
- ? 1
119
- : 0;
120
- return __spreadArray(__spreadArray([], __read(location), false), [index], false);
121
- }
122
- }
123
- exports.getRelativeLocation = getRelativeLocation;
124
- function getDirectionOrientation(direction) {
125
- return direction === droptarget_1.Position.Top || direction === droptarget_1.Position.Bottom
126
- ? splitview_1.Orientation.VERTICAL
127
- : splitview_1.Orientation.HORIZONTAL;
128
- }
129
- exports.getDirectionOrientation = getDirectionOrientation;
130
- function getLocationOrientation(rootOrientation, location) {
131
- return location.length % 2 === 0
132
- ? (0, exports.orthogonal)(rootOrientation)
133
- : rootOrientation;
134
- }
135
- exports.getLocationOrientation = getLocationOrientation;
136
- var orthogonal = function (orientation) {
137
- return orientation === splitview_1.Orientation.HORIZONTAL
138
- ? splitview_1.Orientation.VERTICAL
139
- : splitview_1.Orientation.HORIZONTAL;
140
- };
141
- exports.orthogonal = orthogonal;
142
- function isGridBranchNode(node) {
143
- return !!node.children;
144
- }
145
- exports.isGridBranchNode = isGridBranchNode;
146
- var serializeBranchNode = function (node, orientation) {
147
- var size = orientation === splitview_1.Orientation.VERTICAL ? node.box.width : node.box.height;
148
- if (!isGridBranchNode(node)) {
149
- if (typeof node.cachedVisibleSize === 'number') {
150
- return {
151
- type: 'leaf',
152
- data: node.view.toJSON(),
153
- size: node.cachedVisibleSize,
154
- visible: false,
155
- };
156
- }
157
- return { type: 'leaf', data: node.view.toJSON(), size: size };
158
- }
159
- return {
160
- type: 'branch',
161
- data: node.children.map(function (c) {
162
- return serializeBranchNode(c, (0, exports.orthogonal)(orientation));
163
- }),
164
- size: size,
165
- };
166
- };
167
- var Gridview = /** @class */ (function () {
168
- function Gridview(proportionalLayout, styles, orientation) {
169
- this.proportionalLayout = proportionalLayout;
170
- this.styles = styles;
171
- this.disposable = new lifecycle_1.MutableDisposable();
172
- this._onDidChange = new events_1.Emitter();
173
- this.onDidChange = this._onDidChange.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
- Gridview.prototype.serialize = function () {
179
- var root = serializeBranchNode(this.getView(), this.orientation);
180
- return {
181
- root: root,
182
- width: this.width,
183
- height: this.height,
184
- orientation: this.orientation,
185
- };
186
- };
187
- Gridview.prototype.dispose = function () {
188
- this.disposable.dispose();
189
- this._onDidChange.dispose();
190
- this.root.dispose();
191
- this.element.remove();
192
- };
193
- Gridview.prototype.clear = function () {
194
- var orientation = this.root.orientation;
195
- this.root = new branchNode_1.BranchNode(orientation, this.proportionalLayout, this.styles, this.root.size, this.root.orthogonalSize);
196
- };
197
- Gridview.prototype.deserialize = function (json, deserializer) {
198
- var orientation = json.orientation;
199
- var height = orientation === splitview_1.Orientation.VERTICAL ? json.height : json.width;
200
- this._deserialize(json.root, orientation, deserializer, height);
201
- };
202
- Gridview.prototype._deserialize = function (root, orientation, deserializer, orthogonalSize) {
203
- this.root = this._deserializeNode(root, orientation, deserializer, orthogonalSize, true);
204
- };
205
- Gridview.prototype._deserializeNode = function (node, orientation, deserializer, orthogonalSize, isRoot) {
206
- var _this = this;
207
- if (isRoot === void 0) { isRoot = false; }
208
- var result;
209
- if (node.type === 'branch') {
210
- var serializedChildren = node.data;
211
- var children = serializedChildren.map(function (serializedChild) {
212
- return {
213
- node: _this._deserializeNode(serializedChild, (0, exports.orthogonal)(orientation), deserializer, node.size),
214
- visible: serializedChild.visible,
215
- };
216
- });
217
- // HORIZONTAL => height=orthogonalsize width=size
218
- // VERTICAL => height=size width=orthogonalsize
219
- result = new branchNode_1.BranchNode(orientation, this.proportionalLayout, this.styles, isRoot ? orthogonalSize : node.size, isRoot ? node.size : orthogonalSize, children);
220
- }
221
- else {
222
- result = new leafNode_1.LeafNode(deserializer.fromJSON(node), orientation, orthogonalSize, node.size);
223
- }
224
- return result;
225
- };
226
- Object.defineProperty(Gridview.prototype, "orientation", {
227
- get: function () {
228
- return this.root.orientation;
229
- },
230
- set: function (orientation) {
231
- if (this.root.orientation === orientation) {
232
- return;
233
- }
234
- var _a = this.root, size = _a.size, orthogonalSize = _a.orthogonalSize;
235
- this.root = flipNode(this.root, orthogonalSize, size);
236
- this.root.layout(size, orthogonalSize);
237
- },
238
- enumerable: false,
239
- configurable: true
240
- });
241
- Object.defineProperty(Gridview.prototype, "root", {
242
- get: function () {
243
- return this._root;
244
- },
245
- set: function (root) {
246
- var _this = this;
247
- var oldRoot = this._root;
248
- if (oldRoot) {
249
- oldRoot.dispose();
250
- this.element.removeChild(oldRoot.element);
251
- }
252
- this._root = root;
253
- this.element.appendChild(this._root.element);
254
- this.disposable.value = this._root.onDidChange(function (e) {
255
- _this._onDidChange.fire(e);
256
- });
257
- },
258
- enumerable: false,
259
- configurable: true
260
- });
261
- Gridview.prototype.next = function (location) {
262
- return this.progmaticSelect(location);
263
- };
264
- Gridview.prototype.previous = function (location) {
265
- return this.progmaticSelect(location, true);
266
- };
267
- Gridview.prototype.getView = function (location) {
268
- var node = location ? this.getNode(location)[1] : this.root;
269
- return this._getViews(node, this.orientation);
270
- };
271
- Gridview.prototype._getViews = function (node, orientation, cachedVisibleSize) {
272
- var box = { height: node.height, width: node.width };
273
- if (node instanceof leafNode_1.LeafNode) {
274
- return { box: box, view: node.view, cachedVisibleSize: cachedVisibleSize };
275
- }
276
- var children = [];
277
- for (var i = 0; i < node.children.length; i++) {
278
- var child = node.children[i];
279
- var nodeCachedVisibleSize = node.getChildCachedVisibleSize(i);
280
- children.push(this._getViews(child, (0, exports.orthogonal)(orientation), nodeCachedVisibleSize));
281
- }
282
- return { box: box, children: children };
283
- };
284
- Gridview.prototype.progmaticSelect = function (location, reverse) {
285
- if (reverse === void 0) { reverse = false; }
286
- var _a = __read(this.getNode(location), 2), path = _a[0], node = _a[1];
287
- if (!(node instanceof leafNode_1.LeafNode)) {
288
- throw new Error('invalid location');
289
- }
290
- for (var i = path.length - 1; i > -1; i--) {
291
- var n = path[i];
292
- var l = location[i] || 0;
293
- var canProgressInCurrentLevel = reverse
294
- ? l - 1 > -1
295
- : l + 1 < n.children.length;
296
- if (canProgressInCurrentLevel) {
297
- return findLeaf(n.children[reverse ? l - 1 : l + 1], reverse);
298
- }
299
- }
300
- return findLeaf(this.root, reverse);
301
- };
302
- Object.defineProperty(Gridview.prototype, "width", {
303
- get: function () {
304
- return this.root.width;
305
- },
306
- enumerable: false,
307
- configurable: true
308
- });
309
- Object.defineProperty(Gridview.prototype, "height", {
310
- get: function () {
311
- return this.root.height;
312
- },
313
- enumerable: false,
314
- configurable: true
315
- });
316
- Object.defineProperty(Gridview.prototype, "minimumWidth", {
317
- get: function () {
318
- return this.root.minimumWidth;
319
- },
320
- enumerable: false,
321
- configurable: true
322
- });
323
- Object.defineProperty(Gridview.prototype, "minimumHeight", {
324
- get: function () {
325
- return this.root.minimumHeight;
326
- },
327
- enumerable: false,
328
- configurable: true
329
- });
330
- Object.defineProperty(Gridview.prototype, "maximumWidth", {
331
- get: function () {
332
- return this.root.maximumHeight;
333
- },
334
- enumerable: false,
335
- configurable: true
336
- });
337
- Object.defineProperty(Gridview.prototype, "maximumHeight", {
338
- get: function () {
339
- return this.root.maximumHeight;
340
- },
341
- enumerable: false,
342
- configurable: true
343
- });
344
- Gridview.prototype.isViewVisible = function (location) {
345
- var _a = __read((0, array_1.tail)(location), 2), rest = _a[0], index = _a[1];
346
- var _b = __read(this.getNode(rest), 2), parent = _b[1];
347
- if (!(parent instanceof branchNode_1.BranchNode)) {
348
- throw new Error('Invalid from location');
349
- }
350
- return parent.isChildVisible(index);
351
- };
352
- Gridview.prototype.setViewVisible = function (location, visible) {
353
- var _a = __read((0, array_1.tail)(location), 2), rest = _a[0], index = _a[1];
354
- var _b = __read(this.getNode(rest), 2), parent = _b[1];
355
- if (!(parent instanceof branchNode_1.BranchNode)) {
356
- throw new Error('Invalid from location');
357
- }
358
- parent.setChildVisible(index, visible);
359
- };
360
- Gridview.prototype.moveView = function (parentLocation, from, to) {
361
- var _a = __read(this.getNode(parentLocation), 2), parent = _a[1];
362
- if (!(parent instanceof branchNode_1.BranchNode)) {
363
- throw new Error('Invalid location');
364
- }
365
- parent.moveChild(from, to);
366
- };
367
- Gridview.prototype.addView = function (view, size, location) {
368
- var _a = __read((0, array_1.tail)(location), 2), rest = _a[0], index = _a[1];
369
- var _b = __read(this.getNode(rest), 2), pathToParent = _b[0], parent = _b[1];
370
- if (parent instanceof branchNode_1.BranchNode) {
371
- var node = new leafNode_1.LeafNode(view, (0, exports.orthogonal)(parent.orientation), parent.orthogonalSize);
372
- parent.addChild(node, size, index);
373
- }
374
- else {
375
- var _c = __read(__spreadArray([], __read(pathToParent), false).reverse()), grandParent = _c[0], _1 = _c.slice(1);
376
- var _d = __read(__spreadArray([], __read(rest), false).reverse()), parentIndex = _d[0], __ = _d.slice(1);
377
- var newSiblingSize = 0;
378
- var newSiblingCachedVisibleSize = grandParent.getChildCachedVisibleSize(parentIndex);
379
- if (typeof newSiblingCachedVisibleSize === 'number') {
380
- newSiblingSize = splitview_1.Sizing.Invisible(newSiblingCachedVisibleSize);
381
- }
382
- grandParent.removeChild(parentIndex);
383
- var newParent = new branchNode_1.BranchNode(parent.orientation, this.proportionalLayout, this.styles, parent.size, parent.orthogonalSize);
384
- grandParent.addChild(newParent, parent.size, parentIndex);
385
- var newSibling = new leafNode_1.LeafNode(parent.view, grandParent.orientation, parent.size);
386
- newParent.addChild(newSibling, newSiblingSize, 0);
387
- if (typeof size !== 'number' && size.type === 'split') {
388
- size = { type: 'split', index: 0 };
389
- }
390
- var node = new leafNode_1.LeafNode(view, grandParent.orientation, parent.size);
391
- newParent.addChild(node, size, index);
392
- }
393
- };
394
- Gridview.prototype.remove = function (view, sizing) {
395
- var location = getGridLocation(view.element);
396
- return this.removeView(location, sizing);
397
- };
398
- Gridview.prototype.removeView = function (location, sizing) {
399
- var _a = __read((0, array_1.tail)(location), 2), rest = _a[0], index = _a[1];
400
- var _b = __read(this.getNode(rest), 2), pathToParent = _b[0], parent = _b[1];
401
- if (!(parent instanceof branchNode_1.BranchNode)) {
402
- throw new Error('Invalid location');
403
- }
404
- var node = parent.children[index];
405
- if (!(node instanceof leafNode_1.LeafNode)) {
406
- throw new Error('Invalid location');
407
- }
408
- parent.removeChild(index, sizing);
409
- if (parent.children.length === 0) {
410
- return node.view;
411
- }
412
- if (parent.children.length > 1) {
413
- return node.view;
414
- }
415
- var sibling = parent.children[0];
416
- if (pathToParent.length === 0) {
417
- // parent is root
418
- if (sibling instanceof leafNode_1.LeafNode) {
419
- return node.view;
420
- }
421
- // we must promote sibling to be the new root
422
- parent.removeChild(0, sizing);
423
- this.root = sibling;
424
- return node.view;
425
- }
426
- var _c = __read(__spreadArray([], __read(pathToParent), false).reverse()), grandParent = _c[0], _ = _c.slice(1);
427
- var _d = __read(__spreadArray([], __read(rest), false).reverse()), parentIndex = _d[0], __ = _d.slice(1);
428
- var isSiblingVisible = parent.isChildVisible(0);
429
- parent.removeChild(0, sizing);
430
- var sizes = grandParent.children.map(function (_size, i) {
431
- return grandParent.getChildSize(i);
432
- });
433
- grandParent.removeChild(parentIndex, sizing);
434
- if (sibling instanceof branchNode_1.BranchNode) {
435
- sizes.splice.apply(sizes, __spreadArray([parentIndex,
436
- 1], __read(sibling.children.map(function (c) { return c.size; })), false));
437
- for (var i = 0; i < sibling.children.length; i++) {
438
- var child = sibling.children[i];
439
- grandParent.addChild(child, child.size, parentIndex + i);
440
- }
441
- }
442
- else {
443
- var newSibling = new leafNode_1.LeafNode(sibling.view, (0, exports.orthogonal)(sibling.orientation), sibling.size);
444
- var siblingSizing = isSiblingVisible
445
- ? sibling.orthogonalSize
446
- : splitview_1.Sizing.Invisible(sibling.orthogonalSize);
447
- grandParent.addChild(newSibling, siblingSizing, parentIndex);
448
- }
449
- for (var i = 0; i < sizes.length; i++) {
450
- grandParent.resizeChild(i, sizes[i]);
451
- }
452
- return node.view;
453
- };
454
- Gridview.prototype.layout = function (width, height) {
455
- var _a = __read(this.root.orientation === splitview_1.Orientation.HORIZONTAL
456
- ? [height, width]
457
- : [width, height], 2), size = _a[0], orthogonalSize = _a[1];
458
- this.root.layout(size, orthogonalSize);
459
- };
460
- Gridview.prototype.getNode = function (location, node, path) {
461
- if (node === void 0) { node = this.root; }
462
- if (path === void 0) { path = []; }
463
- if (location.length === 0) {
464
- return [path, node];
465
- }
466
- if (!(node instanceof branchNode_1.BranchNode)) {
467
- throw new Error('Invalid location');
468
- }
469
- var _a = __read(location), index = _a[0], rest = _a.slice(1);
470
- if (index < 0 || index >= node.children.length) {
471
- throw new Error('Invalid location');
472
- }
473
- var child = node.children[index];
474
- path.push(node);
475
- return this.getNode(rest, child, path);
476
- };
477
- return Gridview;
478
- }());
479
- 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/core/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
+ Gridview.prototype.serialize = function () {
183
+ var root = serializeBranchNode(this.getView(), this.orientation);
184
+ return {
185
+ root: root,
186
+ width: this.width,
187
+ height: this.height,
188
+ orientation: this.orientation,
189
+ };
190
+ };
191
+ Gridview.prototype.dispose = function () {
192
+ this.disposable.dispose();
193
+ this._onDidChange.dispose();
194
+ this.root.dispose();
195
+ this.element.remove();
196
+ };
197
+ Gridview.prototype.clear = function () {
198
+ var orientation = this.root.orientation;
199
+ this.root = new branchNode_1.BranchNode(orientation, this.proportionalLayout, this.styles, this.root.size, this.root.orthogonalSize);
200
+ };
201
+ Gridview.prototype.deserialize = function (json, deserializer) {
202
+ var orientation = json.orientation;
203
+ var height = orientation === splitview_1.Orientation.VERTICAL ? json.height : json.width;
204
+ this._deserialize(json.root, orientation, deserializer, height);
205
+ };
206
+ Gridview.prototype._deserialize = function (root, orientation, deserializer, orthogonalSize) {
207
+ this.root = this._deserializeNode(root, orientation, deserializer, orthogonalSize, true);
208
+ };
209
+ Gridview.prototype._deserializeNode = function (node, orientation, deserializer, orthogonalSize, isRoot) {
210
+ var _this = this;
211
+ if (isRoot === void 0) { isRoot = false; }
212
+ var result;
213
+ if (node.type === 'branch') {
214
+ var serializedChildren = node.data;
215
+ var children = serializedChildren.map(function (serializedChild) {
216
+ return {
217
+ node: _this._deserializeNode(serializedChild, (0, exports.orthogonal)(orientation), deserializer, node.size),
218
+ visible: serializedChild.visible,
219
+ };
220
+ });
221
+ // HORIZONTAL => height=orthogonalsize width=size
222
+ // VERTICAL => height=size width=orthogonalsize
223
+ result = new branchNode_1.BranchNode(orientation, this.proportionalLayout, this.styles, isRoot ? orthogonalSize : node.size, isRoot ? node.size : orthogonalSize, children);
224
+ }
225
+ else {
226
+ result = new leafNode_1.LeafNode(deserializer.fromJSON(node), orientation, orthogonalSize, node.size);
227
+ }
228
+ return result;
229
+ };
230
+ Object.defineProperty(Gridview.prototype, "orientation", {
231
+ get: function () {
232
+ return this.root.orientation;
233
+ },
234
+ set: function (orientation) {
235
+ if (this.root.orientation === orientation) {
236
+ return;
237
+ }
238
+ var _a = this.root, size = _a.size, orthogonalSize = _a.orthogonalSize;
239
+ this.root = flipNode(this.root, orthogonalSize, size);
240
+ this.root.layout(size, orthogonalSize);
241
+ },
242
+ enumerable: false,
243
+ configurable: true
244
+ });
245
+ Object.defineProperty(Gridview.prototype, "root", {
246
+ get: function () {
247
+ return this._root;
248
+ },
249
+ set: function (root) {
250
+ var _this = this;
251
+ var oldRoot = this._root;
252
+ if (oldRoot) {
253
+ oldRoot.dispose();
254
+ this.element.removeChild(oldRoot.element);
255
+ }
256
+ this._root = root;
257
+ this.element.appendChild(this._root.element);
258
+ this.disposable.value = this._root.onDidChange(function (e) {
259
+ _this._onDidChange.fire(e);
260
+ });
261
+ },
262
+ enumerable: false,
263
+ configurable: true
264
+ });
265
+ /**
266
+ * If the root is orientated as a VERTICAL node then nest the existing root within a new HORIZIONTAL root node
267
+ * If the root is orientated as a HORIZONTAL node then nest the existing root within a new VERITCAL root node
268
+ */
269
+ Gridview.prototype.insertOrthogonalSplitviewAtRoot = function () {
270
+ var _this = this;
271
+ if (!this._root) {
272
+ return;
273
+ }
274
+ var oldRoot = this.root;
275
+ oldRoot.element.remove();
276
+ this._root = new branchNode_1.BranchNode((0, exports.orthogonal)(oldRoot.orientation), this.proportionalLayout, this.styles, this.root.orthogonalSize, this.root.size);
277
+ if (oldRoot.children.length === 1) {
278
+ // can remove one level of redundant branching if there is only a single child
279
+ var childReference = oldRoot.children[0];
280
+ oldRoot.removeChild(0); // remove to prevent disposal when disposing of unwanted root
281
+ oldRoot.dispose();
282
+ this._root.addChild(childReference, splitview_1.Sizing.Distribute, 0);
283
+ }
284
+ else {
285
+ this._root.addChild(oldRoot, splitview_1.Sizing.Distribute, 0);
286
+ }
287
+ this.element.appendChild(this._root.element);
288
+ this.disposable.value = this._root.onDidChange(function (e) {
289
+ _this._onDidChange.fire(e);
290
+ });
291
+ };
292
+ Gridview.prototype.next = function (location) {
293
+ return this.progmaticSelect(location);
294
+ };
295
+ Gridview.prototype.previous = function (location) {
296
+ return this.progmaticSelect(location, true);
297
+ };
298
+ Gridview.prototype.getView = function (location) {
299
+ var node = location ? this.getNode(location)[1] : this.root;
300
+ return this._getViews(node, this.orientation);
301
+ };
302
+ Gridview.prototype._getViews = function (node, orientation, cachedVisibleSize) {
303
+ var box = { height: node.height, width: node.width };
304
+ if (node instanceof leafNode_1.LeafNode) {
305
+ return { box: box, view: node.view, cachedVisibleSize: cachedVisibleSize };
306
+ }
307
+ var children = [];
308
+ for (var i = 0; i < node.children.length; i++) {
309
+ var child = node.children[i];
310
+ var nodeCachedVisibleSize = node.getChildCachedVisibleSize(i);
311
+ children.push(this._getViews(child, (0, exports.orthogonal)(orientation), nodeCachedVisibleSize));
312
+ }
313
+ return { box: box, children: children };
314
+ };
315
+ Gridview.prototype.progmaticSelect = function (location, reverse) {
316
+ if (reverse === void 0) { reverse = false; }
317
+ var _a = __read(this.getNode(location), 2), path = _a[0], node = _a[1];
318
+ if (!(node instanceof leafNode_1.LeafNode)) {
319
+ throw new Error('invalid location');
320
+ }
321
+ for (var i = path.length - 1; i > -1; i--) {
322
+ var n = path[i];
323
+ var l = location[i] || 0;
324
+ var canProgressInCurrentLevel = reverse
325
+ ? l - 1 > -1
326
+ : l + 1 < n.children.length;
327
+ if (canProgressInCurrentLevel) {
328
+ return findLeaf(n.children[reverse ? l - 1 : l + 1], reverse);
329
+ }
330
+ }
331
+ return findLeaf(this.root, reverse);
332
+ };
333
+ Object.defineProperty(Gridview.prototype, "width", {
334
+ get: function () {
335
+ return this.root.width;
336
+ },
337
+ enumerable: false,
338
+ configurable: true
339
+ });
340
+ Object.defineProperty(Gridview.prototype, "height", {
341
+ get: function () {
342
+ return this.root.height;
343
+ },
344
+ enumerable: false,
345
+ configurable: true
346
+ });
347
+ Object.defineProperty(Gridview.prototype, "minimumWidth", {
348
+ get: function () {
349
+ return this.root.minimumWidth;
350
+ },
351
+ enumerable: false,
352
+ configurable: true
353
+ });
354
+ Object.defineProperty(Gridview.prototype, "minimumHeight", {
355
+ get: function () {
356
+ return this.root.minimumHeight;
357
+ },
358
+ enumerable: false,
359
+ configurable: true
360
+ });
361
+ Object.defineProperty(Gridview.prototype, "maximumWidth", {
362
+ get: function () {
363
+ return this.root.maximumHeight;
364
+ },
365
+ enumerable: false,
366
+ configurable: true
367
+ });
368
+ Object.defineProperty(Gridview.prototype, "maximumHeight", {
369
+ get: function () {
370
+ return this.root.maximumHeight;
371
+ },
372
+ enumerable: false,
373
+ configurable: true
374
+ });
375
+ Gridview.prototype.isViewVisible = function (location) {
376
+ var _a = __read((0, array_1.tail)(location), 2), rest = _a[0], index = _a[1];
377
+ var _b = __read(this.getNode(rest), 2), parent = _b[1];
378
+ if (!(parent instanceof branchNode_1.BranchNode)) {
379
+ throw new Error('Invalid from location');
380
+ }
381
+ return parent.isChildVisible(index);
382
+ };
383
+ Gridview.prototype.setViewVisible = function (location, visible) {
384
+ var _a = __read((0, array_1.tail)(location), 2), rest = _a[0], index = _a[1];
385
+ var _b = __read(this.getNode(rest), 2), parent = _b[1];
386
+ if (!(parent instanceof branchNode_1.BranchNode)) {
387
+ throw new Error('Invalid from location');
388
+ }
389
+ parent.setChildVisible(index, visible);
390
+ };
391
+ Gridview.prototype.moveView = function (parentLocation, from, to) {
392
+ var _a = __read(this.getNode(parentLocation), 2), parent = _a[1];
393
+ if (!(parent instanceof branchNode_1.BranchNode)) {
394
+ throw new Error('Invalid location');
395
+ }
396
+ parent.moveChild(from, to);
397
+ };
398
+ Gridview.prototype.addView = function (view, size, location) {
399
+ var _a = __read((0, array_1.tail)(location), 2), rest = _a[0], index = _a[1];
400
+ var _b = __read(this.getNode(rest), 2), pathToParent = _b[0], parent = _b[1];
401
+ if (parent instanceof branchNode_1.BranchNode) {
402
+ var node = new leafNode_1.LeafNode(view, (0, exports.orthogonal)(parent.orientation), parent.orthogonalSize);
403
+ parent.addChild(node, size, index);
404
+ }
405
+ else {
406
+ var _c = __read(__spreadArray([], __read(pathToParent), false).reverse()), grandParent = _c[0], _ = _c.slice(1);
407
+ var _d = __read(__spreadArray([], __read(rest), false).reverse()), parentIndex = _d[0], __ = _d.slice(1);
408
+ var newSiblingSize = 0;
409
+ var newSiblingCachedVisibleSize = grandParent.getChildCachedVisibleSize(parentIndex);
410
+ if (typeof newSiblingCachedVisibleSize === 'number') {
411
+ newSiblingSize = splitview_1.Sizing.Invisible(newSiblingCachedVisibleSize);
412
+ }
413
+ grandParent.removeChild(parentIndex);
414
+ var newParent = new branchNode_1.BranchNode(parent.orientation, this.proportionalLayout, this.styles, parent.size, parent.orthogonalSize);
415
+ grandParent.addChild(newParent, parent.size, parentIndex);
416
+ var newSibling = new leafNode_1.LeafNode(parent.view, grandParent.orientation, parent.size);
417
+ newParent.addChild(newSibling, newSiblingSize, 0);
418
+ if (typeof size !== 'number' && size.type === 'split') {
419
+ size = { type: 'split', index: 0 };
420
+ }
421
+ var node = new leafNode_1.LeafNode(view, grandParent.orientation, parent.size);
422
+ newParent.addChild(node, size, index);
423
+ }
424
+ };
425
+ Gridview.prototype.remove = function (view, sizing) {
426
+ var location = getGridLocation(view.element);
427
+ return this.removeView(location, sizing);
428
+ };
429
+ Gridview.prototype.removeView = function (location, sizing) {
430
+ var _a = __read((0, array_1.tail)(location), 2), rest = _a[0], index = _a[1];
431
+ var _b = __read(this.getNode(rest), 2), pathToParent = _b[0], parent = _b[1];
432
+ if (!(parent instanceof branchNode_1.BranchNode)) {
433
+ throw new Error('Invalid location');
434
+ }
435
+ var node = parent.children[index];
436
+ if (!(node instanceof leafNode_1.LeafNode)) {
437
+ throw new Error('Invalid location');
438
+ }
439
+ parent.removeChild(index, sizing);
440
+ if (parent.children.length === 0) {
441
+ return node.view;
442
+ }
443
+ if (parent.children.length > 1) {
444
+ return node.view;
445
+ }
446
+ var sibling = parent.children[0];
447
+ if (pathToParent.length === 0) {
448
+ // parent is root
449
+ if (sibling instanceof leafNode_1.LeafNode) {
450
+ return node.view;
451
+ }
452
+ // we must promote sibling to be the new root
453
+ parent.removeChild(0, sizing);
454
+ this.root = sibling;
455
+ return node.view;
456
+ }
457
+ var _c = __read(__spreadArray([], __read(pathToParent), false).reverse()), grandParent = _c[0], _ = _c.slice(1);
458
+ var _d = __read(__spreadArray([], __read(rest), false).reverse()), parentIndex = _d[0], __ = _d.slice(1);
459
+ var isSiblingVisible = parent.isChildVisible(0);
460
+ parent.removeChild(0, sizing);
461
+ var sizes = grandParent.children.map(function (_size, i) {
462
+ return grandParent.getChildSize(i);
463
+ });
464
+ grandParent.removeChild(parentIndex, sizing);
465
+ if (sibling instanceof branchNode_1.BranchNode) {
466
+ sizes.splice.apply(sizes, __spreadArray([parentIndex,
467
+ 1], __read(sibling.children.map(function (c) { return c.size; })), false));
468
+ for (var i = 0; i < sibling.children.length; i++) {
469
+ var child = sibling.children[i];
470
+ grandParent.addChild(child, child.size, parentIndex + i);
471
+ }
472
+ }
473
+ else {
474
+ var newSibling = new leafNode_1.LeafNode(sibling.view, (0, exports.orthogonal)(sibling.orientation), sibling.size);
475
+ var siblingSizing = isSiblingVisible
476
+ ? sibling.orthogonalSize
477
+ : splitview_1.Sizing.Invisible(sibling.orthogonalSize);
478
+ grandParent.addChild(newSibling, siblingSizing, parentIndex);
479
+ }
480
+ for (var i = 0; i < sizes.length; i++) {
481
+ grandParent.resizeChild(i, sizes[i]);
482
+ }
483
+ return node.view;
484
+ };
485
+ Gridview.prototype.layout = function (width, height) {
486
+ var _a = __read(this.root.orientation === splitview_1.Orientation.HORIZONTAL
487
+ ? [height, width]
488
+ : [width, height], 2), size = _a[0], orthogonalSize = _a[1];
489
+ this.root.layout(size, orthogonalSize);
490
+ };
491
+ Gridview.prototype.getNode = function (location, node, path) {
492
+ if (node === void 0) { node = this.root; }
493
+ if (path === void 0) { path = []; }
494
+ if (location.length === 0) {
495
+ return [path, node];
496
+ }
497
+ if (!(node instanceof branchNode_1.BranchNode)) {
498
+ throw new Error('Invalid location');
499
+ }
500
+ var _a = __read(location), index = _a[0], rest = _a.slice(1);
501
+ if (index < 0 || index >= node.children.length) {
502
+ throw new Error('Invalid location');
503
+ }
504
+ var child = node.children[index];
505
+ path.push(node);
506
+ return this.getNode(rest, child, path);
507
+ };
508
+ return Gridview;
509
+ }());
510
+ exports.Gridview = Gridview;
480
511
  //# sourceMappingURL=gridview.js.map