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.
- package/README.md +51 -51
- package/dist/cjs/api/component.api.d.ts +455 -152
- package/dist/cjs/api/component.api.d.ts.map +1 -1
- package/dist/cjs/api/component.api.js +895 -592
- package/dist/cjs/api/component.api.js.map +1 -1
- package/dist/cjs/api/dockviewGroupPanelApi.d.ts +29 -29
- package/dist/cjs/api/dockviewGroupPanelApi.js +53 -53
- package/dist/cjs/api/dockviewPanelApi.d.ts +47 -47
- package/dist/cjs/api/dockviewPanelApi.js +88 -88
- package/dist/cjs/api/gridviewPanelApi.d.ts +37 -37
- package/dist/cjs/api/gridviewPanelApi.js +47 -47
- package/dist/cjs/api/panelApi.d.ts +88 -88
- package/dist/cjs/api/panelApi.js +135 -135
- package/dist/cjs/api/paneviewPanelApi.d.ts +26 -26
- package/dist/cjs/api/paneviewPanelApi.js +57 -57
- package/dist/cjs/api/splitviewPanelApi.d.ts +32 -32
- package/dist/cjs/api/splitviewPanelApi.js +47 -47
- package/dist/cjs/array.d.ts +13 -13
- package/dist/cjs/array.js +67 -67
- package/dist/cjs/dnd/abstractDragHandler.d.ts +12 -12
- package/dist/cjs/dnd/abstractDragHandler.js +141 -141
- package/dist/cjs/dnd/dataTransfer.d.ts +30 -31
- package/dist/cjs/dnd/dataTransfer.d.ts.map +1 -1
- package/dist/cjs/dnd/dataTransfer.js +99 -100
- package/dist/cjs/dnd/dataTransfer.js.map +1 -1
- package/dist/cjs/dnd/dnd.d.ts +27 -27
- package/dist/cjs/dnd/dnd.js +59 -59
- package/dist/cjs/dnd/droptarget.d.ts +53 -53
- package/dist/cjs/dnd/droptarget.js +304 -304
- package/dist/cjs/dnd/droptarget.js.map +1 -1
- package/dist/cjs/dnd/ghost.d.ts +1 -1
- package/dist/cjs/dnd/ghost.js +15 -15
- package/dist/cjs/dnd/groupDragHandler.d.ts +12 -12
- package/dist/cjs/dnd/groupDragHandler.js +77 -77
- package/dist/cjs/dnd/overlay.d.ts +43 -43
- package/dist/cjs/dnd/overlay.d.ts.map +1 -1
- package/dist/cjs/dnd/overlay.js +412 -412
- package/dist/cjs/dnd/overlay.js.map +1 -1
- package/dist/cjs/dockview/components/panel/content.d.ts +30 -30
- package/dist/cjs/dockview/components/panel/content.js +100 -100
- package/dist/cjs/dockview/components/tab/defaultTab.d.ts +21 -21
- package/dist/cjs/dockview/components/tab/defaultTab.js +105 -105
- package/dist/cjs/dockview/components/tab/tab.d.ts +34 -34
- package/dist/cjs/dockview/components/tab/tab.js +120 -120
- package/dist/cjs/dockview/components/titlebar/tabsContainer.d.ts +81 -81
- package/dist/cjs/dockview/components/titlebar/tabsContainer.js +325 -325
- package/dist/cjs/dockview/components/titlebar/voidContainer.d.ts +17 -17
- package/dist/cjs/dockview/components/titlebar/voidContainer.js +77 -77
- package/dist/cjs/dockview/components/watermark/watermark.d.ts +18 -18
- package/dist/cjs/dockview/components/watermark/watermark.js +87 -87
- package/dist/cjs/dockview/deserializer.d.ts +12 -12
- package/dist/cjs/dockview/deserializer.js +33 -33
- package/dist/cjs/dockview/deserializer.js.map +1 -1
- package/dist/cjs/dockview/dockviewComponent.d.ts +159 -159
- package/dist/cjs/dockview/dockviewComponent.d.ts.map +1 -1
- package/dist/cjs/dockview/dockviewComponent.js +1170 -1156
- package/dist/cjs/dockview/dockviewComponent.js.map +1 -1
- package/dist/cjs/dockview/dockviewFloatingGroupPanel.d.ts +23 -23
- package/dist/cjs/dockview/dockviewFloatingGroupPanel.js +34 -34
- package/dist/cjs/dockview/dockviewGroupPanel.d.ts +30 -30
- package/dist/cjs/dockview/dockviewGroupPanel.js +97 -97
- package/dist/cjs/dockview/dockviewGroupPanelModel.d.ts +185 -185
- package/dist/cjs/dockview/dockviewGroupPanelModel.js +632 -631
- package/dist/cjs/dockview/dockviewGroupPanelModel.js.map +1 -1
- package/dist/cjs/dockview/dockviewPanel.d.ts +41 -41
- package/dist/cjs/dockview/dockviewPanel.js +172 -171
- package/dist/cjs/dockview/dockviewPanel.js.map +1 -1
- package/dist/cjs/dockview/dockviewPanelModel.d.ts +35 -35
- package/dist/cjs/dockview/dockviewPanelModel.js +98 -98
- package/dist/cjs/dockview/dockviewPanelModel.js.map +1 -1
- package/dist/cjs/dockview/options.d.ts +133 -136
- package/dist/cjs/dockview/options.d.ts.map +1 -1
- package/dist/cjs/dockview/options.js +31 -31
- package/dist/cjs/dockview/types.d.ts +63 -63
- package/dist/cjs/dockview/types.js +10 -10
- package/dist/cjs/dockview/types.js.map +1 -1
- package/dist/cjs/dom.d.ts +16 -16
- package/dist/cjs/dom.js +197 -197
- package/dist/cjs/events.d.ts +47 -47
- package/dist/cjs/events.js +216 -216
- package/dist/cjs/events.js.map +1 -1
- package/dist/cjs/gridview/baseComponentGridview.d.ts +88 -87
- package/dist/cjs/gridview/baseComponentGridview.d.ts.map +1 -1
- package/dist/cjs/gridview/baseComponentGridview.js +270 -270
- package/dist/cjs/gridview/baseComponentGridview.js.map +1 -1
- package/dist/cjs/gridview/basePanelView.d.ts +40 -40
- package/dist/cjs/gridview/basePanelView.js +156 -156
- package/dist/cjs/gridview/branchNode.d.ts +49 -49
- package/dist/cjs/gridview/branchNode.js +343 -343
- package/dist/cjs/gridview/gridview.d.ts +133 -133
- package/dist/cjs/gridview/gridview.js +547 -547
- package/dist/cjs/gridview/gridviewComponent.d.ts +80 -80
- package/dist/cjs/gridview/gridviewComponent.d.ts.map +1 -1
- package/dist/cjs/gridview/gridviewComponent.js +362 -360
- package/dist/cjs/gridview/gridviewComponent.js.map +1 -1
- package/dist/cjs/gridview/gridviewPanel.d.ts +65 -65
- package/dist/cjs/gridview/gridviewPanel.js +214 -214
- package/dist/cjs/gridview/leafNode.d.ts +34 -34
- package/dist/cjs/gridview/leafNode.js +170 -170
- package/dist/cjs/gridview/leafNode.js.map +1 -1
- package/dist/cjs/gridview/options.d.ts +17 -18
- package/dist/cjs/gridview/options.d.ts.map +1 -1
- package/dist/cjs/gridview/options.js +2 -2
- package/dist/cjs/gridview/types.d.ts +3 -3
- package/dist/cjs/gridview/types.js +2 -2
- package/dist/cjs/index.d.ts +42 -42
- package/dist/cjs/index.js +61 -61
- package/dist/cjs/lifecycle.d.ts +23 -23
- package/dist/cjs/lifecycle.js +65 -65
- package/dist/cjs/lifecycle.js.map +1 -1
- package/dist/cjs/math.d.ts +5 -5
- package/dist/cjs/math.js +34 -34
- package/dist/cjs/panel/componentFactory.d.ts +11 -10
- package/dist/cjs/panel/componentFactory.d.ts.map +1 -1
- package/dist/cjs/panel/componentFactory.js +30 -30
- package/dist/cjs/panel/componentFactory.js.map +1 -1
- package/dist/cjs/panel/types.d.ts +33 -33
- package/dist/cjs/panel/types.js +2 -2
- package/dist/cjs/paneview/defaultPaneviewHeader.d.ts +21 -21
- package/dist/cjs/paneview/defaultPaneviewHeader.js +90 -90
- package/dist/cjs/paneview/draggablePaneviewPanel.d.ts +21 -21
- package/dist/cjs/paneview/draggablePaneviewPanel.js +131 -131
- package/dist/cjs/paneview/options.d.ts +25 -28
- package/dist/cjs/paneview/options.d.ts.map +1 -1
- package/dist/cjs/paneview/options.js +2 -2
- package/dist/cjs/paneview/paneview.d.ts +40 -40
- package/dist/cjs/paneview/paneview.d.ts.map +1 -1
- package/dist/cjs/paneview/paneview.js +200 -201
- package/dist/cjs/paneview/paneview.js.map +1 -1
- package/dist/cjs/paneview/paneviewComponent.d.ts +128 -128
- package/dist/cjs/paneview/paneviewComponent.js +400 -397
- package/dist/cjs/paneview/paneviewComponent.js.map +1 -1
- package/dist/cjs/paneview/paneviewPanel.d.ts +92 -92
- package/dist/cjs/paneview/paneviewPanel.d.ts.map +1 -1
- package/dist/cjs/paneview/paneviewPanel.js +275 -275
- package/dist/cjs/resizable.d.ts +10 -7
- package/dist/cjs/resizable.d.ts.map +1 -1
- package/dist/cjs/resizable.js +79 -64
- package/dist/cjs/resizable.js.map +1 -1
- package/dist/cjs/splitview/options.d.ts +26 -27
- package/dist/cjs/splitview/options.d.ts.map +1 -1
- package/dist/cjs/splitview/options.js +2 -2
- package/dist/cjs/splitview/splitview.d.ts +128 -128
- package/dist/cjs/splitview/splitview.js +936 -936
- package/dist/cjs/splitview/splitview.js.map +1 -1
- package/dist/cjs/splitview/splitviewComponent.d.ts +101 -101
- package/dist/cjs/splitview/splitviewComponent.js +395 -392
- package/dist/cjs/splitview/splitviewComponent.js.map +1 -1
- package/dist/cjs/splitview/splitviewPanel.d.ts +45 -45
- package/dist/cjs/splitview/splitviewPanel.d.ts.map +1 -1
- package/dist/cjs/splitview/splitviewPanel.js +179 -179
- package/dist/cjs/splitview/splitviewPanel.js.map +1 -1
- package/dist/cjs/splitview/viewItem.d.ts +25 -25
- package/dist/cjs/splitview/viewItem.js +119 -119
- package/dist/cjs/svg.d.ts +3 -3
- package/dist/cjs/svg.js +43 -43
- package/dist/cjs/types.d.ts +2 -2
- package/dist/cjs/types.js +2 -2
- package/dist/dockview-core.amd.js +7650 -7316
- package/dist/dockview-core.amd.js.map +1 -1
- package/dist/dockview-core.amd.min.js +2 -2
- package/dist/dockview-core.amd.min.js.map +1 -1
- package/dist/dockview-core.amd.min.noStyle.js +2 -2
- package/dist/dockview-core.amd.min.noStyle.js.map +1 -1
- package/dist/dockview-core.amd.noStyle.js +7601 -7267
- package/dist/dockview-core.amd.noStyle.js.map +1 -1
- package/dist/dockview-core.cjs.js +7650 -7316
- package/dist/dockview-core.cjs.js.map +1 -1
- package/dist/dockview-core.esm.js +7650 -7316
- package/dist/dockview-core.esm.js.map +1 -1
- package/dist/dockview-core.esm.min.js +2 -2
- package/dist/dockview-core.esm.min.js.map +1 -1
- package/dist/dockview-core.js +7650 -7316
- package/dist/dockview-core.js.map +1 -1
- package/dist/dockview-core.min.js +2 -2
- package/dist/dockview-core.min.js.map +1 -1
- package/dist/dockview-core.min.noStyle.js +2 -2
- package/dist/dockview-core.min.noStyle.js.map +1 -1
- package/dist/dockview-core.noStyle.js +7601 -7267
- package/dist/dockview-core.noStyle.js.map +1 -1
- package/dist/esm/api/component.api.d.ts +455 -152
- package/dist/esm/api/component.api.d.ts.map +1 -1
- package/dist/esm/api/component.api.js +638 -335
- package/dist/esm/api/component.api.js.map +1 -1
- package/dist/esm/api/dockviewGroupPanelApi.d.ts +29 -29
- package/dist/esm/api/dockviewGroupPanelApi.js +27 -27
- package/dist/esm/api/dockviewPanelApi.d.ts +47 -47
- package/dist/esm/api/dockviewPanelApi.js +53 -53
- package/dist/esm/api/gridviewPanelApi.d.ts +37 -37
- package/dist/esm/api/gridviewPanelApi.js +25 -25
- package/dist/esm/api/panelApi.d.ts +88 -88
- package/dist/esm/api/panelApi.js +93 -93
- package/dist/esm/api/paneviewPanelApi.d.ts +26 -26
- package/dist/esm/api/paneviewPanelApi.js +27 -27
- package/dist/esm/api/splitviewPanelApi.d.ts +32 -32
- package/dist/esm/api/splitviewPanelApi.js +25 -25
- package/dist/esm/array.d.ts +13 -13
- package/dist/esm/array.js +57 -57
- package/dist/esm/dnd/abstractDragHandler.d.ts +12 -12
- package/dist/esm/dnd/abstractDragHandler.js +63 -63
- package/dist/esm/dnd/dataTransfer.d.ts +30 -31
- package/dist/esm/dnd/dataTransfer.d.ts.map +1 -1
- package/dist/esm/dnd/dataTransfer.js +66 -69
- package/dist/esm/dnd/dataTransfer.js.map +1 -1
- package/dist/esm/dnd/dnd.d.ts +27 -27
- package/dist/esm/dnd/dnd.js +36 -36
- package/dist/esm/dnd/droptarget.d.ts +53 -53
- package/dist/esm/dnd/droptarget.js +274 -274
- package/dist/esm/dnd/droptarget.js.map +1 -1
- package/dist/esm/dnd/ghost.d.ts +1 -1
- package/dist/esm/dnd/ghost.js +11 -11
- package/dist/esm/dnd/groupDragHandler.d.ts +12 -12
- package/dist/esm/dnd/groupDragHandler.js +54 -54
- package/dist/esm/dnd/overlay.d.ts +43 -43
- package/dist/esm/dnd/overlay.d.ts.map +1 -1
- package/dist/esm/dnd/overlay.js +304 -304
- package/dist/esm/dnd/overlay.js.map +1 -1
- package/dist/esm/dockview/components/panel/content.d.ts +30 -30
- package/dist/esm/dockview/components/panel/content.js +73 -73
- package/dist/esm/dockview/components/tab/defaultTab.d.ts +21 -21
- package/dist/esm/dockview/components/tab/defaultTab.js +67 -67
- package/dist/esm/dockview/components/tab/tab.d.ts +34 -34
- package/dist/esm/dockview/components/tab/tab.js +90 -90
- package/dist/esm/dockview/components/titlebar/tabsContainer.d.ts +81 -81
- package/dist/esm/dockview/components/titlebar/tabsContainer.js +239 -239
- package/dist/esm/dockview/components/titlebar/voidContainer.d.ts +17 -17
- package/dist/esm/dockview/components/titlebar/voidContainer.js +51 -51
- package/dist/esm/dockview/components/watermark/watermark.d.ts +18 -18
- package/dist/esm/dockview/components/watermark/watermark.js +61 -61
- package/dist/esm/dockview/deserializer.d.ts +12 -12
- package/dist/esm/dockview/deserializer.js +28 -28
- package/dist/esm/dockview/deserializer.js.map +1 -1
- package/dist/esm/dockview/dockviewComponent.d.ts +159 -159
- package/dist/esm/dockview/dockviewComponent.d.ts.map +1 -1
- package/dist/esm/dockview/dockviewComponent.js +932 -918
- package/dist/esm/dockview/dockviewComponent.js.map +1 -1
- package/dist/esm/dockview/dockviewFloatingGroupPanel.d.ts +23 -23
- package/dist/esm/dockview/dockviewFloatingGroupPanel.js +12 -12
- package/dist/esm/dockview/dockviewGroupPanel.d.ts +30 -30
- package/dist/esm/dockview/dockviewGroupPanel.js +51 -51
- package/dist/esm/dockview/dockviewGroupPanelModel.d.ts +185 -185
- package/dist/esm/dockview/dockviewGroupPanelModel.js +499 -498
- package/dist/esm/dockview/dockviewGroupPanelModel.js.map +1 -1
- package/dist/esm/dockview/dockviewPanel.d.ts +41 -41
- package/dist/esm/dockview/dockviewPanel.js +105 -104
- package/dist/esm/dockview/dockviewPanel.js.map +1 -1
- package/dist/esm/dockview/dockviewPanelModel.d.ts +35 -35
- package/dist/esm/dockview/dockviewPanelModel.js +74 -74
- package/dist/esm/dockview/dockviewPanelModel.js.map +1 -1
- package/dist/esm/dockview/options.d.ts +133 -136
- package/dist/esm/dockview/options.d.ts.map +1 -1
- package/dist/esm/dockview/options.js +24 -24
- package/dist/esm/dockview/types.d.ts +63 -63
- package/dist/esm/dockview/types.js +7 -7
- package/dist/esm/dom.d.ts +16 -16
- package/dist/esm/dom.js +126 -126
- package/dist/esm/events.d.ts +47 -47
- package/dist/esm/events.js +156 -156
- package/dist/esm/events.js.map +1 -1
- package/dist/esm/gridview/baseComponentGridview.d.ts +88 -87
- package/dist/esm/gridview/baseComponentGridview.d.ts.map +1 -1
- package/dist/esm/gridview/baseComponentGridview.js +184 -184
- package/dist/esm/gridview/baseComponentGridview.js.map +1 -1
- package/dist/esm/gridview/basePanelView.d.ts +40 -40
- package/dist/esm/gridview/basePanelView.js +85 -85
- package/dist/esm/gridview/branchNode.d.ts +49 -49
- package/dist/esm/gridview/branchNode.js +219 -219
- package/dist/esm/gridview/gridview.d.ts +133 -133
- package/dist/esm/gridview/gridview.js +461 -461
- package/dist/esm/gridview/gridviewComponent.d.ts +80 -80
- package/dist/esm/gridview/gridviewComponent.d.ts.map +1 -1
- package/dist/esm/gridview/gridviewComponent.js +264 -262
- package/dist/esm/gridview/gridviewComponent.js.map +1 -1
- package/dist/esm/gridview/gridviewPanel.d.ts +65 -65
- package/dist/esm/gridview/gridviewPanel.js +151 -151
- package/dist/esm/gridview/leafNode.d.ts +34 -34
- package/dist/esm/gridview/leafNode.js +103 -103
- package/dist/esm/gridview/options.d.ts +17 -18
- package/dist/esm/gridview/options.d.ts.map +1 -1
- package/dist/esm/gridview/options.js +1 -1
- package/dist/esm/gridview/types.d.ts +3 -3
- package/dist/esm/gridview/types.js +1 -1
- package/dist/esm/index.d.ts +42 -42
- package/dist/esm/index.js +34 -34
- package/dist/esm/lifecycle.d.ts +23 -23
- package/dist/esm/lifecycle.js +41 -41
- package/dist/esm/math.d.ts +5 -5
- package/dist/esm/math.js +28 -28
- package/dist/esm/panel/componentFactory.d.ts +11 -10
- package/dist/esm/panel/componentFactory.d.ts.map +1 -1
- package/dist/esm/panel/componentFactory.js +24 -24
- package/dist/esm/panel/componentFactory.js.map +1 -1
- package/dist/esm/panel/types.d.ts +33 -33
- package/dist/esm/panel/types.js +1 -1
- package/dist/esm/paneview/defaultPaneviewHeader.d.ts +21 -21
- package/dist/esm/paneview/defaultPaneviewHeader.js +63 -63
- package/dist/esm/paneview/draggablePaneviewPanel.d.ts +21 -21
- package/dist/esm/paneview/draggablePaneviewPanel.js +92 -92
- package/dist/esm/paneview/options.d.ts +25 -28
- package/dist/esm/paneview/options.d.ts.map +1 -1
- package/dist/esm/paneview/options.js +1 -1
- package/dist/esm/paneview/paneview.d.ts +40 -40
- package/dist/esm/paneview/paneview.d.ts.map +1 -1
- package/dist/esm/paneview/paneview.js +145 -145
- package/dist/esm/paneview/paneviewComponent.d.ts +128 -128
- package/dist/esm/paneview/paneviewComponent.js +276 -273
- package/dist/esm/paneview/paneviewComponent.js.map +1 -1
- package/dist/esm/paneview/paneviewPanel.d.ts +92 -92
- package/dist/esm/paneview/paneviewPanel.d.ts.map +1 -1
- package/dist/esm/paneview/paneviewPanel.js +192 -192
- package/dist/esm/resizable.d.ts +10 -7
- package/dist/esm/resizable.d.ts.map +1 -1
- package/dist/esm/resizable.js +48 -38
- package/dist/esm/resizable.js.map +1 -1
- package/dist/esm/splitview/options.d.ts +26 -27
- package/dist/esm/splitview/options.d.ts.map +1 -1
- package/dist/esm/splitview/options.js +1 -1
- package/dist/esm/splitview/splitview.d.ts +128 -128
- package/dist/esm/splitview/splitview.js +704 -704
- package/dist/esm/splitview/splitviewComponent.d.ts +101 -101
- package/dist/esm/splitview/splitviewComponent.js +261 -258
- package/dist/esm/splitview/splitviewComponent.js.map +1 -1
- package/dist/esm/splitview/splitviewPanel.d.ts +45 -45
- package/dist/esm/splitview/splitviewPanel.d.ts.map +1 -1
- package/dist/esm/splitview/splitviewPanel.js +108 -108
- package/dist/esm/splitview/splitviewPanel.js.map +1 -1
- package/dist/esm/splitview/viewItem.d.ts +25 -25
- package/dist/esm/splitview/viewItem.js +74 -74
- package/dist/esm/svg.d.ts +3 -3
- package/dist/esm/svg.js +31 -31
- package/dist/esm/types.d.ts +2 -2
- package/dist/esm/types.js +1 -1
- package/package.json +30 -42
- package/LICENSE +0 -21
|
@@ -1,462 +1,462 @@
|
|
|
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);
|
|
184
|
-
}
|
|
185
|
-
_deserializeNode(node, orientation, deserializer, orthogonalSize) {
|
|
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
|
-
result = new BranchNode(orientation, this.proportionalLayout, this.styles, node.size, // <- orthogonal size - flips at each depth
|
|
196
|
-
orthogonalSize, // <- size - flips at each depth
|
|
197
|
-
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 === 0) {
|
|
231
|
-
// no data so no need to add anything back in
|
|
232
|
-
}
|
|
233
|
-
else if (oldRoot.children.length === 1) {
|
|
234
|
-
// can remove one level of redundant branching if there is only a single child
|
|
235
|
-
const childReference = oldRoot.children[0];
|
|
236
|
-
const child = oldRoot.removeChild(0); // remove to prevent disposal when disposing of unwanted root
|
|
237
|
-
child.dispose();
|
|
238
|
-
oldRoot.dispose();
|
|
239
|
-
this._root.addChild(
|
|
240
|
-
/**
|
|
241
|
-
* the child node will have the same orientation as the new root since
|
|
242
|
-
* we are removing the inbetween node.
|
|
243
|
-
* the entire 'tree' must be flipped recursively to ensure that the orientation
|
|
244
|
-
* flips at each level
|
|
245
|
-
*/
|
|
246
|
-
flipNode(childReference, childReference.orthogonalSize, childReference.size), Sizing.Distribute, 0);
|
|
247
|
-
}
|
|
248
|
-
else {
|
|
249
|
-
this._root.addChild(oldRoot, Sizing.Distribute, 0);
|
|
250
|
-
}
|
|
251
|
-
this.element.appendChild(this._root.element);
|
|
252
|
-
this.disposable.value = this._root.onDidChange((e) => {
|
|
253
|
-
this._onDidChange.fire(e);
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
next(location) {
|
|
257
|
-
return this.progmaticSelect(location);
|
|
258
|
-
}
|
|
259
|
-
previous(location) {
|
|
260
|
-
return this.progmaticSelect(location, true);
|
|
261
|
-
}
|
|
262
|
-
getView(location) {
|
|
263
|
-
const node = location ? this.getNode(location)[1] : this.root;
|
|
264
|
-
return this._getViews(node, this.orientation);
|
|
265
|
-
}
|
|
266
|
-
_getViews(node, orientation, cachedVisibleSize) {
|
|
267
|
-
const box = { height: node.height, width: node.width };
|
|
268
|
-
if (node instanceof LeafNode) {
|
|
269
|
-
return { box, view: node.view, cachedVisibleSize };
|
|
270
|
-
}
|
|
271
|
-
const children = [];
|
|
272
|
-
for (let i = 0; i < node.children.length; i++) {
|
|
273
|
-
const child = node.children[i];
|
|
274
|
-
const nodeCachedVisibleSize = node.getChildCachedVisibleSize(i);
|
|
275
|
-
children.push(this._getViews(child, orthogonal(orientation), nodeCachedVisibleSize));
|
|
276
|
-
}
|
|
277
|
-
return { box, children };
|
|
278
|
-
}
|
|
279
|
-
progmaticSelect(location, reverse = false) {
|
|
280
|
-
const [path, node] = this.getNode(location);
|
|
281
|
-
if (!(node instanceof LeafNode)) {
|
|
282
|
-
throw new Error('invalid location');
|
|
283
|
-
}
|
|
284
|
-
for (let i = path.length - 1; i > -1; i--) {
|
|
285
|
-
const n = path[i];
|
|
286
|
-
const l = location[i] || 0;
|
|
287
|
-
const canProgressInCurrentLevel = reverse
|
|
288
|
-
? l - 1 > -1
|
|
289
|
-
: l + 1 < n.children.length;
|
|
290
|
-
if (canProgressInCurrentLevel) {
|
|
291
|
-
return findLeaf(n.children[reverse ? l - 1 : l + 1], reverse);
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
return findLeaf(this.root, reverse);
|
|
295
|
-
}
|
|
296
|
-
constructor(proportionalLayout, styles, orientation) {
|
|
297
|
-
this.proportionalLayout = proportionalLayout;
|
|
298
|
-
this.styles = styles;
|
|
299
|
-
this.disposable = new MutableDisposable();
|
|
300
|
-
this._onDidChange = new Emitter();
|
|
301
|
-
this.onDidChange = this._onDidChange.event;
|
|
302
|
-
this.element = document.createElement('div');
|
|
303
|
-
this.element.className = 'grid-view';
|
|
304
|
-
this.root = new BranchNode(orientation, proportionalLayout, styles, 0, 0);
|
|
305
|
-
}
|
|
306
|
-
isViewVisible(location) {
|
|
307
|
-
const [rest, index] = tail(location);
|
|
308
|
-
const [, parent] = this.getNode(rest);
|
|
309
|
-
if (!(parent instanceof BranchNode)) {
|
|
310
|
-
throw new Error('Invalid from location');
|
|
311
|
-
}
|
|
312
|
-
return parent.isChildVisible(index);
|
|
313
|
-
}
|
|
314
|
-
setViewVisible(location, visible) {
|
|
315
|
-
const [rest, index] = tail(location);
|
|
316
|
-
const [, parent] = this.getNode(rest);
|
|
317
|
-
if (!(parent instanceof BranchNode)) {
|
|
318
|
-
throw new Error('Invalid from location');
|
|
319
|
-
}
|
|
320
|
-
parent.setChildVisible(index, visible);
|
|
321
|
-
}
|
|
322
|
-
moveView(parentLocation, from, to) {
|
|
323
|
-
const [, parent] = this.getNode(parentLocation);
|
|
324
|
-
if (!(parent instanceof BranchNode)) {
|
|
325
|
-
throw new Error('Invalid location');
|
|
326
|
-
}
|
|
327
|
-
parent.moveChild(from, to);
|
|
328
|
-
}
|
|
329
|
-
addView(view, size, location) {
|
|
330
|
-
const [rest, index] = tail(location);
|
|
331
|
-
const [pathToParent, parent] = this.getNode(rest);
|
|
332
|
-
if (parent instanceof BranchNode) {
|
|
333
|
-
const node = new LeafNode(view, orthogonal(parent.orientation), parent.orthogonalSize);
|
|
334
|
-
parent.addChild(node, size, index);
|
|
335
|
-
}
|
|
336
|
-
else {
|
|
337
|
-
const [grandParent, ..._] = [...pathToParent].reverse();
|
|
338
|
-
const [parentIndex, ...__] = [...rest].reverse();
|
|
339
|
-
let newSiblingSize = 0;
|
|
340
|
-
const newSiblingCachedVisibleSize = grandParent.getChildCachedVisibleSize(parentIndex);
|
|
341
|
-
if (typeof newSiblingCachedVisibleSize === 'number') {
|
|
342
|
-
newSiblingSize = Sizing.Invisible(newSiblingCachedVisibleSize);
|
|
343
|
-
}
|
|
344
|
-
const child = grandParent.removeChild(parentIndex);
|
|
345
|
-
child.dispose();
|
|
346
|
-
const newParent = new BranchNode(parent.orientation, this.proportionalLayout, this.styles, parent.size, parent.orthogonalSize);
|
|
347
|
-
grandParent.addChild(newParent, parent.size, parentIndex);
|
|
348
|
-
const newSibling = new LeafNode(parent.view, grandParent.orientation, parent.size);
|
|
349
|
-
newParent.addChild(newSibling, newSiblingSize, 0);
|
|
350
|
-
if (typeof size !== 'number' && size.type === 'split') {
|
|
351
|
-
size = { type: 'split', index: 0 };
|
|
352
|
-
}
|
|
353
|
-
const node = new LeafNode(view, grandParent.orientation, parent.size);
|
|
354
|
-
newParent.addChild(node, size, index);
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
remove(view, sizing) {
|
|
358
|
-
const location = getGridLocation(view.element);
|
|
359
|
-
return this.removeView(location, sizing);
|
|
360
|
-
}
|
|
361
|
-
removeView(location, sizing) {
|
|
362
|
-
const [rest, index] = tail(location);
|
|
363
|
-
const [pathToParent, parent] = this.getNode(rest);
|
|
364
|
-
if (!(parent instanceof BranchNode)) {
|
|
365
|
-
throw new Error('Invalid location');
|
|
366
|
-
}
|
|
367
|
-
const nodeToRemove = parent.children[index];
|
|
368
|
-
if (!(nodeToRemove instanceof LeafNode)) {
|
|
369
|
-
throw new Error('Invalid location');
|
|
370
|
-
}
|
|
371
|
-
parent.removeChild(index, sizing);
|
|
372
|
-
nodeToRemove.dispose();
|
|
373
|
-
if (parent.children.length !== 1) {
|
|
374
|
-
return nodeToRemove.view;
|
|
375
|
-
}
|
|
376
|
-
// if the parent has only one child and we know the parent is a BranchNode we can make the tree
|
|
377
|
-
// more efficiently spaced by replacing the parent BranchNode with the child.
|
|
378
|
-
// if that child is a LeafNode then we simply replace the BranchNode with the child otherwise if the child
|
|
379
|
-
// is a BranchNode too we should spread it's children into the grandparent.
|
|
380
|
-
// refer to the remaining child as the sibling
|
|
381
|
-
const sibling = parent.children[0];
|
|
382
|
-
if (pathToParent.length === 0) {
|
|
383
|
-
// if the parent is root
|
|
384
|
-
if (sibling instanceof LeafNode) {
|
|
385
|
-
// if the sibling is a leaf node no action is required
|
|
386
|
-
return nodeToRemove.view;
|
|
387
|
-
}
|
|
388
|
-
// otherwise the sibling is a branch node. since the parent is the root and the root has only one child
|
|
389
|
-
// which is a branch node we can just set this branch node to be the new root node
|
|
390
|
-
// for good housekeeping we'll removing the sibling from it's existing tree
|
|
391
|
-
parent.removeChild(0, sizing);
|
|
392
|
-
// and set that sibling node to be root
|
|
393
|
-
this.root = sibling;
|
|
394
|
-
return nodeToRemove.view;
|
|
395
|
-
}
|
|
396
|
-
// otherwise the parent is apart of a large sub-tree
|
|
397
|
-
const [grandParent, ..._] = [...pathToParent].reverse();
|
|
398
|
-
const [parentIndex, ...__] = [...rest].reverse();
|
|
399
|
-
const isSiblingVisible = parent.isChildVisible(0);
|
|
400
|
-
// either way we need to remove the sibling from it's existing tree
|
|
401
|
-
parent.removeChild(0, sizing);
|
|
402
|
-
// note the sizes of all of the grandparents children
|
|
403
|
-
const sizes = grandParent.children.map((_size, i) => grandParent.getChildSize(i));
|
|
404
|
-
// remove the parent from the grandparent since we are moving the sibling to take the parents place
|
|
405
|
-
// this parent is no longer used and can be disposed of
|
|
406
|
-
grandParent.removeChild(parentIndex, sizing).dispose();
|
|
407
|
-
if (sibling instanceof BranchNode) {
|
|
408
|
-
// replace the parent with the siblings children
|
|
409
|
-
sizes.splice(parentIndex, 1, ...sibling.children.map((c) => c.size));
|
|
410
|
-
// and add those siblings to the grandparent
|
|
411
|
-
for (let i = 0; i < sibling.children.length; i++) {
|
|
412
|
-
const child = sibling.children[i];
|
|
413
|
-
grandParent.addChild(child, child.size, parentIndex + i);
|
|
414
|
-
}
|
|
415
|
-
/**
|
|
416
|
-
* clean down the branch node since we need to dipose of it and
|
|
417
|
-
* when .dispose() it called on a branch it will dispose of any
|
|
418
|
-
* views it is holding onto.
|
|
419
|
-
*/
|
|
420
|
-
while (sibling.children.length > 0) {
|
|
421
|
-
sibling.removeChild(0);
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
else {
|
|
425
|
-
// otherwise create a new leaf node and add that to the grandparent
|
|
426
|
-
const newSibling = new LeafNode(sibling.view, orthogonal(sibling.orientation), sibling.size);
|
|
427
|
-
const siblingSizing = isSiblingVisible
|
|
428
|
-
? sibling.orthogonalSize
|
|
429
|
-
: Sizing.Invisible(sibling.orthogonalSize);
|
|
430
|
-
grandParent.addChild(newSibling, siblingSizing, parentIndex);
|
|
431
|
-
}
|
|
432
|
-
// the containing node of the sibling is no longer required and can be disposed of
|
|
433
|
-
sibling.dispose();
|
|
434
|
-
// resize everything
|
|
435
|
-
for (let i = 0; i < sizes.length; i++) {
|
|
436
|
-
grandParent.resizeChild(i, sizes[i]);
|
|
437
|
-
}
|
|
438
|
-
return nodeToRemove.view;
|
|
439
|
-
}
|
|
440
|
-
layout(width, height) {
|
|
441
|
-
const [size, orthogonalSize] = this.root.orientation === Orientation.HORIZONTAL
|
|
442
|
-
? [height, width]
|
|
443
|
-
: [width, height];
|
|
444
|
-
this.root.layout(size, orthogonalSize);
|
|
445
|
-
}
|
|
446
|
-
getNode(location, node = this.root, path = []) {
|
|
447
|
-
if (location.length === 0) {
|
|
448
|
-
return [path, node];
|
|
449
|
-
}
|
|
450
|
-
if (!(node instanceof BranchNode)) {
|
|
451
|
-
throw new Error('Invalid location');
|
|
452
|
-
}
|
|
453
|
-
const [index, ...rest] = location;
|
|
454
|
-
if (index < 0 || index >= node.children.length) {
|
|
455
|
-
throw new Error('Invalid location');
|
|
456
|
-
}
|
|
457
|
-
const child = node.children[index];
|
|
458
|
-
path.push(node);
|
|
459
|
-
return this.getNode(rest, child, path);
|
|
460
|
-
}
|
|
461
|
-
}
|
|
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);
|
|
184
|
+
}
|
|
185
|
+
_deserializeNode(node, orientation, deserializer, orthogonalSize) {
|
|
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
|
+
result = new BranchNode(orientation, this.proportionalLayout, this.styles, node.size, // <- orthogonal size - flips at each depth
|
|
196
|
+
orthogonalSize, // <- size - flips at each depth
|
|
197
|
+
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 === 0) {
|
|
231
|
+
// no data so no need to add anything back in
|
|
232
|
+
}
|
|
233
|
+
else if (oldRoot.children.length === 1) {
|
|
234
|
+
// can remove one level of redundant branching if there is only a single child
|
|
235
|
+
const childReference = oldRoot.children[0];
|
|
236
|
+
const child = oldRoot.removeChild(0); // remove to prevent disposal when disposing of unwanted root
|
|
237
|
+
child.dispose();
|
|
238
|
+
oldRoot.dispose();
|
|
239
|
+
this._root.addChild(
|
|
240
|
+
/**
|
|
241
|
+
* the child node will have the same orientation as the new root since
|
|
242
|
+
* we are removing the inbetween node.
|
|
243
|
+
* the entire 'tree' must be flipped recursively to ensure that the orientation
|
|
244
|
+
* flips at each level
|
|
245
|
+
*/
|
|
246
|
+
flipNode(childReference, childReference.orthogonalSize, childReference.size), Sizing.Distribute, 0);
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
this._root.addChild(oldRoot, Sizing.Distribute, 0);
|
|
250
|
+
}
|
|
251
|
+
this.element.appendChild(this._root.element);
|
|
252
|
+
this.disposable.value = this._root.onDidChange((e) => {
|
|
253
|
+
this._onDidChange.fire(e);
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
next(location) {
|
|
257
|
+
return this.progmaticSelect(location);
|
|
258
|
+
}
|
|
259
|
+
previous(location) {
|
|
260
|
+
return this.progmaticSelect(location, true);
|
|
261
|
+
}
|
|
262
|
+
getView(location) {
|
|
263
|
+
const node = location ? this.getNode(location)[1] : this.root;
|
|
264
|
+
return this._getViews(node, this.orientation);
|
|
265
|
+
}
|
|
266
|
+
_getViews(node, orientation, cachedVisibleSize) {
|
|
267
|
+
const box = { height: node.height, width: node.width };
|
|
268
|
+
if (node instanceof LeafNode) {
|
|
269
|
+
return { box, view: node.view, cachedVisibleSize };
|
|
270
|
+
}
|
|
271
|
+
const children = [];
|
|
272
|
+
for (let i = 0; i < node.children.length; i++) {
|
|
273
|
+
const child = node.children[i];
|
|
274
|
+
const nodeCachedVisibleSize = node.getChildCachedVisibleSize(i);
|
|
275
|
+
children.push(this._getViews(child, orthogonal(orientation), nodeCachedVisibleSize));
|
|
276
|
+
}
|
|
277
|
+
return { box, children };
|
|
278
|
+
}
|
|
279
|
+
progmaticSelect(location, reverse = false) {
|
|
280
|
+
const [path, node] = this.getNode(location);
|
|
281
|
+
if (!(node instanceof LeafNode)) {
|
|
282
|
+
throw new Error('invalid location');
|
|
283
|
+
}
|
|
284
|
+
for (let i = path.length - 1; i > -1; i--) {
|
|
285
|
+
const n = path[i];
|
|
286
|
+
const l = location[i] || 0;
|
|
287
|
+
const canProgressInCurrentLevel = reverse
|
|
288
|
+
? l - 1 > -1
|
|
289
|
+
: l + 1 < n.children.length;
|
|
290
|
+
if (canProgressInCurrentLevel) {
|
|
291
|
+
return findLeaf(n.children[reverse ? l - 1 : l + 1], reverse);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
return findLeaf(this.root, reverse);
|
|
295
|
+
}
|
|
296
|
+
constructor(proportionalLayout, styles, orientation) {
|
|
297
|
+
this.proportionalLayout = proportionalLayout;
|
|
298
|
+
this.styles = styles;
|
|
299
|
+
this.disposable = new MutableDisposable();
|
|
300
|
+
this._onDidChange = new Emitter();
|
|
301
|
+
this.onDidChange = this._onDidChange.event;
|
|
302
|
+
this.element = document.createElement('div');
|
|
303
|
+
this.element.className = 'grid-view';
|
|
304
|
+
this.root = new BranchNode(orientation, proportionalLayout, styles, 0, 0);
|
|
305
|
+
}
|
|
306
|
+
isViewVisible(location) {
|
|
307
|
+
const [rest, index] = tail(location);
|
|
308
|
+
const [, parent] = this.getNode(rest);
|
|
309
|
+
if (!(parent instanceof BranchNode)) {
|
|
310
|
+
throw new Error('Invalid from location');
|
|
311
|
+
}
|
|
312
|
+
return parent.isChildVisible(index);
|
|
313
|
+
}
|
|
314
|
+
setViewVisible(location, visible) {
|
|
315
|
+
const [rest, index] = tail(location);
|
|
316
|
+
const [, parent] = this.getNode(rest);
|
|
317
|
+
if (!(parent instanceof BranchNode)) {
|
|
318
|
+
throw new Error('Invalid from location');
|
|
319
|
+
}
|
|
320
|
+
parent.setChildVisible(index, visible);
|
|
321
|
+
}
|
|
322
|
+
moveView(parentLocation, from, to) {
|
|
323
|
+
const [, parent] = this.getNode(parentLocation);
|
|
324
|
+
if (!(parent instanceof BranchNode)) {
|
|
325
|
+
throw new Error('Invalid location');
|
|
326
|
+
}
|
|
327
|
+
parent.moveChild(from, to);
|
|
328
|
+
}
|
|
329
|
+
addView(view, size, location) {
|
|
330
|
+
const [rest, index] = tail(location);
|
|
331
|
+
const [pathToParent, parent] = this.getNode(rest);
|
|
332
|
+
if (parent instanceof BranchNode) {
|
|
333
|
+
const node = new LeafNode(view, orthogonal(parent.orientation), parent.orthogonalSize);
|
|
334
|
+
parent.addChild(node, size, index);
|
|
335
|
+
}
|
|
336
|
+
else {
|
|
337
|
+
const [grandParent, ..._] = [...pathToParent].reverse();
|
|
338
|
+
const [parentIndex, ...__] = [...rest].reverse();
|
|
339
|
+
let newSiblingSize = 0;
|
|
340
|
+
const newSiblingCachedVisibleSize = grandParent.getChildCachedVisibleSize(parentIndex);
|
|
341
|
+
if (typeof newSiblingCachedVisibleSize === 'number') {
|
|
342
|
+
newSiblingSize = Sizing.Invisible(newSiblingCachedVisibleSize);
|
|
343
|
+
}
|
|
344
|
+
const child = grandParent.removeChild(parentIndex);
|
|
345
|
+
child.dispose();
|
|
346
|
+
const newParent = new BranchNode(parent.orientation, this.proportionalLayout, this.styles, parent.size, parent.orthogonalSize);
|
|
347
|
+
grandParent.addChild(newParent, parent.size, parentIndex);
|
|
348
|
+
const newSibling = new LeafNode(parent.view, grandParent.orientation, parent.size);
|
|
349
|
+
newParent.addChild(newSibling, newSiblingSize, 0);
|
|
350
|
+
if (typeof size !== 'number' && size.type === 'split') {
|
|
351
|
+
size = { type: 'split', index: 0 };
|
|
352
|
+
}
|
|
353
|
+
const node = new LeafNode(view, grandParent.orientation, parent.size);
|
|
354
|
+
newParent.addChild(node, size, index);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
remove(view, sizing) {
|
|
358
|
+
const location = getGridLocation(view.element);
|
|
359
|
+
return this.removeView(location, sizing);
|
|
360
|
+
}
|
|
361
|
+
removeView(location, sizing) {
|
|
362
|
+
const [rest, index] = tail(location);
|
|
363
|
+
const [pathToParent, parent] = this.getNode(rest);
|
|
364
|
+
if (!(parent instanceof BranchNode)) {
|
|
365
|
+
throw new Error('Invalid location');
|
|
366
|
+
}
|
|
367
|
+
const nodeToRemove = parent.children[index];
|
|
368
|
+
if (!(nodeToRemove instanceof LeafNode)) {
|
|
369
|
+
throw new Error('Invalid location');
|
|
370
|
+
}
|
|
371
|
+
parent.removeChild(index, sizing);
|
|
372
|
+
nodeToRemove.dispose();
|
|
373
|
+
if (parent.children.length !== 1) {
|
|
374
|
+
return nodeToRemove.view;
|
|
375
|
+
}
|
|
376
|
+
// if the parent has only one child and we know the parent is a BranchNode we can make the tree
|
|
377
|
+
// more efficiently spaced by replacing the parent BranchNode with the child.
|
|
378
|
+
// if that child is a LeafNode then we simply replace the BranchNode with the child otherwise if the child
|
|
379
|
+
// is a BranchNode too we should spread it's children into the grandparent.
|
|
380
|
+
// refer to the remaining child as the sibling
|
|
381
|
+
const sibling = parent.children[0];
|
|
382
|
+
if (pathToParent.length === 0) {
|
|
383
|
+
// if the parent is root
|
|
384
|
+
if (sibling instanceof LeafNode) {
|
|
385
|
+
// if the sibling is a leaf node no action is required
|
|
386
|
+
return nodeToRemove.view;
|
|
387
|
+
}
|
|
388
|
+
// otherwise the sibling is a branch node. since the parent is the root and the root has only one child
|
|
389
|
+
// which is a branch node we can just set this branch node to be the new root node
|
|
390
|
+
// for good housekeeping we'll removing the sibling from it's existing tree
|
|
391
|
+
parent.removeChild(0, sizing);
|
|
392
|
+
// and set that sibling node to be root
|
|
393
|
+
this.root = sibling;
|
|
394
|
+
return nodeToRemove.view;
|
|
395
|
+
}
|
|
396
|
+
// otherwise the parent is apart of a large sub-tree
|
|
397
|
+
const [grandParent, ..._] = [...pathToParent].reverse();
|
|
398
|
+
const [parentIndex, ...__] = [...rest].reverse();
|
|
399
|
+
const isSiblingVisible = parent.isChildVisible(0);
|
|
400
|
+
// either way we need to remove the sibling from it's existing tree
|
|
401
|
+
parent.removeChild(0, sizing);
|
|
402
|
+
// note the sizes of all of the grandparents children
|
|
403
|
+
const sizes = grandParent.children.map((_size, i) => grandParent.getChildSize(i));
|
|
404
|
+
// remove the parent from the grandparent since we are moving the sibling to take the parents place
|
|
405
|
+
// this parent is no longer used and can be disposed of
|
|
406
|
+
grandParent.removeChild(parentIndex, sizing).dispose();
|
|
407
|
+
if (sibling instanceof BranchNode) {
|
|
408
|
+
// replace the parent with the siblings children
|
|
409
|
+
sizes.splice(parentIndex, 1, ...sibling.children.map((c) => c.size));
|
|
410
|
+
// and add those siblings to the grandparent
|
|
411
|
+
for (let i = 0; i < sibling.children.length; i++) {
|
|
412
|
+
const child = sibling.children[i];
|
|
413
|
+
grandParent.addChild(child, child.size, parentIndex + i);
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* clean down the branch node since we need to dipose of it and
|
|
417
|
+
* when .dispose() it called on a branch it will dispose of any
|
|
418
|
+
* views it is holding onto.
|
|
419
|
+
*/
|
|
420
|
+
while (sibling.children.length > 0) {
|
|
421
|
+
sibling.removeChild(0);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
else {
|
|
425
|
+
// otherwise create a new leaf node and add that to the grandparent
|
|
426
|
+
const newSibling = new LeafNode(sibling.view, orthogonal(sibling.orientation), sibling.size);
|
|
427
|
+
const siblingSizing = isSiblingVisible
|
|
428
|
+
? sibling.orthogonalSize
|
|
429
|
+
: Sizing.Invisible(sibling.orthogonalSize);
|
|
430
|
+
grandParent.addChild(newSibling, siblingSizing, parentIndex);
|
|
431
|
+
}
|
|
432
|
+
// the containing node of the sibling is no longer required and can be disposed of
|
|
433
|
+
sibling.dispose();
|
|
434
|
+
// resize everything
|
|
435
|
+
for (let i = 0; i < sizes.length; i++) {
|
|
436
|
+
grandParent.resizeChild(i, sizes[i]);
|
|
437
|
+
}
|
|
438
|
+
return nodeToRemove.view;
|
|
439
|
+
}
|
|
440
|
+
layout(width, height) {
|
|
441
|
+
const [size, orthogonalSize] = this.root.orientation === Orientation.HORIZONTAL
|
|
442
|
+
? [height, width]
|
|
443
|
+
: [width, height];
|
|
444
|
+
this.root.layout(size, orthogonalSize);
|
|
445
|
+
}
|
|
446
|
+
getNode(location, node = this.root, path = []) {
|
|
447
|
+
if (location.length === 0) {
|
|
448
|
+
return [path, node];
|
|
449
|
+
}
|
|
450
|
+
if (!(node instanceof BranchNode)) {
|
|
451
|
+
throw new Error('Invalid location');
|
|
452
|
+
}
|
|
453
|
+
const [index, ...rest] = location;
|
|
454
|
+
if (index < 0 || index >= node.children.length) {
|
|
455
|
+
throw new Error('Invalid location');
|
|
456
|
+
}
|
|
457
|
+
const child = node.children[index];
|
|
458
|
+
path.push(node);
|
|
459
|
+
return this.getNode(rest, child, path);
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
462
|
//# sourceMappingURL=gridview.js.map
|