dockview-core 1.14.2 → 1.15.1

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 (76) hide show
  1. package/dist/cjs/api/component.api.d.ts +5 -5
  2. package/dist/cjs/api/component.api.js +19 -2
  3. package/dist/cjs/constants.d.ts +2 -0
  4. package/dist/cjs/constants.js +1 -1
  5. package/dist/cjs/dnd/overlay.d.ts +6 -4
  6. package/dist/cjs/dnd/overlay.js +119 -28
  7. package/dist/cjs/dockview/components/titlebar/tabsContainer.js +4 -2
  8. package/dist/cjs/dockview/dockviewComponent.d.ts +24 -17
  9. package/dist/cjs/dockview/dockviewComponent.js +104 -47
  10. package/dist/cjs/dockview/dockviewFloatingGroupPanel.d.ts +3 -12
  11. package/dist/cjs/dockview/options.d.ts +10 -6
  12. package/dist/cjs/dockview/options.js +1 -0
  13. package/dist/cjs/dom.d.ts +1 -0
  14. package/dist/cjs/dom.js +5 -1
  15. package/dist/cjs/gridview/baseComponentGridview.d.ts +3 -0
  16. package/dist/cjs/gridview/baseComponentGridview.js +8 -2
  17. package/dist/cjs/gridview/branchNode.d.ts +7 -3
  18. package/dist/cjs/gridview/branchNode.js +24 -29
  19. package/dist/cjs/gridview/gridview.d.ts +7 -1
  20. package/dist/cjs/gridview/gridview.js +31 -8
  21. package/dist/cjs/gridview/gridviewPanel.d.ts +1 -0
  22. package/dist/cjs/gridview/gridviewPanel.js +7 -0
  23. package/dist/cjs/math.js +5 -1
  24. package/dist/cjs/splitview/splitview.d.ts +13 -0
  25. package/dist/cjs/splitview/splitview.js +42 -12
  26. package/dist/cjs/types.d.ts +23 -0
  27. package/dist/dockview-core.amd.js +328 -112
  28. package/dist/dockview-core.amd.js.map +1 -1
  29. package/dist/dockview-core.amd.min.js +2 -2
  30. package/dist/dockview-core.amd.min.js.map +1 -1
  31. package/dist/dockview-core.amd.min.noStyle.js +2 -2
  32. package/dist/dockview-core.amd.min.noStyle.js.map +1 -1
  33. package/dist/dockview-core.amd.noStyle.js +327 -111
  34. package/dist/dockview-core.amd.noStyle.js.map +1 -1
  35. package/dist/dockview-core.cjs.js +328 -112
  36. package/dist/dockview-core.cjs.js.map +1 -1
  37. package/dist/dockview-core.esm.js +328 -112
  38. package/dist/dockview-core.esm.js.map +1 -1
  39. package/dist/dockview-core.esm.min.js +2 -2
  40. package/dist/dockview-core.esm.min.js.map +1 -1
  41. package/dist/dockview-core.js +328 -112
  42. package/dist/dockview-core.js.map +1 -1
  43. package/dist/dockview-core.min.js +2 -2
  44. package/dist/dockview-core.min.js.map +1 -1
  45. package/dist/dockview-core.min.noStyle.js +2 -2
  46. package/dist/dockview-core.min.noStyle.js.map +1 -1
  47. package/dist/dockview-core.noStyle.js +327 -111
  48. package/dist/dockview-core.noStyle.js.map +1 -1
  49. package/dist/esm/api/component.api.d.ts +5 -5
  50. package/dist/esm/api/component.api.js +11 -2
  51. package/dist/esm/constants.d.ts +2 -0
  52. package/dist/esm/constants.js +1 -1
  53. package/dist/esm/dnd/overlay.d.ts +6 -4
  54. package/dist/esm/dnd/overlay.js +108 -28
  55. package/dist/esm/dockview/components/titlebar/tabsContainer.js +4 -2
  56. package/dist/esm/dockview/dockviewComponent.d.ts +24 -17
  57. package/dist/esm/dockview/dockviewComponent.js +101 -48
  58. package/dist/esm/dockview/dockviewFloatingGroupPanel.d.ts +3 -12
  59. package/dist/esm/dockview/options.d.ts +10 -6
  60. package/dist/esm/dockview/options.js +1 -0
  61. package/dist/esm/dom.d.ts +1 -0
  62. package/dist/esm/dom.js +3 -0
  63. package/dist/esm/gridview/baseComponentGridview.d.ts +3 -0
  64. package/dist/esm/gridview/baseComponentGridview.js +6 -2
  65. package/dist/esm/gridview/branchNode.d.ts +7 -3
  66. package/dist/esm/gridview/branchNode.js +19 -7
  67. package/dist/esm/gridview/gridview.d.ts +7 -1
  68. package/dist/esm/gridview/gridview.js +27 -8
  69. package/dist/esm/gridview/gridviewPanel.d.ts +1 -0
  70. package/dist/esm/gridview/gridviewPanel.js +3 -0
  71. package/dist/esm/math.js +5 -1
  72. package/dist/esm/splitview/splitview.d.ts +13 -0
  73. package/dist/esm/splitview/splitview.js +38 -12
  74. package/dist/esm/types.d.ts +23 -0
  75. package/dist/styles/dockview.css +0 -13
  76. package/package.json +1 -1
@@ -138,6 +138,7 @@ var DockviewComponent = /** @class */ (function (_super) {
138
138
  parentElement: options.parentElement,
139
139
  disableAutoResizing: options.disableAutoResizing,
140
140
  locked: options.locked,
141
+ margin: options.gap,
141
142
  }) || this;
142
143
  _this.nextGroupId = (0, math_1.sequentialNumberGenerator)();
143
144
  _this._deserializer = new deserializer_1.DefaultDockviewDeserialzier(_this);
@@ -163,9 +164,9 @@ var DockviewComponent = /** @class */ (function (_super) {
163
164
  _this._onDidActivePanelChange = new events_1.Emitter();
164
165
  _this.onDidActivePanelChange = _this._onDidActivePanelChange.event;
165
166
  _this._onDidMovePanel = new events_1.Emitter();
167
+ _this.onDidMovePanel = _this._onDidMovePanel.event;
166
168
  _this._floatingGroups = [];
167
169
  _this._popoutGroups = [];
168
- _this._ignoreEvents = 0;
169
170
  _this._onDidRemoveGroup = new events_1.Emitter();
170
171
  _this.onDidRemoveGroup = _this._onDidRemoveGroup.event;
171
172
  _this._onDidAddGroup = new events_1.Emitter();
@@ -179,7 +180,9 @@ var DockviewComponent = /** @class */ (function (_super) {
179
180
  _this.overlayRenderContainer = new overlayRenderContainer_1.OverlayRenderContainer(gready);
180
181
  (0, dom_1.toggleClass)(_this.gridview.element, 'dv-dockview', true);
181
182
  (0, dom_1.toggleClass)(_this.element, 'dv-debug', !!options.debug);
182
- _this.addDisposables(_this.overlayRenderContainer, _this._onWillDragPanel, _this._onWillDragGroup, _this._onWillShowOverlay, _this._onDidActivePanelChange, _this._onDidAddPanel, _this._onDidRemovePanel, _this._onDidLayoutFromJSON, _this._onDidDrop, _this._onWillDrop, _this._onDidMovePanel, _this._onDidAddGroup, _this._onDidRemoveGroup, _this._onDidActiveGroupChange, _this._onUnhandledDragOverEvent, _this.onDidAdd(function (event) {
183
+ _this.addDisposables(_this.overlayRenderContainer, _this._onWillDragPanel, _this._onWillDragGroup, _this._onWillShowOverlay, _this._onDidActivePanelChange, _this._onDidAddPanel, _this._onDidRemovePanel, _this._onDidLayoutFromJSON, _this._onDidDrop, _this._onWillDrop, _this._onDidMovePanel, _this._onDidAddGroup, _this._onDidRemoveGroup, _this._onDidActiveGroupChange, _this._onUnhandledDragOverEvent, _this.onDidViewVisibilityChangeMicroTaskQueue(function () {
184
+ _this.updateWatermark();
185
+ }), _this.onDidAdd(function (event) {
183
186
  if (!_this._moving) {
184
187
  _this._onDidAddGroup.fire(event);
185
188
  }
@@ -193,7 +196,7 @@ var DockviewComponent = /** @class */ (function (_super) {
193
196
  }
194
197
  }), events_1.Event.any(_this.onDidAdd, _this.onDidRemove)(function () {
195
198
  _this.updateWatermark();
196
- }), events_1.Event.any(_this.onDidAddPanel, _this.onDidRemovePanel, _this.onDidActivePanelChange)(function () {
199
+ }), events_1.Event.any(_this.onDidAddPanel, _this.onDidRemovePanel, _this.onDidAddGroup, _this.onDidRemove, _this.onDidMovePanel, _this.onDidActivePanelChange)(function () {
197
200
  _this._bufferOnDidLayoutChange.fire();
198
201
  }), lifecycle_1.Disposable.from(function () {
199
202
  var e_1, _a, e_2, _b;
@@ -365,12 +368,19 @@ var DockviewComponent = /** @class */ (function (_super) {
365
368
  enumerable: false,
366
369
  configurable: true
367
370
  });
371
+ Object.defineProperty(DockviewComponent.prototype, "gap", {
372
+ get: function () {
373
+ return this.gridview.margin;
374
+ },
375
+ enumerable: false,
376
+ configurable: true
377
+ });
368
378
  DockviewComponent.prototype.addPopoutGroup = function (itemToPopout, options) {
369
379
  var _this = this;
370
380
  var _a, _b, _c;
371
381
  if (itemToPopout instanceof dockviewPanel_1.DockviewPanel &&
372
382
  itemToPopout.group.size === 1) {
373
- return this.addPopoutGroup(itemToPopout.group);
383
+ return this.addPopoutGroup(itemToPopout.group, options);
374
384
  }
375
385
  var theme = getDockviewTheme(this.gridview.element);
376
386
  var element = this.element;
@@ -525,9 +535,9 @@ var DockviewComponent = /** @class */ (function (_super) {
525
535
  console.error('dockview: failed to create popout window', err);
526
536
  });
527
537
  };
528
- DockviewComponent.prototype.addFloatingGroup = function (item, coord, options) {
538
+ DockviewComponent.prototype.addFloatingGroup = function (item, options) {
529
539
  var _this = this;
530
- var _a, _b, _c, _d, _e, _f, _g;
540
+ var _a, _b, _c, _d, _e;
531
541
  var group;
532
542
  if (item instanceof dockviewPanel_1.DockviewPanel) {
533
543
  group = this.createGroup();
@@ -578,26 +588,62 @@ var DockviewComponent = /** @class */ (function (_super) {
578
588
  }
579
589
  }
580
590
  group.model.location = { type: 'floating' };
581
- var overlayLeft = typeof (coord === null || coord === void 0 ? void 0 : coord.x) === 'number'
582
- ? Math.max(coord.x, 0)
583
- : constants_1.DEFAULT_FLOATING_GROUP_POSITION.left;
584
- var overlayTop = typeof (coord === null || coord === void 0 ? void 0 : coord.y) === 'number'
585
- ? Math.max(coord.y, 0)
586
- : constants_1.DEFAULT_FLOATING_GROUP_POSITION.top;
587
- var overlay = new overlay_1.Overlay({
588
- container: this.gridview.element,
589
- content: group.element,
590
- height: (_b = coord === null || coord === void 0 ? void 0 : coord.height) !== null && _b !== void 0 ? _b : 300,
591
- width: (_c = coord === null || coord === void 0 ? void 0 : coord.width) !== null && _c !== void 0 ? _c : 300,
592
- left: overlayLeft,
593
- top: overlayTop,
594
- minimumInViewportWidth: this.options.floatingGroupBounds === 'boundedWithinViewport'
591
+ function getAnchoredBox() {
592
+ if (options === null || options === void 0 ? void 0 : options.position) {
593
+ var result = {};
594
+ if ('left' in options.position) {
595
+ result.left = Math.max(options.position.left, 0);
596
+ }
597
+ else if ('right' in options.position) {
598
+ result.right = Math.max(options.position.right, 0);
599
+ }
600
+ else {
601
+ result.left = constants_1.DEFAULT_FLOATING_GROUP_POSITION.left;
602
+ }
603
+ if ('top' in options.position) {
604
+ result.top = Math.max(options.position.top, 0);
605
+ }
606
+ else if ('bottom' in options.position) {
607
+ result.bottom = Math.max(options.position.bottom, 0);
608
+ }
609
+ else {
610
+ result.top = constants_1.DEFAULT_FLOATING_GROUP_POSITION.top;
611
+ }
612
+ if (typeof options.width === 'number') {
613
+ result.width = Math.max(options.width, 0);
614
+ }
615
+ else {
616
+ result.width = constants_1.DEFAULT_FLOATING_GROUP_POSITION.width;
617
+ }
618
+ if (typeof options.height === 'number') {
619
+ result.height = Math.max(options.height, 0);
620
+ }
621
+ else {
622
+ result.height = constants_1.DEFAULT_FLOATING_GROUP_POSITION.height;
623
+ }
624
+ return result;
625
+ }
626
+ return {
627
+ left: typeof (options === null || options === void 0 ? void 0 : options.x) === 'number'
628
+ ? Math.max(options.x, 0)
629
+ : constants_1.DEFAULT_FLOATING_GROUP_POSITION.left,
630
+ top: typeof (options === null || options === void 0 ? void 0 : options.y) === 'number'
631
+ ? Math.max(options.y, 0)
632
+ : constants_1.DEFAULT_FLOATING_GROUP_POSITION.top,
633
+ width: typeof (options === null || options === void 0 ? void 0 : options.width) === 'number'
634
+ ? Math.max(options.width, 0)
635
+ : constants_1.DEFAULT_FLOATING_GROUP_POSITION.width,
636
+ height: typeof (options === null || options === void 0 ? void 0 : options.height) === 'number'
637
+ ? Math.max(options.height, 0)
638
+ : constants_1.DEFAULT_FLOATING_GROUP_POSITION.height,
639
+ };
640
+ }
641
+ var anchoredBox = getAnchoredBox();
642
+ var overlay = new overlay_1.Overlay(__assign(__assign({ container: this.gridview.element, content: group.element }, anchoredBox), { minimumInViewportWidth: this.options.floatingGroupBounds === 'boundedWithinViewport'
595
643
  ? undefined
596
- : (_e = (_d = this.options.floatingGroupBounds) === null || _d === void 0 ? void 0 : _d.minimumWidthWithinViewport) !== null && _e !== void 0 ? _e : constants_1.DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE,
597
- minimumInViewportHeight: this.options.floatingGroupBounds === 'boundedWithinViewport'
644
+ : (_c = (_b = this.options.floatingGroupBounds) === null || _b === void 0 ? void 0 : _b.minimumWidthWithinViewport) !== null && _c !== void 0 ? _c : constants_1.DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE, minimumInViewportHeight: this.options.floatingGroupBounds === 'boundedWithinViewport'
598
645
  ? undefined
599
- : (_g = (_f = this.options.floatingGroupBounds) === null || _f === void 0 ? void 0 : _f.minimumHeightWithinViewport) !== null && _g !== void 0 ? _g : constants_1.DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE,
600
- });
646
+ : (_e = (_d = this.options.floatingGroupBounds) === null || _d === void 0 ? void 0 : _d.minimumHeightWithinViewport) !== null && _e !== void 0 ? _e : constants_1.DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE }));
601
647
  var el = group.element.querySelector('.void-container');
602
648
  if (!el) {
603
649
  throw new Error('failed to find drag handle');
@@ -700,7 +746,7 @@ var DockviewComponent = /** @class */ (function (_super) {
700
746
  group.overlay.minimumInViewportWidth =
701
747
  (_c = this.options.floatingGroupBounds) === null || _c === void 0 ? void 0 : _c.minimumWidthWithinViewport;
702
748
  }
703
- group.overlay.setBounds({});
749
+ group.overlay.setBounds();
704
750
  }
705
751
  }
706
752
  catch (e_3_1) { e_3 = { error: e_3_1 }; }
@@ -714,6 +760,15 @@ var DockviewComponent = /** @class */ (function (_super) {
714
760
  if (changed_rootOverlayOptions) {
715
761
  this._rootDropTarget.setOverlayModel(options.rootOverlayModel);
716
762
  }
763
+ if (
764
+ // if explicitly set as `undefined`
765
+ 'gap' in options &&
766
+ options.gap === undefined) {
767
+ this.gridview.margin = 0;
768
+ }
769
+ if (typeof options.gap === 'number') {
770
+ this.gridview.margin = options.gap;
771
+ }
717
772
  this.layout(this.gridview.width, this.gridview.height, true);
718
773
  };
719
774
  DockviewComponent.prototype.layout = function (width, height, forceResize) {
@@ -903,11 +958,10 @@ var DockviewComponent = /** @class */ (function (_super) {
903
958
  var data_1 = serializedFloatingGroup.data, position = serializedFloatingGroup.position;
904
959
  var group = createGroupFromSerializedState_1(data_1);
905
960
  this.addFloatingGroup(group, {
906
- x: position.left,
907
- y: position.top,
908
- height: position.height,
909
- width: position.width,
910
- }, { skipRemoveGroup: true, inDragMode: false });
961
+ position: position,
962
+ skipRemoveGroup: true,
963
+ inDragMode: false,
964
+ });
911
965
  }
912
966
  }
913
967
  catch (e_5_1) { e_5 = { error: e_5_1 }; }
@@ -1128,15 +1182,11 @@ var DockviewComponent = /** @class */ (function (_super) {
1128
1182
  if (options.floating) {
1129
1183
  var group = this.createGroup();
1130
1184
  this._onDidAddGroup.fire(group);
1131
- var o = typeof options.floating === 'object' &&
1185
+ var floatingGroupOptions = typeof options.floating === 'object' &&
1132
1186
  options.floating !== null
1133
1187
  ? options.floating
1134
1188
  : {};
1135
- this.addFloatingGroup(group, o, {
1136
- inDragMode: false,
1137
- skipRemoveGroup: true,
1138
- skipActiveGroup: true,
1139
- });
1189
+ this.addFloatingGroup(group, __assign(__assign({}, floatingGroupOptions), { inDragMode: false, skipRemoveGroup: true, skipActiveGroup: true }));
1140
1190
  panel = this.createPanel(options, group);
1141
1191
  group.model.openPanel(panel, {
1142
1192
  skipSetActive: options.inactive,
@@ -1175,11 +1225,7 @@ var DockviewComponent = /** @class */ (function (_super) {
1175
1225
  options.floating !== null
1176
1226
  ? options.floating
1177
1227
  : {};
1178
- this.addFloatingGroup(group, coordinates, {
1179
- inDragMode: false,
1180
- skipRemoveGroup: true,
1181
- skipActiveGroup: true,
1182
- });
1228
+ this.addFloatingGroup(group, __assign(__assign({}, coordinates), { inDragMode: false, skipRemoveGroup: true, skipActiveGroup: true }));
1183
1229
  panel = this.createPanel(options, group);
1184
1230
  group.model.openPanel(panel, {
1185
1231
  skipSetActive: options.inactive,
@@ -1235,6 +1281,7 @@ var DockviewComponent = /** @class */ (function (_super) {
1235
1281
  });
1236
1282
  var watermarkContainer = document.createElement('div');
1237
1283
  watermarkContainer.className = 'dv-watermark-container';
1284
+ (0, dom_1.addTestId)(watermarkContainer, 'watermark-component');
1238
1285
  watermarkContainer.appendChild(this.watermark.element);
1239
1286
  this.gridview.element.appendChild(watermarkContainer);
1240
1287
  }
@@ -1439,6 +1486,7 @@ var DockviewComponent = /** @class */ (function (_super) {
1439
1486
  this.doSetGroupAndPanelActive(destinationGroup);
1440
1487
  this._onDidMovePanel.fire({
1441
1488
  panel: removedPanel_1,
1489
+ from: sourceGroup,
1442
1490
  });
1443
1491
  }
1444
1492
  else {
@@ -1462,6 +1510,10 @@ var DockviewComponent = /** @class */ (function (_super) {
1462
1510
  // if a group has one tab - we are essentially moving the 'group'
1463
1511
  // which is equivalent to swapping two views in this case
1464
1512
  this.gridview.moveView(sourceParentLocation, from, to);
1513
+ this._onDidMovePanel.fire({
1514
+ panel: this.getGroupPanel(sourceItemId),
1515
+ from: sourceGroup,
1516
+ });
1465
1517
  return;
1466
1518
  }
1467
1519
  }
@@ -1477,6 +1529,10 @@ var DockviewComponent = /** @class */ (function (_super) {
1477
1529
  var location_3 = (0, gridview_1.getRelativeLocation)(this.gridview.orientation, updatedReferenceLocation, destinationTarget);
1478
1530
  this.movingLock(function () { return _this.doAddGroup(targetGroup_1, location_3); });
1479
1531
  this.doSetGroupAndPanelActive(targetGroup_1);
1532
+ this._onDidMovePanel.fire({
1533
+ panel: this.getGroupPanel(sourceItemId),
1534
+ from: sourceGroup,
1535
+ });
1480
1536
  }
1481
1537
  else {
1482
1538
  /**
@@ -1500,6 +1556,10 @@ var DockviewComponent = /** @class */ (function (_super) {
1500
1556
  });
1501
1557
  });
1502
1558
  this.doSetGroupAndPanelActive(group_2);
1559
+ this._onDidMovePanel.fire({
1560
+ panel: removedPanel_2,
1561
+ from: sourceGroup,
1562
+ });
1503
1563
  }
1504
1564
  }
1505
1565
  };
@@ -1540,9 +1600,6 @@ var DockviewComponent = /** @class */ (function (_super) {
1540
1600
  }
1541
1601
  });
1542
1602
  this.doSetGroupAndPanelActive(to);
1543
- panels_2.forEach(function (panel) {
1544
- _this._onDidMovePanel.fire({ panel: panel });
1545
- });
1546
1603
  }
1547
1604
  else {
1548
1605
  switch (from.api.location.type) {
@@ -1568,10 +1625,10 @@ var DockviewComponent = /** @class */ (function (_super) {
1568
1625
  var referenceLocation = (0, gridview_1.getGridLocation)(to.element);
1569
1626
  var dropLocation = (0, gridview_1.getRelativeLocation)(this.gridview.orientation, referenceLocation, target);
1570
1627
  this.gridview.addView(from, splitview_1.Sizing.Distribute, dropLocation);
1571
- from.panels.forEach(function (panel) {
1572
- _this._onDidMovePanel.fire({ panel: panel });
1573
- });
1574
1628
  }
1629
+ from.panels.forEach(function (panel) {
1630
+ _this._onDidMovePanel.fire({ panel: panel, from: from });
1631
+ });
1575
1632
  };
1576
1633
  DockviewComponent.prototype.doSetGroupActive = function (group) {
1577
1634
  _super.prototype.doSetGroupActive.call(this, group);
@@ -1,23 +1,14 @@
1
1
  import { Overlay } from '../dnd/overlay';
2
2
  import { CompositeDisposable } from '../lifecycle';
3
+ import { AnchoredBox } from '../types';
3
4
  import { DockviewGroupPanel, IDockviewGroupPanel } from './dockviewGroupPanel';
4
5
  export interface IDockviewFloatingGroupPanel {
5
6
  readonly group: IDockviewGroupPanel;
6
- position(bounds: Partial<{
7
- top: number;
8
- left: number;
9
- height: number;
10
- width: number;
11
- }>): void;
7
+ position(bounds: Partial<AnchoredBox>): void;
12
8
  }
13
9
  export declare class DockviewFloatingGroupPanel extends CompositeDisposable implements IDockviewFloatingGroupPanel {
14
10
  readonly group: DockviewGroupPanel;
15
11
  readonly overlay: Overlay;
16
12
  constructor(group: DockviewGroupPanel, overlay: Overlay);
17
- position(bounds: Partial<{
18
- top: number;
19
- left: number;
20
- height: number;
21
- width: number;
22
- }>): void;
13
+ position(bounds: Partial<AnchoredBox>): void;
23
14
  }
@@ -11,6 +11,7 @@ import { DockviewGroupDropLocation, GroupOptions } from './dockviewGroupPanelMod
11
11
  import { IDockviewPanel } from './dockviewPanel';
12
12
  import { DockviewPanelRenderer } from '../overlayRenderContainer';
13
13
  import { IGroupHeaderProps } from './framework';
14
+ import { FloatingGroupOptions } from './dockviewComponent';
14
15
  export interface IHeaderActionsRenderer extends IDisposable {
15
16
  readonly element: HTMLElement;
16
17
  init(params: IGroupHeaderProps): void;
@@ -25,6 +26,10 @@ export interface ViewFactoryData {
25
26
  tab?: string;
26
27
  }
27
28
  export interface DockviewOptions {
29
+ /**
30
+ * Disable the auto-resizing which is controlled through a `ResizeObserver`.
31
+ * Call `.layout(width, height)` to manually resize the container.
32
+ */
28
33
  disableAutoResizing?: boolean;
29
34
  hideBorders?: boolean;
30
35
  singleTabMode?: 'fullwidth' | 'default';
@@ -39,6 +44,10 @@ export interface DockviewOptions {
39
44
  rootOverlayModel?: DroptargetOverlayModel;
40
45
  locked?: boolean;
41
46
  disableDnd?: boolean;
47
+ /**
48
+ * Pixel gap between groups
49
+ */
50
+ gap?: number;
42
51
  }
43
52
  export interface DockviewDndOverlayEvent {
44
53
  nativeEvent: DragEvent;
@@ -100,12 +109,7 @@ export type AddPanelPositionOptions = RelativePanel | RelativeGroup | AbsolutePo
100
109
  export declare function isPanelOptionsWithPanel(data: AddPanelPositionOptions): data is RelativePanel;
101
110
  export declare function isPanelOptionsWithGroup(data: AddPanelPositionOptions): data is RelativeGroup;
102
111
  type AddPanelFloatingGroupUnion = {
103
- floating: {
104
- height?: number;
105
- width?: number;
106
- x?: number;
107
- y?: number;
108
- } | true;
112
+ floating: Partial<FloatingGroupOptions> | true;
109
113
  position: never;
110
114
  };
111
115
  type AddPanelPositionUnion = {
@@ -40,6 +40,7 @@ exports.PROPERTY_KEYS = (function () {
40
40
  rootOverlayModel: undefined,
41
41
  locked: undefined,
42
42
  disableDnd: undefined,
43
+ gap: undefined,
43
44
  };
44
45
  return Object.keys(properties);
45
46
  })();
package/dist/cjs/dom.d.ts CHANGED
@@ -26,3 +26,4 @@ export declare function getDomNodePagePosition(domNode: Element): {
26
26
  * @see https://terodox.tech/how-to-tell-if-an-element-is-in-the-dom-including-the-shadow-dom/
27
27
  */
28
28
  export declare function isInDocument(element: Element): boolean;
29
+ export declare function addTestId(element: HTMLElement, id: string): void;
package/dist/cjs/dom.js CHANGED
@@ -26,7 +26,7 @@ var __values = (this && this.__values) || function(o) {
26
26
  throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.isInDocument = exports.getDomNodePagePosition = exports.addStyles = exports.quasiDefaultPrevented = exports.quasiPreventDefault = exports.trackFocus = exports.getElementsByTagName = exports.isAncestor = exports.toggleClass = exports.addClasses = exports.removeClasses = exports.watchElementResize = void 0;
29
+ exports.addTestId = exports.isInDocument = exports.getDomNodePagePosition = exports.addStyles = exports.quasiDefaultPrevented = exports.quasiPreventDefault = exports.trackFocus = exports.getElementsByTagName = exports.isAncestor = exports.toggleClass = exports.addClasses = exports.removeClasses = exports.watchElementResize = void 0;
30
30
  var events_1 = require("./events");
31
31
  var lifecycle_1 = require("./lifecycle");
32
32
  function watchElementResize(element, cb) {
@@ -274,3 +274,7 @@ function isInDocument(element) {
274
274
  return false;
275
275
  }
276
276
  exports.isInDocument = isInDocument;
277
+ function addTestId(element, id) {
278
+ element.setAttribute('data-testid', id);
279
+ }
280
+ exports.addTestId = addTestId;
@@ -15,6 +15,7 @@ export interface BaseGridOptions {
15
15
  readonly parentElement: HTMLElement;
16
16
  readonly disableAutoResizing?: boolean;
17
17
  readonly locked?: boolean;
18
+ readonly margin?: number;
18
19
  }
19
20
  export interface IGridPanelView extends IGridView, IPanel {
20
21
  setActive(isActive: boolean): void;
@@ -59,6 +60,8 @@ export declare abstract class BaseGrid<T extends IGridPanelView> extends Resizab
59
60
  readonly onDidActiveChange: Event<T | undefined>;
60
61
  protected readonly _bufferOnDidLayoutChange: AsapEvent;
61
62
  readonly onDidLayoutChange: Event<void>;
63
+ private readonly _onDidViewVisibilityChangeMicroTaskQueue;
64
+ readonly onDidViewVisibilityChangeMicroTaskQueue: Event<void>;
62
65
  get id(): string;
63
66
  get size(): number;
64
67
  get groups(): T[];
@@ -64,14 +64,20 @@ var BaseGrid = /** @class */ (function (_super) {
64
64
  _this.onDidActiveChange = _this._onDidActiveChange.event;
65
65
  _this._bufferOnDidLayoutChange = new events_1.AsapEvent();
66
66
  _this.onDidLayoutChange = _this._bufferOnDidLayoutChange.onEvent;
67
+ _this._onDidViewVisibilityChangeMicroTaskQueue = new events_1.AsapEvent();
68
+ _this.onDidViewVisibilityChangeMicroTaskQueue = _this._onDidViewVisibilityChangeMicroTaskQueue.onEvent;
67
69
  _this.element.style.height = '100%';
68
70
  _this.element.style.width = '100%';
69
71
  options.parentElement.appendChild(_this.element);
70
- _this.gridview = new gridview_1.Gridview(!!options.proportionalLayout, options.styles, options.orientation);
72
+ _this.gridview = new gridview_1.Gridview(!!options.proportionalLayout, options.styles, options.orientation, options.locked, options.margin);
71
73
  _this.gridview.locked = !!options.locked;
72
74
  _this.element.appendChild(_this.gridview.element);
73
75
  _this.layout(0, 0, true); // set some elements height/widths
74
- _this.addDisposables(lifecycle_1.Disposable.from(function () {
76
+ _this.addDisposables(_this.gridview.onDidViewVisibilityChange(function () {
77
+ return _this._onDidViewVisibilityChangeMicroTaskQueue.fire();
78
+ }), _this.onDidViewVisibilityChangeMicroTaskQueue(function () {
79
+ _this.layout(_this.width, _this.height, true);
80
+ }), lifecycle_1.Disposable.from(function () {
75
81
  var _a;
76
82
  (_a = _this.element.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(_this.element);
77
83
  }), _this.gridview.onDidChange(function () {
@@ -19,7 +19,9 @@ export declare class BranchNode extends CompositeDisposable implements IView {
19
19
  orthogonalSize?: number;
20
20
  }>;
21
21
  private readonly _onDidVisibilityChange;
22
- readonly onDidVisibilityChange: Event<boolean>;
22
+ readonly onDidVisibilityChange: Event<{
23
+ visible: boolean;
24
+ }>;
23
25
  get width(): number;
24
26
  get height(): number;
25
27
  get minimumSize(): number;
@@ -35,8 +37,10 @@ export declare class BranchNode extends CompositeDisposable implements IView {
35
37
  get priority(): LayoutPriority;
36
38
  get disabled(): boolean;
37
39
  set disabled(value: boolean);
38
- constructor(orientation: Orientation, proportionalLayout: boolean, styles: ISplitviewStyles | undefined, size: number, orthogonalSize: number, disabled: boolean, childDescriptors?: INodeDescriptor[]);
39
- setVisible(visible: boolean): void;
40
+ get margin(): number;
41
+ set margin(value: number);
42
+ constructor(orientation: Orientation, proportionalLayout: boolean, styles: ISplitviewStyles | undefined, size: number, orthogonalSize: number, disabled: boolean, margin: number | undefined, childDescriptors?: INodeDescriptor[]);
43
+ setVisible(_visible: boolean): void;
40
44
  isChildVisible(index: number): boolean;
41
45
  setChildVisible(index: number, visible: boolean): void;
42
46
  moveChild(from: number, to: number): void;
@@ -43,17 +43,6 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
43
43
  }
44
44
  return to.concat(ar || Array.prototype.slice.call(from));
45
45
  };
46
- var __values = (this && this.__values) || function(o) {
47
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
48
- if (m) return m.call(o);
49
- if (o && typeof o.length === "number") return {
50
- next: function () {
51
- if (o && i >= o.length) o = void 0;
52
- return { value: o && o[i++], done: !o };
53
- }
54
- };
55
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
56
- };
57
46
  Object.defineProperty(exports, "__esModule", { value: true });
58
47
  exports.BranchNode = void 0;
59
48
  var splitview_1 = require("../splitview/splitview");
@@ -62,7 +51,7 @@ var leafNode_1 = require("./leafNode");
62
51
  var lifecycle_1 = require("../lifecycle");
63
52
  var BranchNode = /** @class */ (function (_super) {
64
53
  __extends(BranchNode, _super);
65
- function BranchNode(orientation, proportionalLayout, styles, size, orthogonalSize, disabled, childDescriptors) {
54
+ function BranchNode(orientation, proportionalLayout, styles, size, orthogonalSize, disabled, margin, childDescriptors) {
66
55
  var _this = _super.call(this) || this;
67
56
  _this.orientation = orientation;
68
57
  _this.proportionalLayout = proportionalLayout;
@@ -82,6 +71,7 @@ var BranchNode = /** @class */ (function (_super) {
82
71
  orientation: _this.orientation,
83
72
  proportionalLayout: proportionalLayout,
84
73
  styles: styles,
74
+ margin: margin,
85
75
  });
86
76
  _this.splitview.layout(_this.size, _this.orthogonalSize);
87
77
  }
@@ -105,6 +95,7 @@ var BranchNode = /** @class */ (function (_super) {
105
95
  descriptor: descriptor,
106
96
  proportionalLayout: proportionalLayout,
107
97
  styles: styles,
98
+ margin: margin,
108
99
  });
109
100
  }
110
101
  _this.disabled = disabled;
@@ -253,21 +244,23 @@ var BranchNode = /** @class */ (function (_super) {
253
244
  enumerable: false,
254
245
  configurable: true
255
246
  });
256
- BranchNode.prototype.setVisible = function (visible) {
257
- var e_1, _a;
258
- try {
259
- for (var _b = __values(this.children), _c = _b.next(); !_c.done; _c = _b.next()) {
260
- var child = _c.value;
261
- child.setVisible(visible);
262
- }
263
- }
264
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
265
- finally {
266
- try {
267
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
268
- }
269
- finally { if (e_1) throw e_1.error; }
270
- }
247
+ Object.defineProperty(BranchNode.prototype, "margin", {
248
+ get: function () {
249
+ return this.splitview.margin;
250
+ },
251
+ set: function (value) {
252
+ this.splitview.margin = value;
253
+ this.children.forEach(function (child) {
254
+ if (child instanceof BranchNode) {
255
+ child.margin = value;
256
+ }
257
+ });
258
+ },
259
+ enumerable: false,
260
+ configurable: true
261
+ });
262
+ BranchNode.prototype.setVisible = function (_visible) {
263
+ // noop
271
264
  };
272
265
  BranchNode.prototype.isChildVisible = function (index) {
273
266
  if (index < 0 || index >= this.children.length) {
@@ -284,12 +277,13 @@ var BranchNode = /** @class */ (function (_super) {
284
277
  }
285
278
  var wereAllChildrenHidden = this.splitview.contentSize === 0;
286
279
  this.splitview.setViewVisible(index, visible);
280
+ // }
287
281
  var areAllChildrenHidden = this.splitview.contentSize === 0;
288
282
  // If all children are hidden then the parent should hide the entire splitview
289
283
  // If the entire splitview is hidden then the parent should show the splitview when a child is shown
290
284
  if ((visible && wereAllChildrenHidden) ||
291
285
  (!visible && areAllChildrenHidden)) {
292
- this._onDidVisibilityChange.fire(visible);
286
+ this._onDidVisibilityChange.fire({ visible: visible });
293
287
  }
294
288
  };
295
289
  BranchNode.prototype.moveChild = function (from, to) {
@@ -363,7 +357,8 @@ var BranchNode = /** @class */ (function (_super) {
363
357
  _this._onDidChange.fire({ size: e.orthogonalSize });
364
358
  })], __read(this.children.map(function (c, i) {
365
359
  if (c instanceof BranchNode) {
366
- return c.onDidVisibilityChange(function (visible) {
360
+ return c.onDidVisibilityChange(function (_a) {
361
+ var visible = _a.visible;
367
362
  _this.setChildVisible(i, visible);
368
363
  });
369
364
  }
@@ -26,6 +26,7 @@ export interface IGridView {
26
26
  readonly maximumWidth: number;
27
27
  readonly minimumHeight: number;
28
28
  readonly maximumHeight: number;
29
+ readonly isVisible: boolean;
29
30
  priority?: LayoutPriority;
30
31
  layout(width: number, height: number): void;
31
32
  toJSON(): object;
@@ -88,6 +89,7 @@ export declare class Gridview implements IDisposable {
88
89
  readonly element: HTMLElement;
89
90
  private _root;
90
91
  private _locked;
92
+ private _margin;
91
93
  private _maximizedNode;
92
94
  private readonly disposable;
93
95
  private readonly _onDidChange;
@@ -95,6 +97,8 @@ export declare class Gridview implements IDisposable {
95
97
  size?: number;
96
98
  orthogonalSize?: number;
97
99
  }>;
100
+ private readonly _onDidViewVisibilityChange;
101
+ readonly onDidViewVisibilityChange: Event<void>;
98
102
  private readonly _onDidMaximizedNodeChange;
99
103
  readonly onDidMaximizedNodeChange: Event<void>;
100
104
  get length(): number;
@@ -108,6 +112,8 @@ export declare class Gridview implements IDisposable {
108
112
  get maximumHeight(): number;
109
113
  get locked(): boolean;
110
114
  set locked(value: boolean);
115
+ get margin(): number;
116
+ set margin(value: number);
111
117
  maximizedView(): IGridView | undefined;
112
118
  hasMaximizedView(): boolean;
113
119
  maximizeView(view: IGridView): void;
@@ -131,7 +137,7 @@ export declare class Gridview implements IDisposable {
131
137
  getView(location?: number[]): GridNode<IGridView>;
132
138
  private _getViews;
133
139
  private progmaticSelect;
134
- constructor(proportionalLayout: boolean, styles: ISplitviewStyles | undefined, orientation: Orientation);
140
+ constructor(proportionalLayout: boolean, styles: ISplitviewStyles | undefined, orientation: Orientation, locked?: boolean, margin?: number);
135
141
  isViewVisible(location: number[]): boolean;
136
142
  setViewVisible(location: number[], visible: boolean): void;
137
143
  moveView(parentLocation: number[], from: number, to: number): void;