dockview-core 4.4.1 → 4.5.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 (33) hide show
  1. package/dist/cjs/api/dockviewGroupPanelApi.d.ts +4 -0
  2. package/dist/cjs/api/dockviewGroupPanelApi.js +4 -3
  3. package/dist/cjs/api/dockviewPanelApi.js +1 -0
  4. package/dist/cjs/dockview/dockviewComponent.d.ts +2 -0
  5. package/dist/cjs/dockview/dockviewComponent.js +89 -6
  6. package/dist/dockview-core.amd.js +100 -13
  7. package/dist/dockview-core.amd.js.map +1 -1
  8. package/dist/dockview-core.amd.min.js +2 -2
  9. package/dist/dockview-core.amd.min.js.map +1 -1
  10. package/dist/dockview-core.amd.min.noStyle.js +2 -2
  11. package/dist/dockview-core.amd.min.noStyle.js.map +1 -1
  12. package/dist/dockview-core.amd.noStyle.js +100 -13
  13. package/dist/dockview-core.amd.noStyle.js.map +1 -1
  14. package/dist/dockview-core.cjs.js +100 -13
  15. package/dist/dockview-core.cjs.js.map +1 -1
  16. package/dist/dockview-core.esm.js +100 -13
  17. package/dist/dockview-core.esm.js.map +1 -1
  18. package/dist/dockview-core.esm.min.js +2 -2
  19. package/dist/dockview-core.esm.min.js.map +1 -1
  20. package/dist/dockview-core.js +100 -13
  21. package/dist/dockview-core.js.map +1 -1
  22. package/dist/dockview-core.min.js +2 -2
  23. package/dist/dockview-core.min.js.map +1 -1
  24. package/dist/dockview-core.min.noStyle.js +2 -2
  25. package/dist/dockview-core.min.noStyle.js.map +1 -1
  26. package/dist/dockview-core.noStyle.js +100 -13
  27. package/dist/dockview-core.noStyle.js.map +1 -1
  28. package/dist/esm/api/dockviewGroupPanelApi.d.ts +4 -0
  29. package/dist/esm/api/dockviewGroupPanelApi.js +4 -3
  30. package/dist/esm/api/dockviewPanelApi.js +1 -0
  31. package/dist/esm/dockview/dockviewComponent.d.ts +2 -0
  32. package/dist/esm/dockview/dockviewComponent.js +94 -9
  33. package/package.json +1 -1
@@ -11,6 +11,10 @@ export interface DockviewGroupMoveParams {
11
11
  * The index to place the panel within a group, only applicable if the placement is within an existing group
12
12
  */
13
13
  index?: number;
14
+ /**
15
+ * Whether to skip setting the group as active after moving
16
+ */
17
+ skipSetActive?: boolean;
14
18
  }
15
19
  export interface DockviewGroupPanelApi extends GridviewPanelApi {
16
20
  readonly onDidLocationChange: Event<DockviewGroupPanelFloatingChangeEvent>;
@@ -54,23 +54,24 @@ var DockviewGroupPanelApiImpl = /** @class */ (function (_super) {
54
54
  : window;
55
55
  };
56
56
  DockviewGroupPanelApiImpl.prototype.moveTo = function (options) {
57
- var _a, _b, _c;
57
+ var _a, _b, _c, _d;
58
58
  if (!this._group) {
59
59
  throw new Error(NOT_INITIALIZED_MESSAGE);
60
60
  }
61
61
  var group = (_a = options.group) !== null && _a !== void 0 ? _a : this.accessor.addGroup({
62
62
  direction: (0, droptarget_1.positionToDirection)((_b = options.position) !== null && _b !== void 0 ? _b : 'right'),
63
- skipSetActive: true,
63
+ skipSetActive: (_c = options.skipSetActive) !== null && _c !== void 0 ? _c : false,
64
64
  });
65
65
  this.accessor.moveGroupOrPanel({
66
66
  from: { groupId: this._group.id },
67
67
  to: {
68
68
  group: group,
69
69
  position: options.group
70
- ? (_c = options.position) !== null && _c !== void 0 ? _c : 'center'
70
+ ? (_d = options.position) !== null && _d !== void 0 ? _d : 'center'
71
71
  : 'center',
72
72
  index: options.index,
73
73
  },
74
+ skipSetActive: options.skipSetActive,
74
75
  });
75
76
  };
76
77
  DockviewGroupPanelApiImpl.prototype.maximize = function () {
@@ -110,6 +110,7 @@ var DockviewPanelApiImpl = /** @class */ (function (_super) {
110
110
  : 'center',
111
111
  index: options.index,
112
112
  },
113
+ skipSetActive: options.skipSetActive,
113
114
  });
114
115
  };
115
116
  DockviewPanelApiImpl.prototype.setTitle = function (title) {
@@ -80,6 +80,7 @@ type MoveGroupOptions = {
80
80
  group: DockviewGroupPanel;
81
81
  position: Position;
82
82
  };
83
+ skipSetActive?: boolean;
83
84
  };
84
85
  type MoveGroupOrPanelOptions = {
85
86
  from: {
@@ -91,6 +92,7 @@ type MoveGroupOrPanelOptions = {
91
92
  position: Position;
92
93
  index?: number;
93
94
  };
95
+ skipSetActive?: boolean;
94
96
  };
95
97
  export interface FloatingGroupOptions {
96
98
  x?: number;
@@ -1630,6 +1630,7 @@ var DockviewComponent = /** @class */ (function (_super) {
1630
1630
  group: destinationGroup,
1631
1631
  position: destinationTarget,
1632
1632
  },
1633
+ skipSetActive: options.skipSetActive,
1633
1634
  });
1634
1635
  return;
1635
1636
  }
@@ -1651,12 +1652,16 @@ var DockviewComponent = /** @class */ (function (_super) {
1651
1652
  this.doRemoveGroup(sourceGroup, { skipActive: true });
1652
1653
  }
1653
1654
  this.movingLock(function () {
1655
+ var _a;
1654
1656
  return destinationGroup.model.openPanel(removedPanel_1, {
1655
1657
  index: destinationIndex,
1658
+ skipSetActive: (_a = options.skipSetActive) !== null && _a !== void 0 ? _a : false,
1656
1659
  skipSetGroupActive: true,
1657
1660
  });
1658
1661
  });
1659
- this.doSetGroupAndPanelActive(destinationGroup);
1662
+ if (!options.skipSetActive) {
1663
+ this.doSetGroupAndPanelActive(destinationGroup);
1664
+ }
1660
1665
  this._onDidMovePanel.fire({
1661
1666
  panel: removedPanel_1,
1662
1667
  from: sourceGroup,
@@ -1769,7 +1774,8 @@ var DockviewComponent = /** @class */ (function (_super) {
1769
1774
  var to = options.to.group;
1770
1775
  var target = options.to.position;
1771
1776
  if (target === 'center') {
1772
- var activePanel_1 = from.activePanel;
1777
+ var activePanel = from.activePanel;
1778
+ var targetActivePanel = to.activePanel;
1773
1779
  var panels_2 = this.movingLock(function () {
1774
1780
  return __spreadArray([], __read(from.panels), false).map(function (p) {
1775
1781
  return from.model.removePanel(p.id, {
@@ -1786,7 +1792,7 @@ var DockviewComponent = /** @class */ (function (_super) {
1786
1792
  for (var panels_3 = __values(panels_2), panels_3_1 = panels_3.next(); !panels_3_1.done; panels_3_1 = panels_3.next()) {
1787
1793
  var panel = panels_3_1.value;
1788
1794
  to.model.openPanel(panel, {
1789
- skipSetActive: panel !== activePanel_1,
1795
+ skipSetActive: true, // Always skip setting panels active during move
1790
1796
  skipSetGroupActive: true,
1791
1797
  });
1792
1798
  }
@@ -1799,7 +1805,18 @@ var DockviewComponent = /** @class */ (function (_super) {
1799
1805
  finally { if (e_17) throw e_17.error; }
1800
1806
  }
1801
1807
  });
1802
- this.doSetGroupAndPanelActive(to);
1808
+ if (!options.skipSetActive) {
1809
+ // Make the moved panel (from the source group) active
1810
+ if (activePanel) {
1811
+ this.doSetGroupAndPanelActive(to);
1812
+ }
1813
+ }
1814
+ else if (targetActivePanel) {
1815
+ // Ensure the target group's original active panel remains active
1816
+ to.model.openPanel(targetActivePanel, {
1817
+ skipSetGroupActive: true
1818
+ });
1819
+ }
1803
1820
  }
1804
1821
  else {
1805
1822
  switch (from.api.location.type) {
@@ -1819,12 +1836,39 @@ var DockviewComponent = /** @class */ (function (_super) {
1819
1836
  if (!selectedPopoutGroup) {
1820
1837
  throw new Error('failed to find popout group');
1821
1838
  }
1822
- selectedPopoutGroup.disposable.dispose();
1839
+ // Remove from popout groups list to prevent automatic restoration
1840
+ var index = this._popoutGroups.indexOf(selectedPopoutGroup);
1841
+ if (index >= 0) {
1842
+ this._popoutGroups.splice(index, 1);
1843
+ }
1844
+ // Clean up the reference group (ghost) if it exists and is hidden
1845
+ if (selectedPopoutGroup.referenceGroup) {
1846
+ var referenceGroup = this.getPanel(selectedPopoutGroup.referenceGroup);
1847
+ if (referenceGroup && !referenceGroup.api.isVisible) {
1848
+ this.doRemoveGroup(referenceGroup, { skipActive: true });
1849
+ }
1850
+ }
1851
+ // Manually dispose the window without triggering restoration
1852
+ selectedPopoutGroup.window.dispose();
1853
+ // Update group's location and containers for target
1854
+ if (to.api.location.type === 'grid') {
1855
+ from.model.renderContainer = this.overlayRenderContainer;
1856
+ from.model.dropTargetContainer = this.rootDropTargetContainer;
1857
+ from.model.location = { type: 'grid' };
1858
+ }
1859
+ else if (to.api.location.type === 'floating') {
1860
+ from.model.renderContainer = this.overlayRenderContainer;
1861
+ from.model.dropTargetContainer = this.rootDropTargetContainer;
1862
+ from.model.location = { type: 'floating' };
1863
+ }
1864
+ break;
1823
1865
  }
1824
1866
  }
1825
- if (from.api.location.type !== 'popout') {
1867
+ // For moves to grid locations
1868
+ if (to.api.location.type === 'grid') {
1826
1869
  var referenceLocation = (0, gridview_1.getGridLocation)(to.element);
1827
1870
  var dropLocation = (0, gridview_1.getRelativeLocation)(this.gridview.orientation, referenceLocation, target);
1871
+ // Add to grid for all moves targeting grid location
1828
1872
  var size = void 0;
1829
1873
  switch (this.gridview.orientation) {
1830
1874
  case splitview_1.Orientation.VERTICAL:
@@ -1842,10 +1886,49 @@ var DockviewComponent = /** @class */ (function (_super) {
1842
1886
  }
1843
1887
  this.gridview.addView(from, size, dropLocation);
1844
1888
  }
1889
+ else if (to.api.location.type === 'floating') {
1890
+ // For moves to floating locations, add as floating group
1891
+ // Get the position/size from the target floating group
1892
+ var targetFloatingGroup = this._floatingGroups.find(function (x) { return x.group === to; });
1893
+ if (targetFloatingGroup) {
1894
+ var box = targetFloatingGroup.overlay.toJSON();
1895
+ // Calculate position based on available properties
1896
+ var left = void 0, top_1;
1897
+ if ('left' in box) {
1898
+ left = box.left + 50;
1899
+ }
1900
+ else if ('right' in box) {
1901
+ left = Math.max(0, box.right - box.width - 50);
1902
+ }
1903
+ else {
1904
+ left = 50; // Default fallback
1905
+ }
1906
+ if ('top' in box) {
1907
+ top_1 = box.top + 50;
1908
+ }
1909
+ else if ('bottom' in box) {
1910
+ top_1 = Math.max(0, box.bottom - box.height - 50);
1911
+ }
1912
+ else {
1913
+ top_1 = 50; // Default fallback
1914
+ }
1915
+ this.addFloatingGroup(from, {
1916
+ height: box.height,
1917
+ width: box.width,
1918
+ position: {
1919
+ left: left,
1920
+ top: top_1,
1921
+ },
1922
+ });
1923
+ }
1924
+ }
1845
1925
  }
1846
1926
  from.panels.forEach(function (panel) {
1847
1927
  _this._onDidMovePanel.fire({ panel: panel, from: from });
1848
1928
  });
1929
+ if (!options.skipSetActive) {
1930
+ this.doSetGroupAndPanelActive(from);
1931
+ }
1849
1932
  };
1850
1933
  DockviewComponent.prototype.doSetGroupActive = function (group) {
1851
1934
  _super.prototype.doSetGroupActive.call(this, group);
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * dockview-core
3
- * @version 4.4.1
3
+ * @version 4.5.0
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -6665,23 +6665,24 @@ define(['exports'], (function (exports) { 'use strict';
6665
6665
  : window;
6666
6666
  }
6667
6667
  moveTo(options) {
6668
- var _a, _b, _c;
6668
+ var _a, _b, _c, _d;
6669
6669
  if (!this._group) {
6670
6670
  throw new Error(NOT_INITIALIZED_MESSAGE);
6671
6671
  }
6672
6672
  const group = (_a = options.group) !== null && _a !== void 0 ? _a : this.accessor.addGroup({
6673
6673
  direction: positionToDirection((_b = options.position) !== null && _b !== void 0 ? _b : 'right'),
6674
- skipSetActive: true,
6674
+ skipSetActive: (_c = options.skipSetActive) !== null && _c !== void 0 ? _c : false,
6675
6675
  });
6676
6676
  this.accessor.moveGroupOrPanel({
6677
6677
  from: { groupId: this._group.id },
6678
6678
  to: {
6679
6679
  group,
6680
6680
  position: options.group
6681
- ? (_c = options.position) !== null && _c !== void 0 ? _c : 'center'
6681
+ ? (_d = options.position) !== null && _d !== void 0 ? _d : 'center'
6682
6682
  : 'center',
6683
6683
  index: options.index,
6684
6684
  },
6685
+ skipSetActive: options.skipSetActive,
6685
6686
  });
6686
6687
  }
6687
6688
  maximize() {
@@ -6913,6 +6914,7 @@ define(['exports'], (function (exports) { 'use strict';
6913
6914
  : 'center',
6914
6915
  index: options.index,
6915
6916
  },
6917
+ skipSetActive: options.skipSetActive,
6916
6918
  });
6917
6919
  }
6918
6920
  setTitle(title) {
@@ -9505,6 +9507,7 @@ define(['exports'], (function (exports) { 'use strict';
9505
9507
  group: destinationGroup,
9506
9508
  position: destinationTarget,
9507
9509
  },
9510
+ skipSetActive: options.skipSetActive,
9508
9511
  });
9509
9512
  return;
9510
9513
  }
@@ -9523,11 +9526,17 @@ define(['exports'], (function (exports) { 'use strict';
9523
9526
  // remove the group and do not set a new group as active
9524
9527
  this.doRemoveGroup(sourceGroup, { skipActive: true });
9525
9528
  }
9526
- this.movingLock(() => destinationGroup.model.openPanel(removedPanel, {
9527
- index: destinationIndex,
9528
- skipSetGroupActive: true,
9529
- }));
9530
- this.doSetGroupAndPanelActive(destinationGroup);
9529
+ this.movingLock(() => {
9530
+ var _a;
9531
+ return destinationGroup.model.openPanel(removedPanel, {
9532
+ index: destinationIndex,
9533
+ skipSetActive: (_a = options.skipSetActive) !== null && _a !== void 0 ? _a : false,
9534
+ skipSetGroupActive: true,
9535
+ });
9536
+ });
9537
+ if (!options.skipSetActive) {
9538
+ this.doSetGroupAndPanelActive(destinationGroup);
9539
+ }
9531
9540
  this._onDidMovePanel.fire({
9532
9541
  panel: removedPanel,
9533
9542
  from: sourceGroup,
@@ -9630,6 +9639,7 @@ define(['exports'], (function (exports) { 'use strict';
9630
9639
  const target = options.to.position;
9631
9640
  if (target === 'center') {
9632
9641
  const activePanel = from.activePanel;
9642
+ const targetActivePanel = to.activePanel;
9633
9643
  const panels = this.movingLock(() => [...from.panels].map((p) => from.model.removePanel(p.id, {
9634
9644
  skipSetActive: true,
9635
9645
  })));
@@ -9639,12 +9649,23 @@ define(['exports'], (function (exports) { 'use strict';
9639
9649
  this.movingLock(() => {
9640
9650
  for (const panel of panels) {
9641
9651
  to.model.openPanel(panel, {
9642
- skipSetActive: panel !== activePanel,
9652
+ skipSetActive: true, // Always skip setting panels active during move
9643
9653
  skipSetGroupActive: true,
9644
9654
  });
9645
9655
  }
9646
9656
  });
9647
- this.doSetGroupAndPanelActive(to);
9657
+ if (!options.skipSetActive) {
9658
+ // Make the moved panel (from the source group) active
9659
+ if (activePanel) {
9660
+ this.doSetGroupAndPanelActive(to);
9661
+ }
9662
+ }
9663
+ else if (targetActivePanel) {
9664
+ // Ensure the target group's original active panel remains active
9665
+ to.model.openPanel(targetActivePanel, {
9666
+ skipSetGroupActive: true
9667
+ });
9668
+ }
9648
9669
  }
9649
9670
  else {
9650
9671
  switch (from.api.location.type) {
@@ -9664,12 +9685,39 @@ define(['exports'], (function (exports) { 'use strict';
9664
9685
  if (!selectedPopoutGroup) {
9665
9686
  throw new Error('failed to find popout group');
9666
9687
  }
9667
- selectedPopoutGroup.disposable.dispose();
9688
+ // Remove from popout groups list to prevent automatic restoration
9689
+ const index = this._popoutGroups.indexOf(selectedPopoutGroup);
9690
+ if (index >= 0) {
9691
+ this._popoutGroups.splice(index, 1);
9692
+ }
9693
+ // Clean up the reference group (ghost) if it exists and is hidden
9694
+ if (selectedPopoutGroup.referenceGroup) {
9695
+ const referenceGroup = this.getPanel(selectedPopoutGroup.referenceGroup);
9696
+ if (referenceGroup && !referenceGroup.api.isVisible) {
9697
+ this.doRemoveGroup(referenceGroup, { skipActive: true });
9698
+ }
9699
+ }
9700
+ // Manually dispose the window without triggering restoration
9701
+ selectedPopoutGroup.window.dispose();
9702
+ // Update group's location and containers for target
9703
+ if (to.api.location.type === 'grid') {
9704
+ from.model.renderContainer = this.overlayRenderContainer;
9705
+ from.model.dropTargetContainer = this.rootDropTargetContainer;
9706
+ from.model.location = { type: 'grid' };
9707
+ }
9708
+ else if (to.api.location.type === 'floating') {
9709
+ from.model.renderContainer = this.overlayRenderContainer;
9710
+ from.model.dropTargetContainer = this.rootDropTargetContainer;
9711
+ from.model.location = { type: 'floating' };
9712
+ }
9713
+ break;
9668
9714
  }
9669
9715
  }
9670
- if (from.api.location.type !== 'popout') {
9716
+ // For moves to grid locations
9717
+ if (to.api.location.type === 'grid') {
9671
9718
  const referenceLocation = getGridLocation(to.element);
9672
9719
  const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, target);
9720
+ // Add to grid for all moves targeting grid location
9673
9721
  let size;
9674
9722
  switch (this.gridview.orientation) {
9675
9723
  case exports.Orientation.VERTICAL:
@@ -9687,10 +9735,49 @@ define(['exports'], (function (exports) { 'use strict';
9687
9735
  }
9688
9736
  this.gridview.addView(from, size, dropLocation);
9689
9737
  }
9738
+ else if (to.api.location.type === 'floating') {
9739
+ // For moves to floating locations, add as floating group
9740
+ // Get the position/size from the target floating group
9741
+ const targetFloatingGroup = this._floatingGroups.find((x) => x.group === to);
9742
+ if (targetFloatingGroup) {
9743
+ const box = targetFloatingGroup.overlay.toJSON();
9744
+ // Calculate position based on available properties
9745
+ let left, top;
9746
+ if ('left' in box) {
9747
+ left = box.left + 50;
9748
+ }
9749
+ else if ('right' in box) {
9750
+ left = Math.max(0, box.right - box.width - 50);
9751
+ }
9752
+ else {
9753
+ left = 50; // Default fallback
9754
+ }
9755
+ if ('top' in box) {
9756
+ top = box.top + 50;
9757
+ }
9758
+ else if ('bottom' in box) {
9759
+ top = Math.max(0, box.bottom - box.height - 50);
9760
+ }
9761
+ else {
9762
+ top = 50; // Default fallback
9763
+ }
9764
+ this.addFloatingGroup(from, {
9765
+ height: box.height,
9766
+ width: box.width,
9767
+ position: {
9768
+ left,
9769
+ top,
9770
+ },
9771
+ });
9772
+ }
9773
+ }
9690
9774
  }
9691
9775
  from.panels.forEach((panel) => {
9692
9776
  this._onDidMovePanel.fire({ panel, from });
9693
9777
  });
9778
+ if (!options.skipSetActive) {
9779
+ this.doSetGroupAndPanelActive(from);
9780
+ }
9694
9781
  }
9695
9782
  doSetGroupActive(group) {
9696
9783
  super.doSetGroupActive(group);