dockview 0.0.28 → 1.0.2

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