dockview-core 1.6.0

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