dockview-core 8.3.0 → 8.3.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.
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * dockview-core
3
- * @version 8.3.0
3
+ * @version 8.3.1
4
4
  * @link https://github.com/dockview/dockview
5
5
  * @license MIT
6
6
  */
@@ -4447,8 +4447,9 @@ var PointerDragController = class PointerDragController extends CompositeDisposa
4447
4447
  for (const el of elements) {
4448
4448
  let current = el;
4449
4449
  while (current) {
4450
+ var _target$isHitTestTran;
4450
4451
  const target = this._targetByElement.get(current);
4451
- if (target) return target;
4452
+ if (target && !((_target$isHitTestTran = target.isHitTestTransparent) === null || _target$isHitTestTran === void 0 ? void 0 : _target$isHitTestTran.call(target))) return target;
4452
4453
  current = current.parentElement;
4453
4454
  }
4454
4455
  }
@@ -4544,10 +4545,14 @@ var PointerDropTarget = class extends CompositeDisposable {
4544
4545
  element: this.element,
4545
4546
  handleDragOver: (e) => this._onDragOver(e),
4546
4547
  handleDragLeave: () => this._onDragLeave(),
4547
- handleDrop: (e) => this._onDropEvent(e)
4548
+ handleDrop: (e) => this._onDropEvent(e),
4549
+ isHitTestTransparent: options.isHitTestTransparent
4548
4550
  };
4549
4551
  this.addDisposables(this._onDrop, this._onWillShowOverlay, PointerDragController.getInstance().registerTarget(handle));
4550
4552
  }
4553
+ clearOverlay() {
4554
+ this._clearOwnOverlay();
4555
+ }
4551
4556
  setTargetZones(zones) {
4552
4557
  this._acceptedTargetZonesSet = new Set(zones);
4553
4558
  }
@@ -5867,6 +5872,7 @@ var Tab = class extends CompositeDisposable {
5867
5872
  if (this.accessor.id === (data === null || data === void 0 ? void 0 : data.viewId)) {
5868
5873
  var _this$accessor$option;
5869
5874
  if (((_this$accessor$option = this.accessor.options.theme) === null || _this$accessor$option === void 0 ? void 0 : _this$accessor$option.tabAnimation) === "smooth") return false;
5875
+ if (data.tabGroupId && this.group.model.getTabGroupForPanel(this.panel.id)) return false;
5870
5876
  return true;
5871
5877
  }
5872
5878
  return this.group.model.canDisplayOverlay(event, position, "tab");
@@ -7314,7 +7320,23 @@ var TabGroupManager = class {
7314
7320
  }
7315
7321
  updateDirection() {
7316
7322
  const isVertical = this._ctx.getDirection() === "vertical";
7317
- for (const [, entry] of this._chipRenderers) entry.dropTarget.setTargetZones(isVertical ? ["top"] : ["left"]);
7323
+ for (const [, entry] of this._chipRenderers) {
7324
+ const zones = isVertical ? ["top"] : ["left"];
7325
+ entry.dropTarget.setTargetZones(zones);
7326
+ entry.pointerDropTarget.setTargetZones(zones);
7327
+ }
7328
+ }
7329
+ /**
7330
+ * Drop any overlay the chips are showing. A group move is committed by a
7331
+ * capturing listener on the tabs list that stops the event, so the chip
7332
+ * target under the cursor never sees the drop that would clear its own.
7333
+ */
7334
+ clearChipDropOverlays() {
7335
+ for (const [, entry] of this._chipRenderers) {
7336
+ var _entry$dropTarget, _entry$pointerDropTar;
7337
+ (_entry$dropTarget = entry.dropTarget) === null || _entry$dropTarget === void 0 || _entry$dropTarget.clearOverlay();
7338
+ (_entry$pointerDropTar = entry.pointerDropTarget) === null || _entry$pointerDropTar === void 0 || _entry$pointerDropTar.clearOverlay();
7339
+ }
7318
7340
  }
7319
7341
  snapshotChipWidths() {
7320
7342
  const widths = /* @__PURE__ */ new Map();
@@ -7563,9 +7585,8 @@ var TabGroupManager = class {
7563
7585
  };
7564
7586
  if (chip instanceof TabGroupChip) disposables.push(chip.onContextMenu(onContextMenu));
7565
7587
  else disposables.push(new LongPressDetector(chip.element, { onLongPress: onContextMenu }), addDisposableListener(chip.element, "contextmenu", onContextMenu));
7566
- const isVertical = this._ctx.getDirection() === "vertical";
7567
- const dropTarget = new Droptarget(chip.element, {
7568
- acceptedTargetZones: isVertical ? ["top"] : ["left"],
7588
+ const dropTargetOptions = {
7589
+ acceptedTargetZones: this._ctx.getDirection() === "vertical" ? ["top"] : ["left"],
7569
7590
  overlayModel: { activationSize: {
7570
7591
  value: 100,
7571
7592
  type: "percentage"
@@ -7576,15 +7597,18 @@ var TabGroupManager = class {
7576
7597
  const data = getPanelData();
7577
7598
  if (this._ctx.accessor.id === (data === null || data === void 0 ? void 0 : data.viewId)) {
7578
7599
  var _this$_ctx$accessor$o3;
7579
- if (((_this$_ctx$accessor$o3 = this._ctx.accessor.options.theme) === null || _this$_ctx$accessor$o3 === void 0 ? void 0 : _this$_ctx$accessor$o3.tabAnimation) === "smooth") return false;
7600
+ if (((_this$_ctx$accessor$o3 = this._ctx.accessor.options.theme) === null || _this$_ctx$accessor$o3 === void 0 ? void 0 : _this$_ctx$accessor$o3.tabAnimation) === "smooth" && !data.tabGroupId) return false;
7580
7601
  return true;
7581
7602
  }
7582
7603
  return this._ctx.group.model.canDisplayOverlay(event, position, "tab");
7583
7604
  }
7584
- });
7585
- disposables.push(dropTarget, dropTarget.onDrop((event) => {
7605
+ };
7606
+ const dropTarget = html5Backend.createDropTarget(chip.element, dropTargetOptions);
7607
+ const pointerDropTarget = pointerBackend.createDropTarget(chip.element, dropTargetOptions);
7608
+ const onDrop = (event) => {
7586
7609
  this._callbacks.onChipDrop(tabGroup, event);
7587
- }));
7610
+ };
7611
+ disposables.push(dropTarget, dropTarget.onDrop(onDrop), pointerDropTarget, pointerDropTarget.onDrop(onDrop));
7588
7612
  const disposable = new CompositeDisposable(...disposables);
7589
7613
  this._chipRenderers.set(tabGroup.id, {
7590
7614
  chip,
@@ -7592,7 +7616,8 @@ var TabGroupManager = class {
7592
7616
  pointerDragSource: dragSources.pointerDragSource,
7593
7617
  dragSourcesDisposable: dragSources.disposable,
7594
7618
  disposable,
7595
- dropTarget
7619
+ dropTarget,
7620
+ pointerDropTarget
7596
7621
  });
7597
7622
  if (tabGroup.collapsed) this._skipNextCollapseAnimation = true;
7598
7623
  }
@@ -7837,7 +7862,14 @@ var TabReorderController = class extends CompositeDisposable {
7837
7862
  * dragover bridge may have installed.
7838
7863
  */
7839
7864
  handlePointerDragEnd(e) {
7840
- if (e && this._animState && this._animState.sourceIndex !== -1 && !this._animState.sourceTabGroupId && this._animState.currentInsertionIndex !== null && this.isPointInsideTabsList(e.clientX, e.clientY)) this.commitPointerReorder(e.pointerEvent);
7865
+ if (e && this._animState && this._animState.sourceIndex !== -1 && this._animState.currentInsertionIndex !== null && this.isPointInsideTabsList(e.clientX, e.clientY)) {
7866
+ const sourceTabGroupId = this._animState.sourceTabGroupId;
7867
+ if (sourceTabGroupId) {
7868
+ const insertionIndex = this._animState.currentInsertionIndex;
7869
+ this._animState = null;
7870
+ this.commitGroupMove(sourceTabGroupId, insertionIndex);
7871
+ } else this.commitPointerReorder(e.pointerEvent);
7872
+ }
7841
7873
  this._pointerInsideTabsList = false;
7842
7874
  this.resetDragAnimation();
7843
7875
  }
@@ -8473,6 +8505,7 @@ var TabReorderController = class extends CompositeDisposable {
8473
8505
  commitGroupMove(sourceTabGroupId, insertionIndex) {
8474
8506
  const data = getPanelData();
8475
8507
  this._tabGroupManager.disposeChipDrag(sourceTabGroupId);
8508
+ this._tabGroupManager.clearChipDropOverlays();
8476
8509
  if (this.group.model.getTabGroups().some((tg) => tg.id === sourceTabGroupId)) {
8477
8510
  var _this$accessor$option3;
8478
8511
  if (((_this$accessor$option3 = this.accessor.options.theme) === null || _this$accessor$option3 === void 0 ? void 0 : _this$accessor$option3.tabAnimation) === "smooth") {
@@ -8830,7 +8863,16 @@ var Tabs = class extends CompositeDisposable {
8830
8863
  }
8831
8864
  });
8832
8865
  this._reorder = new TabReorderController(this);
8833
- this.addDisposables(this._onOverflowTabsChange, this._observerDisposable, this._pointerActivation, this._onWillShowOverlay, this._onDrop, this._onTabDragStart, this._reorder, PointerDragController.getInstance().onDragEnd((e) => {
8866
+ const tabsListPointerTarget = pointerBackend.createDropTarget(this._tabsList, {
8867
+ acceptedTargetZones: ["center"],
8868
+ canDisplayOverlay: () => false,
8869
+ isHitTestTransparent: () => {
8870
+ const data = getPanelData();
8871
+ if ((data === null || data === void 0 ? void 0 : data.viewId) !== this.accessor.id || data.groupId !== this.group.id) return true;
8872
+ return data.panelId === null && !data.tabGroupId;
8873
+ }
8874
+ });
8875
+ this.addDisposables(tabsListPointerTarget, this._onOverflowTabsChange, this._observerDisposable, this._pointerActivation, this._onWillShowOverlay, this._onDrop, this._onTabDragStart, this._reorder, PointerDragController.getInstance().onDragEnd((e) => {
8834
8876
  this._reorder.handlePointerDragEnd(e);
8835
8877
  }), PointerDragController.getInstance().onDragMove((e) => {
8836
8878
  this._reorder.handlePointerDragMove(e.clientX, e.clientY);
@@ -9306,6 +9348,10 @@ var Tabs = class extends CompositeDisposable {
9306
9348
  * (when the source tab is currently to the left of the target slot, its
9307
9349
  * removal shifts the insertion index down by one). Always clears
9308
9350
  * `targetTabGroupId` so the dropped tab lands outside the group.
9351
+ *
9352
+ * A chip dropped on a chip is a group move: the panel path would route it
9353
+ * through the cross-group machinery, which rebuilds the tab group under a
9354
+ * new id.
9309
9355
  */
9310
9356
  _handleChipDrop(tabGroup, event) {
9311
9357
  const firstPanelId = tabGroup.panelIds[0];
@@ -9313,6 +9359,14 @@ var Tabs = class extends CompositeDisposable {
9313
9359
  const insertionIndex = this._tabs.findIndex((x) => x.value.panel.id === firstPanelId);
9314
9360
  if (insertionIndex === -1) return;
9315
9361
  const data = getPanelData();
9362
+ if (data === null || data === void 0 ? void 0 : data.tabGroupId) {
9363
+ var _animState$currentIns2;
9364
+ const animState = this._animState;
9365
+ this._animState = null;
9366
+ this._pendingCollapse = false;
9367
+ this._commitGroupMove(data.tabGroupId, (_animState$currentIns2 = animState === null || animState === void 0 ? void 0 : animState.currentInsertionIndex) !== null && _animState$currentIns2 !== void 0 ? _animState$currentIns2 : insertionIndex);
9368
+ return;
9369
+ }
9316
9370
  const sourceIndex = (data === null || data === void 0 ? void 0 : data.groupId) === this.group.id && (data === null || data === void 0 ? void 0 : data.panelId) ? this._tabs.findIndex((x) => x.value.panel.id === data.panelId) : -1;
9317
9371
  const adjustedIndex = insertionIndex - (sourceIndex !== -1 && sourceIndex < insertionIndex ? 1 : 0);
9318
9372
  this._onDrop.fire({
@@ -16390,10 +16444,11 @@ var DockviewComponent = class extends BaseGrid {
16390
16444
  group = this.createGroup();
16391
16445
  this._onDidAddGroup.fire(group);
16392
16446
  this.movingLock(() => this.removePanel(item, {
16393
- removeEmptyGroup: true,
16447
+ removeEmptyGroup: false,
16394
16448
  skipDispose: true,
16395
16449
  skipSetActiveGroup: true
16396
16450
  }));
16451
+ this.removeGroupIfEmpty(sourceGroup);
16397
16452
  this.movingLock(() => group.model.openPanel(item, { skipSetGroupActive: true }));
16398
16453
  movedPanels = [{
16399
16454
  panel: item,
@@ -16464,6 +16519,9 @@ var DockviewComponent = class extends BaseGrid {
16464
16519
  });
16465
16520
  for (const { panel, from } of movedPanels) this.fireDidMovePanel(panel, from);
16466
16521
  }
16522
+ removeGroupIfEmpty(group) {
16523
+ if (group.model.size === 0) this.doRemoveGroup(group, { skipActive: true });
16524
+ }
16467
16525
  /**
16468
16526
  * Build an empty gridview configured to match the main grid's styling, for
16469
16527
  * hosting a nested layout inside a floating or popout window.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dockview-core",
3
- "version": "8.3.0",
3
+ "version": "8.3.1",
4
4
  "description": "Zero dependency layout manager supporting tabs, groups, grids and splitviews for vanilla TypeScript",
5
5
  "keywords": [
6
6
  "splitview",