dockview-react 4.4.1 → 4.6.2

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.
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * dockview-react
3
- * @version 4.4.1
3
+ * @version 4.6.2
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -5053,6 +5053,40 @@
5053
5053
  }
5054
5054
  }
5055
5055
 
5056
+ class WillShowOverlayLocationEvent {
5057
+ get kind() {
5058
+ return this.options.kind;
5059
+ }
5060
+ get nativeEvent() {
5061
+ return this.event.nativeEvent;
5062
+ }
5063
+ get position() {
5064
+ return this.event.position;
5065
+ }
5066
+ get defaultPrevented() {
5067
+ return this.event.defaultPrevented;
5068
+ }
5069
+ get panel() {
5070
+ return this.options.panel;
5071
+ }
5072
+ get api() {
5073
+ return this.options.api;
5074
+ }
5075
+ get group() {
5076
+ return this.options.group;
5077
+ }
5078
+ preventDefault() {
5079
+ this.event.preventDefault();
5080
+ }
5081
+ getData() {
5082
+ return this.options.getData();
5083
+ }
5084
+ constructor(event, options) {
5085
+ this.event = event;
5086
+ this.options = options;
5087
+ }
5088
+ }
5089
+
5056
5090
  class GroupDragHandler extends DragHandler {
5057
5091
  constructor(element, accessor, group) {
5058
5092
  super(element);
@@ -5120,6 +5154,7 @@
5120
5154
  this._element = document.createElement('div');
5121
5155
  this._element.className = 'dv-void-container';
5122
5156
  this._element.draggable = !this.accessor.options.disableDnd;
5157
+ toggleClass(this._element, 'dv-draggable', !this.accessor.options.disableDnd);
5123
5158
  this.addDisposables(this._onDrop, this._onDragStart, addDisposableListener(this._element, 'pointerdown', () => {
5124
5159
  this.accessor.doSetGroupActive(this.group);
5125
5160
  }));
@@ -5144,6 +5179,7 @@
5144
5179
  }
5145
5180
  updateDragAndDropState() {
5146
5181
  this._element.draggable = !this.accessor.options.disableDnd;
5182
+ toggleClass(this._element, 'dv-draggable', !this.accessor.options.disableDnd);
5147
5183
  }
5148
5184
  }
5149
5185
 
@@ -5664,8 +5700,11 @@
5664
5700
  toggleClass(wrapper, 'dv-tab', true);
5665
5701
  toggleClass(wrapper, 'dv-active-tab', panelObject.api.isActive);
5666
5702
  toggleClass(wrapper, 'dv-inactive-tab', !panelObject.api.isActive);
5667
- wrapper.addEventListener('pointerdown', () => {
5703
+ wrapper.addEventListener('click', (event) => {
5668
5704
  this.accessor.popupService.close();
5705
+ if (event.defaultPrevented) {
5706
+ return;
5707
+ }
5669
5708
  tab.element.scrollIntoView();
5670
5709
  tab.panel.api.setActive();
5671
5710
  });
@@ -5782,39 +5821,6 @@
5782
5821
  this._kind = options.kind;
5783
5822
  }
5784
5823
  }
5785
- class WillShowOverlayLocationEvent {
5786
- get kind() {
5787
- return this.options.kind;
5788
- }
5789
- get nativeEvent() {
5790
- return this.event.nativeEvent;
5791
- }
5792
- get position() {
5793
- return this.event.position;
5794
- }
5795
- get defaultPrevented() {
5796
- return this.event.defaultPrevented;
5797
- }
5798
- get panel() {
5799
- return this.options.panel;
5800
- }
5801
- get api() {
5802
- return this.options.api;
5803
- }
5804
- get group() {
5805
- return this.options.group;
5806
- }
5807
- preventDefault() {
5808
- this.event.preventDefault();
5809
- }
5810
- getData() {
5811
- return this.options.getData();
5812
- }
5813
- constructor(event, options) {
5814
- this.event = event;
5815
- this.options = options;
5816
- }
5817
- }
5818
5824
  class DockviewGroupPanelModel extends CompositeDisposable {
5819
5825
  get element() {
5820
5826
  throw new Error('dockview: not supported');
@@ -6639,23 +6645,24 @@
6639
6645
  : window;
6640
6646
  }
6641
6647
  moveTo(options) {
6642
- var _a, _b, _c;
6648
+ var _a, _b, _c, _d;
6643
6649
  if (!this._group) {
6644
6650
  throw new Error(NOT_INITIALIZED_MESSAGE);
6645
6651
  }
6646
6652
  const group = (_a = options.group) !== null && _a !== void 0 ? _a : this.accessor.addGroup({
6647
6653
  direction: positionToDirection((_b = options.position) !== null && _b !== void 0 ? _b : 'right'),
6648
- skipSetActive: true,
6654
+ skipSetActive: (_c = options.skipSetActive) !== null && _c !== void 0 ? _c : false,
6649
6655
  });
6650
6656
  this.accessor.moveGroupOrPanel({
6651
6657
  from: { groupId: this._group.id },
6652
6658
  to: {
6653
6659
  group,
6654
6660
  position: options.group
6655
- ? (_c = options.position) !== null && _c !== void 0 ? _c : 'center'
6661
+ ? (_d = options.position) !== null && _d !== void 0 ? _d : 'center'
6656
6662
  : 'center',
6657
6663
  index: options.index,
6658
6664
  },
6665
+ skipSetActive: options.skipSetActive,
6659
6666
  });
6660
6667
  }
6661
6668
  maximize() {
@@ -6887,6 +6894,7 @@
6887
6894
  : 'center',
6888
6895
  index: options.index,
6889
6896
  },
6897
+ skipSetActive: options.skipSetActive,
6890
6898
  });
6891
6899
  }
6892
6900
  setTitle(title) {
@@ -9456,6 +9464,7 @@
9456
9464
  group: destinationGroup,
9457
9465
  position: destinationTarget,
9458
9466
  },
9467
+ skipSetActive: options.skipSetActive,
9459
9468
  });
9460
9469
  return;
9461
9470
  }
@@ -9474,11 +9483,17 @@
9474
9483
  // remove the group and do not set a new group as active
9475
9484
  this.doRemoveGroup(sourceGroup, { skipActive: true });
9476
9485
  }
9477
- this.movingLock(() => destinationGroup.model.openPanel(removedPanel, {
9478
- index: destinationIndex,
9479
- skipSetGroupActive: true,
9480
- }));
9481
- this.doSetGroupAndPanelActive(destinationGroup);
9486
+ this.movingLock(() => {
9487
+ var _a;
9488
+ return destinationGroup.model.openPanel(removedPanel, {
9489
+ index: destinationIndex,
9490
+ skipSetActive: (_a = options.skipSetActive) !== null && _a !== void 0 ? _a : false,
9491
+ skipSetGroupActive: true,
9492
+ });
9493
+ });
9494
+ if (!options.skipSetActive) {
9495
+ this.doSetGroupAndPanelActive(destinationGroup);
9496
+ }
9482
9497
  this._onDidMovePanel.fire({
9483
9498
  panel: removedPanel,
9484
9499
  from: sourceGroup,
@@ -9581,6 +9596,7 @@
9581
9596
  const target = options.to.position;
9582
9597
  if (target === 'center') {
9583
9598
  const activePanel = from.activePanel;
9599
+ const targetActivePanel = to.activePanel;
9584
9600
  const panels = this.movingLock(() => [...from.panels].map((p) => from.model.removePanel(p.id, {
9585
9601
  skipSetActive: true,
9586
9602
  })));
@@ -9590,12 +9606,23 @@
9590
9606
  this.movingLock(() => {
9591
9607
  for (const panel of panels) {
9592
9608
  to.model.openPanel(panel, {
9593
- skipSetActive: panel !== activePanel,
9609
+ skipSetActive: true, // Always skip setting panels active during move
9594
9610
  skipSetGroupActive: true,
9595
9611
  });
9596
9612
  }
9597
9613
  });
9598
- this.doSetGroupAndPanelActive(to);
9614
+ if (!options.skipSetActive) {
9615
+ // Make the moved panel (from the source group) active
9616
+ if (activePanel) {
9617
+ this.doSetGroupAndPanelActive(to);
9618
+ }
9619
+ }
9620
+ else if (targetActivePanel) {
9621
+ // Ensure the target group's original active panel remains active
9622
+ to.model.openPanel(targetActivePanel, {
9623
+ skipSetGroupActive: true
9624
+ });
9625
+ }
9599
9626
  }
9600
9627
  else {
9601
9628
  switch (from.api.location.type) {
@@ -9615,12 +9642,39 @@
9615
9642
  if (!selectedPopoutGroup) {
9616
9643
  throw new Error('failed to find popout group');
9617
9644
  }
9618
- selectedPopoutGroup.disposable.dispose();
9645
+ // Remove from popout groups list to prevent automatic restoration
9646
+ const index = this._popoutGroups.indexOf(selectedPopoutGroup);
9647
+ if (index >= 0) {
9648
+ this._popoutGroups.splice(index, 1);
9649
+ }
9650
+ // Clean up the reference group (ghost) if it exists and is hidden
9651
+ if (selectedPopoutGroup.referenceGroup) {
9652
+ const referenceGroup = this.getPanel(selectedPopoutGroup.referenceGroup);
9653
+ if (referenceGroup && !referenceGroup.api.isVisible) {
9654
+ this.doRemoveGroup(referenceGroup, { skipActive: true });
9655
+ }
9656
+ }
9657
+ // Manually dispose the window without triggering restoration
9658
+ selectedPopoutGroup.window.dispose();
9659
+ // Update group's location and containers for target
9660
+ if (to.api.location.type === 'grid') {
9661
+ from.model.renderContainer = this.overlayRenderContainer;
9662
+ from.model.dropTargetContainer = this.rootDropTargetContainer;
9663
+ from.model.location = { type: 'grid' };
9664
+ }
9665
+ else if (to.api.location.type === 'floating') {
9666
+ from.model.renderContainer = this.overlayRenderContainer;
9667
+ from.model.dropTargetContainer = this.rootDropTargetContainer;
9668
+ from.model.location = { type: 'floating' };
9669
+ }
9670
+ break;
9619
9671
  }
9620
9672
  }
9621
- if (from.api.location.type !== 'popout') {
9673
+ // For moves to grid locations
9674
+ if (to.api.location.type === 'grid') {
9622
9675
  const referenceLocation = getGridLocation(to.element);
9623
9676
  const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, target);
9677
+ // Add to grid for all moves targeting grid location
9624
9678
  let size;
9625
9679
  switch (this.gridview.orientation) {
9626
9680
  case exports.Orientation.VERTICAL:
@@ -9638,10 +9692,49 @@
9638
9692
  }
9639
9693
  this.gridview.addView(from, size, dropLocation);
9640
9694
  }
9695
+ else if (to.api.location.type === 'floating') {
9696
+ // For moves to floating locations, add as floating group
9697
+ // Get the position/size from the target floating group
9698
+ const targetFloatingGroup = this._floatingGroups.find((x) => x.group === to);
9699
+ if (targetFloatingGroup) {
9700
+ const box = targetFloatingGroup.overlay.toJSON();
9701
+ // Calculate position based on available properties
9702
+ let left, top;
9703
+ if ('left' in box) {
9704
+ left = box.left + 50;
9705
+ }
9706
+ else if ('right' in box) {
9707
+ left = Math.max(0, box.right - box.width - 50);
9708
+ }
9709
+ else {
9710
+ left = 50; // Default fallback
9711
+ }
9712
+ if ('top' in box) {
9713
+ top = box.top + 50;
9714
+ }
9715
+ else if ('bottom' in box) {
9716
+ top = Math.max(0, box.bottom - box.height - 50);
9717
+ }
9718
+ else {
9719
+ top = 50; // Default fallback
9720
+ }
9721
+ this.addFloatingGroup(from, {
9722
+ height: box.height,
9723
+ width: box.width,
9724
+ position: {
9725
+ left,
9726
+ top,
9727
+ },
9728
+ });
9729
+ }
9730
+ }
9641
9731
  }
9642
9732
  from.panels.forEach((panel) => {
9643
9733
  this._onDidMovePanel.fire({ panel, from });
9644
9734
  });
9735
+ if (!options.skipSetActive) {
9736
+ this.doSetGroupAndPanelActive(from);
9737
+ }
9645
9738
  }
9646
9739
  doSetGroupActive(group) {
9647
9740
  super.doSetGroupActive(group);
@@ -11382,7 +11475,7 @@
11382
11475
  }, [onPointerLeave]);
11383
11476
  return (React.createElement("div", Object.assign({ "data-testid": "dockview-dv-default-tab" }, rest, { onPointerDown: _onPointerDown, onPointerUp: _onPointerUp, onPointerLeave: _onPointerLeave, className: "dv-default-tab" }),
11384
11477
  React.createElement("span", { className: "dv-default-tab-content" }, title),
11385
- !hideClose && tabLocation !== 'headerOverflow' && (React.createElement("div", { className: "dv-default-tab-action", onPointerDown: onBtnPointerDown, onClick: onClose },
11478
+ !hideClose && (React.createElement("div", { className: "dv-default-tab-action", onPointerDown: onBtnPointerDown, onClick: onClose },
11386
11479
  React.createElement(CloseButton, null)))));
11387
11480
  };
11388
11481
 
@@ -11729,7 +11822,6 @@
11729
11822
  exports.SplitviewPanel = SplitviewPanel;
11730
11823
  exports.SplitviewReact = SplitviewReact;
11731
11824
  exports.Tab = Tab;
11732
- exports.WillShowOverlayLocationEvent = WillShowOverlayLocationEvent;
11733
11825
  exports.createDockview = createDockview;
11734
11826
  exports.createGridview = createGridview;
11735
11827
  exports.createPaneview = createPaneview;