dockview-core 1.8.4 → 1.8.5

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