dockview-core 5.2.0 → 6.0.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 (117) hide show
  1. package/README.md +3 -1
  2. package/dist/cjs/api/component.api.d.ts +93 -1
  3. package/dist/cjs/api/component.api.js +146 -0
  4. package/dist/cjs/api/dockviewGroupPanelApi.d.ts +26 -0
  5. package/dist/cjs/api/dockviewGroupPanelApi.js +21 -1
  6. package/dist/cjs/api/entryPoints.js +4 -5
  7. package/dist/cjs/array.js +7 -8
  8. package/dist/cjs/dnd/dataTransfer.d.ts +2 -1
  9. package/dist/cjs/dnd/dataTransfer.js +5 -4
  10. package/dist/cjs/dnd/droptarget.d.ts +12 -0
  11. package/dist/cjs/dnd/droptarget.js +38 -10
  12. package/dist/cjs/dnd/ghost.js +1 -2
  13. package/dist/cjs/dockview/components/panel/content.js +5 -1
  14. package/dist/cjs/dockview/components/popupService.d.ts +9 -2
  15. package/dist/cjs/dockview/components/popupService.js +24 -9
  16. package/dist/cjs/dockview/components/tab/tab.d.ts +6 -1
  17. package/dist/cjs/dockview/components/tab/tab.js +81 -9
  18. package/dist/cjs/dockview/components/titlebar/tabGroupChip.d.ts +30 -0
  19. package/dist/cjs/dockview/components/titlebar/tabGroupChip.js +95 -0
  20. package/dist/cjs/dockview/components/titlebar/tabGroupIndicator.d.ts +71 -0
  21. package/dist/cjs/dockview/components/titlebar/tabGroupIndicator.js +471 -0
  22. package/dist/cjs/dockview/components/titlebar/tabGroups.d.ts +57 -0
  23. package/dist/cjs/dockview/components/titlebar/tabGroups.js +612 -0
  24. package/dist/cjs/dockview/components/titlebar/tabOverflowControl.js +1 -2
  25. package/dist/cjs/dockview/components/titlebar/tabs.d.ts +59 -0
  26. package/dist/cjs/dockview/components/titlebar/tabs.js +1227 -144
  27. package/dist/cjs/dockview/components/titlebar/tabsContainer.d.ts +6 -0
  28. package/dist/cjs/dockview/components/titlebar/tabsContainer.js +132 -14
  29. package/dist/cjs/dockview/contextMenu.d.ts +10 -0
  30. package/dist/cjs/dockview/contextMenu.js +298 -0
  31. package/dist/cjs/dockview/dockviewComponent.d.ts +60 -3
  32. package/dist/cjs/dockview/dockviewComponent.js +712 -126
  33. package/dist/cjs/dockview/dockviewGroupPanelModel.d.ts +83 -0
  34. package/dist/cjs/dockview/dockviewGroupPanelModel.js +619 -27
  35. package/dist/cjs/dockview/dockviewShell.d.ts +128 -0
  36. package/dist/cjs/dockview/dockviewShell.js +681 -0
  37. package/dist/cjs/dockview/events.d.ts +9 -0
  38. package/dist/cjs/dockview/framework.d.ts +14 -0
  39. package/dist/cjs/dockview/options.d.ts +92 -10
  40. package/dist/cjs/dockview/options.js +10 -7
  41. package/dist/cjs/dockview/tabGroup.d.ts +99 -0
  42. package/dist/cjs/dockview/tabGroup.js +219 -0
  43. package/dist/cjs/dockview/tabGroupAccent.d.ts +65 -0
  44. package/dist/cjs/dockview/tabGroupAccent.js +128 -0
  45. package/dist/cjs/dockview/theme.d.ts +56 -1
  46. package/dist/cjs/dockview/theme.js +103 -6
  47. package/dist/cjs/dockview/types.d.ts +2 -0
  48. package/dist/cjs/dom.js +19 -19
  49. package/dist/cjs/events.js +2 -2
  50. package/dist/cjs/gridview/baseComponentGridview.d.ts +1 -0
  51. package/dist/cjs/gridview/baseComponentGridview.js +6 -3
  52. package/dist/cjs/gridview/gridview.js +7 -7
  53. package/dist/cjs/index.d.ts +8 -5
  54. package/dist/cjs/index.js +6 -1
  55. package/dist/cjs/popoutWindow.js +3 -3
  56. package/dist/cjs/splitview/splitviewPanel.d.ts +1 -1
  57. package/dist/dockview-core.js +6942 -2777
  58. package/dist/dockview-core.min.js +2 -2
  59. package/dist/dockview-core.min.js.map +1 -1
  60. package/dist/dockview-core.min.noStyle.js +2 -2
  61. package/dist/dockview-core.min.noStyle.js.map +1 -1
  62. package/dist/dockview-core.noStyle.js +6940 -2775
  63. package/dist/esm/api/component.api.d.ts +93 -1
  64. package/dist/esm/api/component.api.js +118 -0
  65. package/dist/esm/api/dockviewGroupPanelApi.d.ts +26 -0
  66. package/dist/esm/api/dockviewGroupPanelApi.js +21 -1
  67. package/dist/esm/dnd/dataTransfer.d.ts +2 -1
  68. package/dist/esm/dnd/dataTransfer.js +2 -1
  69. package/dist/esm/dnd/droptarget.d.ts +12 -0
  70. package/dist/esm/dnd/droptarget.js +33 -5
  71. package/dist/esm/dockview/components/panel/content.js +5 -1
  72. package/dist/esm/dockview/components/popupService.d.ts +9 -2
  73. package/dist/esm/dockview/components/popupService.js +23 -9
  74. package/dist/esm/dockview/components/tab/tab.d.ts +6 -1
  75. package/dist/esm/dockview/components/tab/tab.js +83 -9
  76. package/dist/esm/dockview/components/titlebar/tabGroupChip.d.ts +30 -0
  77. package/dist/esm/dockview/components/titlebar/tabGroupChip.js +68 -0
  78. package/dist/esm/dockview/components/titlebar/tabGroupIndicator.d.ts +71 -0
  79. package/dist/esm/dockview/components/titlebar/tabGroupIndicator.js +354 -0
  80. package/dist/esm/dockview/components/titlebar/tabGroups.d.ts +57 -0
  81. package/dist/esm/dockview/components/titlebar/tabGroups.js +406 -0
  82. package/dist/esm/dockview/components/titlebar/tabs.d.ts +59 -0
  83. package/dist/esm/dockview/components/titlebar/tabs.js +1011 -99
  84. package/dist/esm/dockview/components/titlebar/tabsContainer.d.ts +6 -0
  85. package/dist/esm/dockview/components/titlebar/tabsContainer.js +105 -7
  86. package/dist/esm/dockview/contextMenu.d.ts +10 -0
  87. package/dist/esm/dockview/contextMenu.js +213 -0
  88. package/dist/esm/dockview/dockviewComponent.d.ts +60 -3
  89. package/dist/esm/dockview/dockviewComponent.js +460 -35
  90. package/dist/esm/dockview/dockviewGroupPanelModel.d.ts +83 -0
  91. package/dist/esm/dockview/dockviewGroupPanelModel.js +460 -4
  92. package/dist/esm/dockview/dockviewShell.d.ts +128 -0
  93. package/dist/esm/dockview/dockviewShell.js +621 -0
  94. package/dist/esm/dockview/events.d.ts +9 -0
  95. package/dist/esm/dockview/framework.d.ts +14 -0
  96. package/dist/esm/dockview/options.d.ts +92 -10
  97. package/dist/esm/dockview/options.js +5 -2
  98. package/dist/esm/dockview/tabGroup.d.ts +99 -0
  99. package/dist/esm/dockview/tabGroup.js +144 -0
  100. package/dist/esm/dockview/tabGroupAccent.d.ts +65 -0
  101. package/dist/esm/dockview/tabGroupAccent.js +116 -0
  102. package/dist/esm/dockview/theme.d.ts +56 -1
  103. package/dist/esm/dockview/theme.js +102 -5
  104. package/dist/esm/dockview/types.d.ts +2 -0
  105. package/dist/esm/dom.js +1 -1
  106. package/dist/esm/gridview/baseComponentGridview.d.ts +1 -0
  107. package/dist/esm/gridview/baseComponentGridview.js +4 -1
  108. package/dist/esm/index.d.ts +8 -5
  109. package/dist/esm/index.js +2 -1
  110. package/dist/esm/popoutWindow.js +1 -1
  111. package/dist/esm/splitview/splitviewPanel.d.ts +1 -1
  112. package/dist/package/main.cjs.js +6936 -2801
  113. package/dist/package/main.cjs.min.js +2 -2
  114. package/dist/package/main.esm.min.mjs +2 -2
  115. package/dist/package/main.esm.mjs +6922 -2800
  116. package/dist/styles/dockview.css +1945 -196
  117. package/package.json +5 -1
@@ -0,0 +1,681 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.ShellManager = exports.EdgeGroupView = void 0;
15
+ var events_1 = require("../events");
16
+ var lifecycle_1 = require("../lifecycle");
17
+ var splitview_1 = require("../splitview/splitview");
18
+ var dom_1 = require("../dom");
19
+ var EdgeGroupView = /** @class */ (function () {
20
+ function EdgeGroupView(options, group, orientation) {
21
+ var _a, _b, _c;
22
+ this._onDidChange = new events_1.Emitter();
23
+ this.onDidChange = this._onDidChange.event;
24
+ this.snap = false;
25
+ this.priority = splitview_1.LayoutPriority.Low;
26
+ this._isCollapsed = false;
27
+ this._group = group;
28
+ this._orientation = orientation;
29
+ group.element.classList.add('dv-edge-group');
30
+ group.element.dataset.testid = "dv-edge-group-".concat(options.id);
31
+ this._collapsedSize = (_a = options.collapsedSize) !== null && _a !== void 0 ? _a : 35;
32
+ this._expandedMaximumSize =
33
+ (_b = options.maximumSize) !== null && _b !== void 0 ? _b : Number.POSITIVE_INFINITY;
34
+ // If the caller explicitly provides a minimumSize, respect it.
35
+ // Otherwise fall back to collapsedSize + 50 so the expanded state is
36
+ // visually distinguishable from the collapsed state.
37
+ this._expandedMinimumSize =
38
+ options.minimumSize !== undefined
39
+ ? options.minimumSize
40
+ : this._collapsedSize + 50;
41
+ this._lastExpandedSize = (_c = options.initialSize) !== null && _c !== void 0 ? _c : 200;
42
+ if (options.collapsed) {
43
+ this._isCollapsed = true;
44
+ group.element.classList.add('dv-edge-collapsed');
45
+ }
46
+ }
47
+ Object.defineProperty(EdgeGroupView.prototype, "minimumSize", {
48
+ get: function () {
49
+ // When collapsed, lock size to collapsedSize so sash can't drag it open
50
+ return this._isCollapsed
51
+ ? this._collapsedSize
52
+ : this._expandedMinimumSize;
53
+ },
54
+ enumerable: false,
55
+ configurable: true
56
+ });
57
+ Object.defineProperty(EdgeGroupView.prototype, "maximumSize", {
58
+ get: function () {
59
+ // When collapsed, lock size to collapsedSize so sash can't drag it open
60
+ return this._isCollapsed
61
+ ? this._collapsedSize
62
+ : this._expandedMaximumSize;
63
+ },
64
+ enumerable: false,
65
+ configurable: true
66
+ });
67
+ Object.defineProperty(EdgeGroupView.prototype, "element", {
68
+ get: function () {
69
+ return this._group.element;
70
+ },
71
+ enumerable: false,
72
+ configurable: true
73
+ });
74
+ Object.defineProperty(EdgeGroupView.prototype, "isCollapsed", {
75
+ get: function () {
76
+ return this._isCollapsed;
77
+ },
78
+ enumerable: false,
79
+ configurable: true
80
+ });
81
+ Object.defineProperty(EdgeGroupView.prototype, "lastExpandedSize", {
82
+ get: function () {
83
+ return this._lastExpandedSize;
84
+ },
85
+ enumerable: false,
86
+ configurable: true
87
+ });
88
+ Object.defineProperty(EdgeGroupView.prototype, "collapsedSize", {
89
+ get: function () {
90
+ return this._collapsedSize;
91
+ },
92
+ enumerable: false,
93
+ configurable: true
94
+ });
95
+ EdgeGroupView.prototype.layout = function (size, orthogonalSize) {
96
+ // Track the last expanded size so we can restore it after collapsing
97
+ if (!this._isCollapsed) {
98
+ this._lastExpandedSize = size;
99
+ }
100
+ // horizontal (left/right): size=width, orthogonalSize=height → layout(width, height)
101
+ // vertical (top/bottom): size=height, orthogonalSize=width → layout(width, height)
102
+ if (this._orientation === 'horizontal') {
103
+ this._group.layout(size, orthogonalSize);
104
+ }
105
+ else {
106
+ this._group.layout(orthogonalSize, size);
107
+ }
108
+ };
109
+ EdgeGroupView.prototype.setCollapsed = function (collapsed) {
110
+ if (this._isCollapsed === collapsed) {
111
+ return;
112
+ }
113
+ this._isCollapsed = collapsed;
114
+ this._group.element.classList.toggle('dv-edge-collapsed', collapsed);
115
+ // ShellManager calls resizeView directly after this; no _onDidChange needed
116
+ };
117
+ EdgeGroupView.prototype.setVisible = function (_visible) {
118
+ // visibility is managed by the parent splitview
119
+ };
120
+ /**
121
+ * Restore the last-expanded size from serialized state without triggering
122
+ * a layout. Must be called before setCollapsed(true) during fromJSON so
123
+ * that expanding after deserialization restores the correct size.
124
+ */
125
+ EdgeGroupView.prototype.restoreExpandedSize = function (size) {
126
+ this._lastExpandedSize = size;
127
+ };
128
+ /**
129
+ * Apply new effective collapsed and expanded-minimum sizes after a theme
130
+ * or gap change. The caller (ShellManager) is responsible for computing
131
+ * the correct values from the original config and the new gap.
132
+ */
133
+ EdgeGroupView.prototype.updateCollapsedSize = function (newCollapsedSize, newExpandedMinimumSize) {
134
+ this._collapsedSize = newCollapsedSize;
135
+ this._expandedMinimumSize = newExpandedMinimumSize;
136
+ };
137
+ EdgeGroupView.prototype.dispose = function () {
138
+ this._onDidChange.dispose();
139
+ };
140
+ return EdgeGroupView;
141
+ }());
142
+ exports.EdgeGroupView = EdgeGroupView;
143
+ var CenterView = /** @class */ (function () {
144
+ function CenterView(_dockviewElement, _layoutDockview) {
145
+ this._dockviewElement = _dockviewElement;
146
+ this._layoutDockview = _layoutDockview;
147
+ this.priority = splitview_1.LayoutPriority.High;
148
+ this.minimumSize = 100;
149
+ this.maximumSize = Number.POSITIVE_INFINITY;
150
+ this._onDidChange = new events_1.Emitter();
151
+ this.onDidChange = this._onDidChange.event;
152
+ }
153
+ Object.defineProperty(CenterView.prototype, "element", {
154
+ get: function () {
155
+ return this._dockviewElement;
156
+ },
157
+ enumerable: false,
158
+ configurable: true
159
+ });
160
+ CenterView.prototype.layout = function (size, orthogonalSize) {
161
+ // Lives in a VERTICAL middle-column splitview:
162
+ // size = height alloc, orthogonalSize = width
163
+ this._layoutDockview(orthogonalSize, size);
164
+ };
165
+ CenterView.prototype.setVisible = function (_visible) {
166
+ // center is always visible
167
+ };
168
+ CenterView.prototype.dispose = function () {
169
+ this._onDidChange.dispose();
170
+ };
171
+ return CenterView;
172
+ }());
173
+ /**
174
+ * The vertical centre column: top (optional) | center | bottom (optional).
175
+ * This view sits between the left and right edge panels in the outer
176
+ * horizontal splitview, so its primary axis is width (horizontal).
177
+ */
178
+ var MiddleColumnView = /** @class */ (function () {
179
+ function MiddleColumnView(centerView, gap) {
180
+ if (gap === void 0) { gap = 0; }
181
+ this._onDidChange = new events_1.Emitter();
182
+ this.onDidChange = this._onDidChange.event;
183
+ this.minimumSize = 100;
184
+ this.maximumSize = Number.POSITIVE_INFINITY;
185
+ this.priority = splitview_1.LayoutPriority.High;
186
+ this._element = document.createElement('div');
187
+ this._element.className = 'dv-shell-middle-column';
188
+ this._element.style.height = '100%';
189
+ this._element.style.width = '100%';
190
+ this._splitview = new splitview_1.Splitview(this._element, {
191
+ orientation: splitview_1.Orientation.VERTICAL,
192
+ proportionalLayout: false,
193
+ margin: gap,
194
+ });
195
+ this._centerIndex = 0;
196
+ this._splitview.addView(centerView, { type: 'distribute' }, 0);
197
+ }
198
+ Object.defineProperty(MiddleColumnView.prototype, "element", {
199
+ get: function () {
200
+ return this._element;
201
+ },
202
+ enumerable: false,
203
+ configurable: true
204
+ });
205
+ MiddleColumnView.prototype.addTopView = function (view, initialSize) {
206
+ // Insert before center
207
+ this._splitview.addView(view, initialSize, 0);
208
+ this._topIndex = 0;
209
+ this._centerIndex += 1;
210
+ if (this._bottomIndex !== undefined) {
211
+ this._bottomIndex += 1;
212
+ }
213
+ };
214
+ MiddleColumnView.prototype.addBottomView = function (view, initialSize) {
215
+ // Append after center (and any existing bottom — shouldn't happen but safe)
216
+ var newIndex = this._splitview.length;
217
+ this._splitview.addView(view, initialSize, newIndex);
218
+ this._bottomIndex = newIndex;
219
+ };
220
+ MiddleColumnView.prototype.removeView = function (position) {
221
+ var index = position === 'top' ? this._topIndex : this._bottomIndex;
222
+ if (index === undefined) {
223
+ return;
224
+ }
225
+ this._splitview.removeView(index);
226
+ if (position === 'top') {
227
+ this._topIndex = undefined;
228
+ // center (and bottom if present) shift down by one
229
+ this._centerIndex -= 1;
230
+ if (this._bottomIndex !== undefined) {
231
+ this._bottomIndex -= 1;
232
+ }
233
+ }
234
+ else {
235
+ this._bottomIndex = undefined;
236
+ // center and top are unaffected
237
+ }
238
+ };
239
+ MiddleColumnView.prototype.layout = function (size, orthogonalSize) {
240
+ // Outer horizontal splitview: size = width, orthogonalSize = height
241
+ // Inner vertical splitview: layout(height, width)
242
+ this._splitview.layout(orthogonalSize, size);
243
+ };
244
+ MiddleColumnView.prototype.setVisible = function (_visible) {
245
+ // middle column is always visible
246
+ };
247
+ MiddleColumnView.prototype.setViewVisible = function (position, visible) {
248
+ var index = position === 'top' ? this._topIndex : this._bottomIndex;
249
+ if (index !== undefined) {
250
+ this._splitview.setViewVisible(index, visible);
251
+ }
252
+ };
253
+ MiddleColumnView.prototype.isViewVisible = function (position) {
254
+ var index = position === 'top' ? this._topIndex : this._bottomIndex;
255
+ if (index !== undefined) {
256
+ return this._splitview.isViewVisible(index);
257
+ }
258
+ return false;
259
+ };
260
+ MiddleColumnView.prototype.getViewSize = function (position) {
261
+ var index = position === 'top' ? this._topIndex : this._bottomIndex;
262
+ if (index !== undefined) {
263
+ return this._splitview.getViewSize(index);
264
+ }
265
+ return 0;
266
+ };
267
+ MiddleColumnView.prototype.resizeView = function (position, size) {
268
+ var index = position === 'top' ? this._topIndex : this._bottomIndex;
269
+ if (index !== undefined) {
270
+ this._splitview.resizeView(index, size);
271
+ }
272
+ };
273
+ MiddleColumnView.prototype.updateMargin = function (gap) {
274
+ this._splitview.margin = gap;
275
+ };
276
+ MiddleColumnView.prototype.dispose = function () {
277
+ this._onDidChange.dispose();
278
+ this._splitview.dispose();
279
+ };
280
+ return MiddleColumnView;
281
+ }());
282
+ function adjustedOpts(base, defaultCollapsed, gapAdd) {
283
+ var _a;
284
+ var effectiveCollapsed = ((_a = base.collapsedSize) !== null && _a !== void 0 ? _a : defaultCollapsed) + gapAdd;
285
+ var result = __assign(__assign({}, base), { collapsedSize: effectiveCollapsed });
286
+ if (base.minimumSize !== undefined) {
287
+ result.minimumSize = base.minimumSize + gapAdd;
288
+ }
289
+ return result;
290
+ }
291
+ var ShellManager = /** @class */ (function () {
292
+ function ShellManager(container, dockviewElement, layoutGrid, gap, defaultCollapsedSize) {
293
+ if (gap === void 0) { gap = 0; }
294
+ if (defaultCollapsedSize === void 0) { defaultCollapsedSize = 35; }
295
+ var _this = this;
296
+ this._disposables = new lifecycle_1.CompositeDisposable();
297
+ // Retained for updateTheme() recalculations.
298
+ this._viewConfigs = new Map();
299
+ this._currentWidth = 0;
300
+ this._currentHeight = 0;
301
+ this._gap = gap;
302
+ this._defaultCollapsedSize = defaultCollapsedSize;
303
+ this._shellElement = document.createElement('div');
304
+ this._shellElement.className = 'dv-shell';
305
+ this._shellElement.style.height = '100%';
306
+ this._shellElement.style.width = '100%';
307
+ this._shellElement.style.position = 'relative';
308
+ container.appendChild(this._shellElement);
309
+ var centerView = new CenterView(dockviewElement, layoutGrid);
310
+ this._middleColumn = new MiddleColumnView(centerView, gap);
311
+ this._outerSplitview = new splitview_1.Splitview(this._shellElement, {
312
+ orientation: splitview_1.Orientation.HORIZONTAL,
313
+ proportionalLayout: false,
314
+ margin: gap,
315
+ });
316
+ this._middleIndex = 0;
317
+ this._outerSplitview.addView(this._middleColumn, { type: 'distribute' }, 0);
318
+ this._disposables.addDisposables((0, dom_1.watchElementResize)(this._shellElement, function (entry) {
319
+ var _a = entry.contentRect, width = _a.width, height = _a.height;
320
+ _this._currentWidth = width;
321
+ _this._currentHeight = height;
322
+ _this.layout(width, height);
323
+ }), this._outerSplitview, this._middleColumn, centerView);
324
+ }
325
+ Object.defineProperty(ShellManager.prototype, "element", {
326
+ get: function () {
327
+ return this._shellElement;
328
+ },
329
+ enumerable: false,
330
+ configurable: true
331
+ });
332
+ /**
333
+ * Add an edge group view at the given position. The view wraps the
334
+ * provided group element inside the shell's splitview layout.
335
+ * Throws if a group at this position is already registered.
336
+ */
337
+ ShellManager.prototype.addEdgeView = function (position, options, group) {
338
+ if (this.hasEdgeGroup(position)) {
339
+ throw new Error("dockview: edge group already registered at position '".concat(position, "'"));
340
+ }
341
+ this._viewConfigs.set(position, options);
342
+ // Recompute gap adjustments now that _viewConfigs has grown.
343
+ var outerN = 1 +
344
+ (this._viewConfigs.has('left') ? 1 : 0) +
345
+ (this._viewConfigs.has('right') ? 1 : 0);
346
+ var innerN = 1 +
347
+ (this._viewConfigs.has('top') ? 1 : 0) +
348
+ (this._viewConfigs.has('bottom') ? 1 : 0);
349
+ var outerGapAdd = outerN > 1 ? (this._gap * (outerN - 1)) / outerN : 0;
350
+ var innerGapAdd = innerN > 1 ? (this._gap * (innerN - 1)) / innerN : 0;
351
+ var isHorizontal = position === 'left' || position === 'right';
352
+ var gapAdd = isHorizontal ? outerGapAdd : innerGapAdd;
353
+ var orientation = isHorizontal ? 'horizontal' : 'vertical';
354
+ var view = new EdgeGroupView(adjustedOpts(__assign({ collapsedSize: this._defaultCollapsedSize }, options), this._defaultCollapsedSize, gapAdd), group, orientation);
355
+ var initialSize = view.isCollapsed
356
+ ? view.collapsedSize
357
+ : view.lastExpandedSize;
358
+ switch (position) {
359
+ case 'left':
360
+ // Insert before the middle column
361
+ this._outerSplitview.addView(view, initialSize, 0);
362
+ this._leftIndex = 0;
363
+ this._middleIndex += 1;
364
+ if (this._rightIndex !== undefined) {
365
+ this._rightIndex += 1;
366
+ }
367
+ this._leftView = view;
368
+ break;
369
+ case 'right':
370
+ // Append after the middle column
371
+ {
372
+ var idx = this._outerSplitview.length;
373
+ this._outerSplitview.addView(view, initialSize, idx);
374
+ this._rightIndex = idx;
375
+ this._rightView = view;
376
+ }
377
+ break;
378
+ case 'top':
379
+ this._middleColumn.addTopView(view, initialSize);
380
+ this._topView = view;
381
+ break;
382
+ case 'bottom':
383
+ this._middleColumn.addBottomView(view, initialSize);
384
+ this._bottomView = view;
385
+ break;
386
+ }
387
+ this._disposables.addDisposables(view);
388
+ // Recalculate gap adjustments for all views now that n has changed.
389
+ // updateTheme already guards the layout() call by _currentWidth/_currentHeight.
390
+ this.updateTheme(this._gap, this._defaultCollapsedSize);
391
+ return view;
392
+ };
393
+ ShellManager.prototype.layout = function (width, height) {
394
+ // Outer splitview is HORIZONTAL: layout(size=width, orthogonalSize=height)
395
+ this._outerSplitview.layout(width, height);
396
+ };
397
+ /**
398
+ * Called when the active theme changes. Updates splitview margins and
399
+ * edge-group collapsed sizes so the layout matches the new theme's gap
400
+ * and tab-strip dimensions.
401
+ */
402
+ ShellManager.prototype.updateTheme = function (gap, defaultCollapsedSize) {
403
+ var _a, _b, _c, _d;
404
+ this._gap = gap;
405
+ this._defaultCollapsedSize = defaultCollapsedSize;
406
+ var outerN = 1 +
407
+ (this._viewConfigs.has('left') ? 1 : 0) +
408
+ (this._viewConfigs.has('right') ? 1 : 0);
409
+ var innerN = 1 +
410
+ (this._viewConfigs.has('top') ? 1 : 0) +
411
+ (this._viewConfigs.has('bottom') ? 1 : 0);
412
+ var outerGapAdd = outerN > 1 ? (gap * (outerN - 1)) / outerN : 0;
413
+ var innerGapAdd = innerN > 1 ? (gap * (innerN - 1)) / innerN : 0;
414
+ // Update splitview margins.
415
+ this._outerSplitview.margin = gap;
416
+ this._middleColumn.updateMargin(gap);
417
+ // Recompute effective collapsed sizes from the original config values.
418
+ var updateView = function (view, baseCfg, gapAdd) {
419
+ var _a;
420
+ var baseCS = (_a = baseCfg.collapsedSize) !== null && _a !== void 0 ? _a : defaultCollapsedSize;
421
+ var newCS = baseCS + gapAdd;
422
+ var baseMS = baseCfg.minimumSize;
423
+ var newMS = baseMS !== undefined ? baseMS + gapAdd : newCS + 50;
424
+ view.updateCollapsedSize(newCS, newMS);
425
+ };
426
+ var topCfg = this._viewConfigs.get('top');
427
+ if (this._topView && topCfg) {
428
+ updateView(this._topView, topCfg, innerGapAdd);
429
+ }
430
+ var bottomCfg = this._viewConfigs.get('bottom');
431
+ if (this._bottomView && bottomCfg) {
432
+ updateView(this._bottomView, bottomCfg, innerGapAdd);
433
+ }
434
+ var leftCfg = this._viewConfigs.get('left');
435
+ if (this._leftView && leftCfg) {
436
+ updateView(this._leftView, leftCfg, outerGapAdd);
437
+ }
438
+ var rightCfg = this._viewConfigs.get('right');
439
+ if (this._rightView && rightCfg) {
440
+ updateView(this._rightView, rightCfg, outerGapAdd);
441
+ }
442
+ // Resize currently-collapsed groups to their new collapsed size so
443
+ // they immediately match the new theme's tab-strip dimensions.
444
+ if (((_a = this._leftView) === null || _a === void 0 ? void 0 : _a.isCollapsed) && this._leftIndex !== undefined) {
445
+ this._outerSplitview.resizeView(this._leftIndex, this._leftView.collapsedSize);
446
+ }
447
+ if (((_b = this._rightView) === null || _b === void 0 ? void 0 : _b.isCollapsed) && this._rightIndex !== undefined) {
448
+ this._outerSplitview.resizeView(this._rightIndex, this._rightView.collapsedSize);
449
+ }
450
+ if ((_c = this._topView) === null || _c === void 0 ? void 0 : _c.isCollapsed) {
451
+ this._middleColumn.resizeView('top', this._topView.collapsedSize);
452
+ }
453
+ if ((_d = this._bottomView) === null || _d === void 0 ? void 0 : _d.isCollapsed) {
454
+ this._middleColumn.resizeView('bottom', this._bottomView.collapsedSize);
455
+ }
456
+ // Re-run layout with the current shell dimensions.
457
+ if (this._currentWidth > 0 && this._currentHeight > 0) {
458
+ this.layout(this._currentWidth, this._currentHeight);
459
+ }
460
+ };
461
+ ShellManager.prototype.removeEdgeView = function (position) {
462
+ var view = this._getView(position);
463
+ if (!view) {
464
+ return;
465
+ }
466
+ switch (position) {
467
+ case 'left':
468
+ this._outerSplitview.removeView(this._leftIndex);
469
+ this._leftIndex = undefined;
470
+ this._leftView = undefined;
471
+ // middle and right shift left by one
472
+ this._middleIndex -= 1;
473
+ if (this._rightIndex !== undefined) {
474
+ this._rightIndex -= 1;
475
+ }
476
+ break;
477
+ case 'right':
478
+ this._outerSplitview.removeView(this._rightIndex);
479
+ this._rightIndex = undefined;
480
+ this._rightView = undefined;
481
+ break;
482
+ case 'top':
483
+ this._middleColumn.removeView('top');
484
+ this._topView = undefined;
485
+ break;
486
+ case 'bottom':
487
+ this._middleColumn.removeView('bottom');
488
+ this._bottomView = undefined;
489
+ break;
490
+ }
491
+ // Deregister before disposing to avoid double-dispose when ShellManager
492
+ // itself is eventually disposed.
493
+ this._disposables.removeDisposable(view);
494
+ view.dispose();
495
+ this._viewConfigs.delete(position);
496
+ // Recalculate gap adjustments for remaining views.
497
+ this.updateTheme(this._gap, this._defaultCollapsedSize);
498
+ };
499
+ ShellManager.prototype.hasEdgeGroup = function (position) {
500
+ switch (position) {
501
+ case 'top':
502
+ return this._topView !== undefined;
503
+ case 'bottom':
504
+ return this._bottomView !== undefined;
505
+ case 'left':
506
+ return this._leftView !== undefined;
507
+ case 'right':
508
+ return this._rightView !== undefined;
509
+ }
510
+ };
511
+ ShellManager.prototype.setEdgeGroupVisible = function (position, visible) {
512
+ switch (position) {
513
+ case 'left':
514
+ if (this._leftIndex !== undefined) {
515
+ this._outerSplitview.setViewVisible(this._leftIndex, visible);
516
+ }
517
+ break;
518
+ case 'right':
519
+ if (this._rightIndex !== undefined) {
520
+ this._outerSplitview.setViewVisible(this._rightIndex, visible);
521
+ }
522
+ break;
523
+ case 'top':
524
+ case 'bottom':
525
+ this._middleColumn.setViewVisible(position, visible);
526
+ break;
527
+ }
528
+ };
529
+ ShellManager.prototype.isEdgeGroupVisible = function (position) {
530
+ switch (position) {
531
+ case 'left':
532
+ if (this._leftIndex !== undefined) {
533
+ return this._outerSplitview.isViewVisible(this._leftIndex);
534
+ }
535
+ return false;
536
+ case 'right':
537
+ if (this._rightIndex !== undefined) {
538
+ return this._outerSplitview.isViewVisible(this._rightIndex);
539
+ }
540
+ return false;
541
+ case 'top':
542
+ case 'bottom':
543
+ return this._middleColumn.isViewVisible(position);
544
+ }
545
+ };
546
+ ShellManager.prototype.setEdgeGroupCollapsed = function (position, collapsed) {
547
+ var view = this._getView(position);
548
+ if (!view) {
549
+ return;
550
+ }
551
+ view.setCollapsed(collapsed);
552
+ var targetSize = collapsed
553
+ ? view.collapsedSize
554
+ : view.lastExpandedSize;
555
+ switch (position) {
556
+ case 'left':
557
+ if (this._leftIndex !== undefined) {
558
+ this._outerSplitview.resizeView(this._leftIndex, targetSize);
559
+ }
560
+ break;
561
+ case 'right':
562
+ if (this._rightIndex !== undefined) {
563
+ this._outerSplitview.resizeView(this._rightIndex, targetSize);
564
+ }
565
+ break;
566
+ case 'top':
567
+ case 'bottom':
568
+ this._middleColumn.resizeView(position, targetSize);
569
+ break;
570
+ }
571
+ };
572
+ ShellManager.prototype.isEdgeGroupCollapsed = function (position) {
573
+ var _a, _b;
574
+ return (_b = (_a = this._getView(position)) === null || _a === void 0 ? void 0 : _a.isCollapsed) !== null && _b !== void 0 ? _b : false;
575
+ };
576
+ ShellManager.prototype._getView = function (position) {
577
+ switch (position) {
578
+ case 'top':
579
+ return this._topView;
580
+ case 'bottom':
581
+ return this._bottomView;
582
+ case 'left':
583
+ return this._leftView;
584
+ case 'right':
585
+ return this._rightView;
586
+ }
587
+ };
588
+ ShellManager.prototype.toJSON = function () {
589
+ var edgeGroups = {};
590
+ if (this._leftView && this._leftIndex !== undefined) {
591
+ edgeGroups.left = {
592
+ size: this._leftView.isCollapsed
593
+ ? this._leftView.lastExpandedSize
594
+ : this._outerSplitview.getViewSize(this._leftIndex),
595
+ visible: this._outerSplitview.isViewVisible(this._leftIndex),
596
+ collapsed: this._leftView.isCollapsed || undefined,
597
+ };
598
+ }
599
+ if (this._rightView && this._rightIndex !== undefined) {
600
+ edgeGroups.right = {
601
+ size: this._rightView.isCollapsed
602
+ ? this._rightView.lastExpandedSize
603
+ : this._outerSplitview.getViewSize(this._rightIndex),
604
+ visible: this._outerSplitview.isViewVisible(this._rightIndex),
605
+ collapsed: this._rightView.isCollapsed || undefined,
606
+ };
607
+ }
608
+ if (this._topView) {
609
+ edgeGroups.top = {
610
+ size: this._topView.isCollapsed
611
+ ? this._topView.lastExpandedSize
612
+ : this._middleColumn.getViewSize('top'),
613
+ visible: this._middleColumn.isViewVisible('top'),
614
+ collapsed: this._topView.isCollapsed || undefined,
615
+ };
616
+ }
617
+ if (this._bottomView) {
618
+ edgeGroups.bottom = {
619
+ size: this._bottomView.isCollapsed
620
+ ? this._bottomView.lastExpandedSize
621
+ : this._middleColumn.getViewSize('bottom'),
622
+ visible: this._middleColumn.isViewVisible('bottom'),
623
+ collapsed: this._bottomView.isCollapsed || undefined,
624
+ };
625
+ }
626
+ return edgeGroups;
627
+ };
628
+ ShellManager.prototype.fromJSON = function (data) {
629
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
630
+ if (data.left && this._leftIndex !== undefined) {
631
+ // Always restore the expanded size first. toJSON always records the
632
+ // expanded size (even when collapsed), so restoredExpandedSize must
633
+ // be applied before setCollapsed locks min/max to collapsedSize.
634
+ (_a = this._leftView) === null || _a === void 0 ? void 0 : _a.restoreExpandedSize(data.left.size);
635
+ (_b = this._leftView) === null || _b === void 0 ? void 0 : _b.setCollapsed((_c = data.left.collapsed) !== null && _c !== void 0 ? _c : false);
636
+ this._outerSplitview.resizeView(this._leftIndex, data.left.collapsed
637
+ ? ((_e = (_d = this._leftView) === null || _d === void 0 ? void 0 : _d.collapsedSize) !== null && _e !== void 0 ? _e : data.left.size)
638
+ : data.left.size);
639
+ if (!data.left.visible) {
640
+ this._outerSplitview.setViewVisible(this._leftIndex, false);
641
+ }
642
+ }
643
+ if (data.right && this._rightIndex !== undefined) {
644
+ (_f = this._rightView) === null || _f === void 0 ? void 0 : _f.restoreExpandedSize(data.right.size);
645
+ (_g = this._rightView) === null || _g === void 0 ? void 0 : _g.setCollapsed((_h = data.right.collapsed) !== null && _h !== void 0 ? _h : false);
646
+ this._outerSplitview.resizeView(this._rightIndex, data.right.collapsed
647
+ ? ((_k = (_j = this._rightView) === null || _j === void 0 ? void 0 : _j.collapsedSize) !== null && _k !== void 0 ? _k : data.right.size)
648
+ : data.right.size);
649
+ if (!data.right.visible) {
650
+ this._outerSplitview.setViewVisible(this._rightIndex, false);
651
+ }
652
+ }
653
+ if (data.top) {
654
+ (_l = this._topView) === null || _l === void 0 ? void 0 : _l.restoreExpandedSize(data.top.size);
655
+ (_m = this._topView) === null || _m === void 0 ? void 0 : _m.setCollapsed((_o = data.top.collapsed) !== null && _o !== void 0 ? _o : false);
656
+ this._middleColumn.resizeView('top', data.top.collapsed
657
+ ? ((_q = (_p = this._topView) === null || _p === void 0 ? void 0 : _p.collapsedSize) !== null && _q !== void 0 ? _q : data.top.size)
658
+ : data.top.size);
659
+ if (!data.top.visible) {
660
+ this._middleColumn.setViewVisible('top', false);
661
+ }
662
+ }
663
+ if (data.bottom) {
664
+ (_r = this._bottomView) === null || _r === void 0 ? void 0 : _r.restoreExpandedSize(data.bottom.size);
665
+ (_s = this._bottomView) === null || _s === void 0 ? void 0 : _s.setCollapsed((_t = data.bottom.collapsed) !== null && _t !== void 0 ? _t : false);
666
+ this._middleColumn.resizeView('bottom', data.bottom.collapsed
667
+ ? ((_v = (_u = this._bottomView) === null || _u === void 0 ? void 0 : _u.collapsedSize) !== null && _v !== void 0 ? _v : data.bottom.size)
668
+ : data.bottom.size);
669
+ if (!data.bottom.visible) {
670
+ this._middleColumn.setViewVisible('bottom', false);
671
+ }
672
+ }
673
+ };
674
+ ShellManager.prototype.dispose = function () {
675
+ var _a;
676
+ this._disposables.dispose();
677
+ (_a = this._shellElement.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(this._shellElement);
678
+ };
679
+ return ShellManager;
680
+ }());
681
+ exports.ShellManager = ShellManager;