dockview-core 8.2.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.2.0
3
+ * @version 8.3.1
4
4
  * @link https://github.com/dockview/dockview
5
5
  * @license MIT
6
6
  */
@@ -1050,8 +1050,14 @@ var Splitview = class {
1050
1050
  container.appendChild(view.element);
1051
1051
  let viewSize;
1052
1052
  if (typeof size === "number") viewSize = size;
1053
- else if (size.type === "split") viewSize = this.getViewSize(size.index) / 2;
1054
- else if (size.type === "invisible") viewSize = { cachedVisibleSize: size.cachedVisibleSize };
1053
+ else if (size.type === "split") {
1054
+ const splitTarget = this.viewItems[size.index];
1055
+ if (splitTarget) {
1056
+ const half = Math.floor(splitTarget.size / 2);
1057
+ viewSize = splitTarget.size - half;
1058
+ splitTarget.size = half;
1059
+ } else viewSize = this.getViewSize(size.index) / 2;
1060
+ } else if (size.type === "invisible") viewSize = { cachedVisibleSize: size.cachedVisibleSize };
1055
1061
  else viewSize = view.minimumSize;
1056
1062
  const disposable = view.onDidChange((newSize) => this.onDidChange(viewItem, newSize.size));
1057
1063
  const viewItem = new ViewItem(container, view, viewSize, { dispose: () => {
@@ -4443,8 +4449,9 @@ var PointerDragController = class PointerDragController extends CompositeDisposa
4443
4449
  for (const el of elements) {
4444
4450
  let current = el;
4445
4451
  while (current) {
4452
+ var _target$isHitTestTran;
4446
4453
  const target = this._targetByElement.get(current);
4447
- if (target) return target;
4454
+ if (target && !((_target$isHitTestTran = target.isHitTestTransparent) === null || _target$isHitTestTran === void 0 ? void 0 : _target$isHitTestTran.call(target))) return target;
4448
4455
  current = current.parentElement;
4449
4456
  }
4450
4457
  }
@@ -4540,10 +4547,14 @@ var PointerDropTarget = class extends CompositeDisposable {
4540
4547
  element: this.element,
4541
4548
  handleDragOver: (e) => this._onDragOver(e),
4542
4549
  handleDragLeave: () => this._onDragLeave(),
4543
- handleDrop: (e) => this._onDropEvent(e)
4550
+ handleDrop: (e) => this._onDropEvent(e),
4551
+ isHitTestTransparent: options.isHitTestTransparent
4544
4552
  };
4545
4553
  this.addDisposables(this._onDrop, this._onWillShowOverlay, PointerDragController.getInstance().registerTarget(handle));
4546
4554
  }
4555
+ clearOverlay() {
4556
+ this._clearOwnOverlay();
4557
+ }
4547
4558
  setTargetZones(zones) {
4548
4559
  this._acceptedTargetZonesSet = new Set(zones);
4549
4560
  }
@@ -5796,7 +5807,7 @@ function resolveDndCapabilities(options) {
5796
5807
  };
5797
5808
  case "auto":
5798
5809
  case void 0:
5799
- default: return isCoarsePrimaryInput$1() ? {
5810
+ default: return isCoarsePrimaryInput$2() ? {
5800
5811
  html5: false,
5801
5812
  pointer: true,
5802
5813
  pointerHandlesMouse: true
@@ -5807,7 +5818,7 @@ function resolveDndCapabilities(options) {
5807
5818
  };
5808
5819
  }
5809
5820
  }
5810
- function isCoarsePrimaryInput$1() {
5821
+ function isCoarsePrimaryInput$2() {
5811
5822
  if (globalThis.window === void 0 || !globalThis.matchMedia) return false;
5812
5823
  const coarse = globalThis.matchMedia("(pointer: coarse)").matches;
5813
5824
  const fine = globalThis.matchMedia("(pointer: fine)").matches;
@@ -5863,6 +5874,7 @@ var Tab = class extends CompositeDisposable {
5863
5874
  if (this.accessor.id === (data === null || data === void 0 ? void 0 : data.viewId)) {
5864
5875
  var _this$accessor$option;
5865
5876
  if (((_this$accessor$option = this.accessor.options.theme) === null || _this$accessor$option === void 0 ? void 0 : _this$accessor$option.tabAnimation) === "smooth") return false;
5877
+ if (data.tabGroupId && this.group.model.getTabGroupForPanel(this.panel.id)) return false;
5866
5878
  return true;
5867
5879
  }
5868
5880
  return this.group.model.canDisplayOverlay(event, position, "tab");
@@ -7310,7 +7322,23 @@ var TabGroupManager = class {
7310
7322
  }
7311
7323
  updateDirection() {
7312
7324
  const isVertical = this._ctx.getDirection() === "vertical";
7313
- for (const [, entry] of this._chipRenderers) entry.dropTarget.setTargetZones(isVertical ? ["top"] : ["left"]);
7325
+ for (const [, entry] of this._chipRenderers) {
7326
+ const zones = isVertical ? ["top"] : ["left"];
7327
+ entry.dropTarget.setTargetZones(zones);
7328
+ entry.pointerDropTarget.setTargetZones(zones);
7329
+ }
7330
+ }
7331
+ /**
7332
+ * Drop any overlay the chips are showing. A group move is committed by a
7333
+ * capturing listener on the tabs list that stops the event, so the chip
7334
+ * target under the cursor never sees the drop that would clear its own.
7335
+ */
7336
+ clearChipDropOverlays() {
7337
+ for (const [, entry] of this._chipRenderers) {
7338
+ var _entry$dropTarget, _entry$pointerDropTar;
7339
+ (_entry$dropTarget = entry.dropTarget) === null || _entry$dropTarget === void 0 || _entry$dropTarget.clearOverlay();
7340
+ (_entry$pointerDropTar = entry.pointerDropTarget) === null || _entry$pointerDropTar === void 0 || _entry$pointerDropTar.clearOverlay();
7341
+ }
7314
7342
  }
7315
7343
  snapshotChipWidths() {
7316
7344
  const widths = /* @__PURE__ */ new Map();
@@ -7559,9 +7587,8 @@ var TabGroupManager = class {
7559
7587
  };
7560
7588
  if (chip instanceof TabGroupChip) disposables.push(chip.onContextMenu(onContextMenu));
7561
7589
  else disposables.push(new LongPressDetector(chip.element, { onLongPress: onContextMenu }), addDisposableListener(chip.element, "contextmenu", onContextMenu));
7562
- const isVertical = this._ctx.getDirection() === "vertical";
7563
- const dropTarget = new Droptarget(chip.element, {
7564
- acceptedTargetZones: isVertical ? ["top"] : ["left"],
7590
+ const dropTargetOptions = {
7591
+ acceptedTargetZones: this._ctx.getDirection() === "vertical" ? ["top"] : ["left"],
7565
7592
  overlayModel: { activationSize: {
7566
7593
  value: 100,
7567
7594
  type: "percentage"
@@ -7572,15 +7599,18 @@ var TabGroupManager = class {
7572
7599
  const data = getPanelData();
7573
7600
  if (this._ctx.accessor.id === (data === null || data === void 0 ? void 0 : data.viewId)) {
7574
7601
  var _this$_ctx$accessor$o3;
7575
- 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;
7602
+ 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;
7576
7603
  return true;
7577
7604
  }
7578
7605
  return this._ctx.group.model.canDisplayOverlay(event, position, "tab");
7579
7606
  }
7580
- });
7581
- disposables.push(dropTarget, dropTarget.onDrop((event) => {
7607
+ };
7608
+ const dropTarget = html5Backend.createDropTarget(chip.element, dropTargetOptions);
7609
+ const pointerDropTarget = pointerBackend.createDropTarget(chip.element, dropTargetOptions);
7610
+ const onDrop = (event) => {
7582
7611
  this._callbacks.onChipDrop(tabGroup, event);
7583
- }));
7612
+ };
7613
+ disposables.push(dropTarget, dropTarget.onDrop(onDrop), pointerDropTarget, pointerDropTarget.onDrop(onDrop));
7584
7614
  const disposable = new CompositeDisposable(...disposables);
7585
7615
  this._chipRenderers.set(tabGroup.id, {
7586
7616
  chip,
@@ -7588,7 +7618,8 @@ var TabGroupManager = class {
7588
7618
  pointerDragSource: dragSources.pointerDragSource,
7589
7619
  dragSourcesDisposable: dragSources.disposable,
7590
7620
  disposable,
7591
- dropTarget
7621
+ dropTarget,
7622
+ pointerDropTarget
7592
7623
  });
7593
7624
  if (tabGroup.collapsed) this._skipNextCollapseAnimation = true;
7594
7625
  }
@@ -7833,7 +7864,14 @@ var TabReorderController = class extends CompositeDisposable {
7833
7864
  * dragover bridge may have installed.
7834
7865
  */
7835
7866
  handlePointerDragEnd(e) {
7836
- 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);
7867
+ if (e && this._animState && this._animState.sourceIndex !== -1 && this._animState.currentInsertionIndex !== null && this.isPointInsideTabsList(e.clientX, e.clientY)) {
7868
+ const sourceTabGroupId = this._animState.sourceTabGroupId;
7869
+ if (sourceTabGroupId) {
7870
+ const insertionIndex = this._animState.currentInsertionIndex;
7871
+ this._animState = null;
7872
+ this.commitGroupMove(sourceTabGroupId, insertionIndex);
7873
+ } else this.commitPointerReorder(e.pointerEvent);
7874
+ }
7837
7875
  this._pointerInsideTabsList = false;
7838
7876
  this.resetDragAnimation();
7839
7877
  }
@@ -7962,11 +8000,28 @@ var TabReorderController = class extends CompositeDisposable {
7962
8000
  if (this._voidContainer && related && (related === this._voidContainer || this._voidContainer.contains(related))) return;
7963
8001
  this.resetTabTransforms();
7964
8002
  if (this._animState.sourceIndex === -1) {
7965
- var _this$group$model$dro2;
7966
- (_this$group$model$dro2 = this.group.model.dropTargetContainer) === null || _this$group$model$dro2 === void 0 || (_this$group$model$dro2 = _this$group$model$dro2.model) === null || _this$group$model$dro2 === void 0 || _this$group$model$dro2.clear();
8003
+ this.clearHeaderAnchorOverlay();
7967
8004
  this._animState = null;
7968
8005
  } else this._animState.currentInsertionIndex = null;
7969
8006
  }
8007
+ /**
8008
+ * Clear the anchored overlay only when this header is what rendered it.
8009
+ * The container is shared with the group's content drop target, which
8010
+ * renders into it on the same frame the cursor leaves the strip: the
8011
+ * pointer backend calls `handleDragOver` on the new target before the
8012
+ * global `onDragMove` that reaches us (#1612).
8013
+ */
8014
+ clearHeaderAnchorOverlay() {
8015
+ var _container$model;
8016
+ const container = this.group.model.dropTargetContainer;
8017
+ const outline = container === null || container === void 0 ? void 0 : container.renderedOutline;
8018
+ if (outline && ![
8019
+ this._tabsList,
8020
+ this._voidContainer,
8021
+ this._extendedDropZone
8022
+ ].some((scope) => scope === null || scope === void 0 ? void 0 : scope.contains(outline))) return;
8023
+ container === null || container === void 0 || (_container$model = container.model) === null || _container$model === void 0 || _container$model.clear();
8024
+ }
7970
8025
  handleDragOver(event) {
7971
8026
  var _this$accessor$option2;
7972
8027
  if (!this._animState) return;
@@ -8452,6 +8507,7 @@ var TabReorderController = class extends CompositeDisposable {
8452
8507
  commitGroupMove(sourceTabGroupId, insertionIndex) {
8453
8508
  const data = getPanelData();
8454
8509
  this._tabGroupManager.disposeChipDrag(sourceTabGroupId);
8510
+ this._tabGroupManager.clearChipDropOverlays();
8455
8511
  if (this.group.model.getTabGroups().some((tg) => tg.id === sourceTabGroupId)) {
8456
8512
  var _this$accessor$option3;
8457
8513
  if (((_this$accessor$option3 = this.accessor.options.theme) === null || _this$accessor$option3 === void 0 ? void 0 : _this$accessor$option3.tabAnimation) === "smooth") {
@@ -8809,7 +8865,16 @@ var Tabs = class extends CompositeDisposable {
8809
8865
  }
8810
8866
  });
8811
8867
  this._reorder = new TabReorderController(this);
8812
- this.addDisposables(this._onOverflowTabsChange, this._observerDisposable, this._pointerActivation, this._onWillShowOverlay, this._onDrop, this._onTabDragStart, this._reorder, PointerDragController.getInstance().onDragEnd((e) => {
8868
+ const tabsListPointerTarget = pointerBackend.createDropTarget(this._tabsList, {
8869
+ acceptedTargetZones: ["center"],
8870
+ canDisplayOverlay: () => false,
8871
+ isHitTestTransparent: () => {
8872
+ const data = getPanelData();
8873
+ if ((data === null || data === void 0 ? void 0 : data.viewId) !== this.accessor.id || data.groupId !== this.group.id) return true;
8874
+ return data.panelId === null && !data.tabGroupId;
8875
+ }
8876
+ });
8877
+ this.addDisposables(tabsListPointerTarget, this._onOverflowTabsChange, this._observerDisposable, this._pointerActivation, this._onWillShowOverlay, this._onDrop, this._onTabDragStart, this._reorder, PointerDragController.getInstance().onDragEnd((e) => {
8813
8878
  this._reorder.handlePointerDragEnd(e);
8814
8879
  }), PointerDragController.getInstance().onDragMove((e) => {
8815
8880
  this._reorder.handlePointerDragMove(e.clientX, e.clientY);
@@ -9285,6 +9350,10 @@ var Tabs = class extends CompositeDisposable {
9285
9350
  * (when the source tab is currently to the left of the target slot, its
9286
9351
  * removal shifts the insertion index down by one). Always clears
9287
9352
  * `targetTabGroupId` so the dropped tab lands outside the group.
9353
+ *
9354
+ * A chip dropped on a chip is a group move: the panel path would route it
9355
+ * through the cross-group machinery, which rebuilds the tab group under a
9356
+ * new id.
9288
9357
  */
9289
9358
  _handleChipDrop(tabGroup, event) {
9290
9359
  const firstPanelId = tabGroup.panelIds[0];
@@ -9292,6 +9361,14 @@ var Tabs = class extends CompositeDisposable {
9292
9361
  const insertionIndex = this._tabs.findIndex((x) => x.value.panel.id === firstPanelId);
9293
9362
  if (insertionIndex === -1) return;
9294
9363
  const data = getPanelData();
9364
+ if (data === null || data === void 0 ? void 0 : data.tabGroupId) {
9365
+ var _animState$currentIns2;
9366
+ const animState = this._animState;
9367
+ this._animState = null;
9368
+ this._pendingCollapse = false;
9369
+ this._commitGroupMove(data.tabGroupId, (_animState$currentIns2 = animState === null || animState === void 0 ? void 0 : animState.currentInsertionIndex) !== null && _animState$currentIns2 !== void 0 ? _animState$currentIns2 : insertionIndex);
9370
+ return;
9371
+ }
9295
9372
  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;
9296
9373
  const adjustedIndex = insertionIndex - (sourceIndex !== -1 && sourceIndex < insertionIndex ? 1 : 0);
9297
9374
  this._onDrop.fire({
@@ -12396,7 +12473,6 @@ const ENTERPRISE_MODULE_NAMES = /* @__PURE__ */ new Set([
12396
12473
  "AdvancedOverflow",
12397
12474
  "AutoEdgeGroup",
12398
12475
  "AutoHideEdgeGroup",
12399
- "ContextMenu",
12400
12476
  "DndCompass",
12401
12477
  "KeyboardDocking",
12402
12478
  "KeyboardNavigation",
@@ -12478,8 +12554,8 @@ function logMissingModule(moduleName, reason) {
12478
12554
  * case: calling `undo()` having never set the option at all.
12479
12555
  *
12480
12556
  * Interaction handlers are queries in this sense too: a right-click reaching an
12481
- * absent ContextMenu module means the app never asked for one, so it stays
12482
- * silent (`?.`) and the browser's own menu shows. Options are where intent is
12557
+ * absent module means the app never asked for that feature, so it stays silent
12558
+ * (`?.`) and the browser's own behaviour applies. Options are where intent is
12483
12559
  * declared; see `optionsModules.ts`.
12484
12560
  */
12485
12561
  function assertModule(service, moduleName, context) {
@@ -12559,10 +12635,9 @@ function clearRegisteredModules() {
12559
12635
  *
12560
12636
  * This is the "declared intent" diagnostic. It fires when the user asks for a
12561
12637
  * feature via options, at construction and on every `updateOptions`. It
12562
- * deliberately does *not* fire on user interaction: right-clicking without the
12563
- * ContextMenu module stays silent (the browser's own menu shows), because the
12564
- * `?.` service-slot call sites can't tell a missing module from a feature the
12565
- * app never wanted.
12638
+ * deliberately does *not* fire on user interaction: an interaction reaching an
12639
+ * absent module stays silent, because the `?.` service-slot call sites can't
12640
+ * tell a missing module from a feature the app never wanted.
12566
12641
  *
12567
12642
  * Rules are a flat list rather than a `Record<keyof DockviewOptions, ...>`
12568
12643
  * because dockview's options are nested and value-gated: `overflow.mode:
@@ -12658,18 +12733,6 @@ const OPTION_MODULE_RULES = [
12658
12733
  moduleName: "AutoEdgeGroup",
12659
12734
  when: (o) => isAnyEdgeGroupEnabled(o.dockToEdgeGroups)
12660
12735
  },
12661
- {
12662
- optionKey: "getTabContextMenuItems",
12663
- reason: "getTabContextMenuItems",
12664
- moduleName: "ContextMenu",
12665
- when: (o) => o.getTabContextMenuItems != null
12666
- },
12667
- {
12668
- optionKey: "getTabGroupChipContextMenuItems",
12669
- reason: "getTabGroupChipContextMenuItems",
12670
- moduleName: "ContextMenu",
12671
- when: (o) => o.getTabGroupChipContextMenuItems != null
12672
- },
12673
12736
  {
12674
12737
  optionKey: "dndCompass",
12675
12738
  reason: "dndCompass",
@@ -13570,6 +13633,270 @@ const TabGroupChipsModule = defineModule({
13570
13633
  }
13571
13634
  });
13572
13635
 
13636
+ //#endregion
13637
+ //#region src/dockview/contextMenuService.ts
13638
+ function popoverZIndexFor(target, group) {
13639
+ var _group$api, _group$api$isPeeking;
13640
+ if ((_group$api = group.api) === null || _group$api === void 0 || (_group$api$isPeeking = _group$api.isPeeking) === null || _group$api$isPeeking === void 0 ? void 0 : _group$api$isPeeking.call(_group$api)) return "calc(var(--dv-overlay-z-index, 999) + 100)";
13641
+ if (!(target instanceof HTMLElement)) return;
13642
+ const relativeParent = findRelativeZIndexParent(target);
13643
+ return (relativeParent === null || relativeParent === void 0 ? void 0 : relativeParent.style.zIndex) ? `calc(${relativeParent.style.zIndex} * 2)` : void 0;
13644
+ }
13645
+ let _nextId = 0;
13646
+ const nextContextMenuItemId = () => `dv-ctx-menu-item-${_nextId++}`;
13647
+ function isItemConfig(item) {
13648
+ return typeof item === "object";
13649
+ }
13650
+ function buildItem(label, close, action, disabled) {
13651
+ const el = document.createElement("div");
13652
+ el.className = "dv-context-menu-item";
13653
+ el.setAttribute("role", "menuitem");
13654
+ if (disabled) {
13655
+ el.classList.add("dv-context-menu-item--disabled");
13656
+ el.setAttribute("aria-disabled", "true");
13657
+ }
13658
+ el.textContent = label;
13659
+ if (!disabled) el.addEventListener("click", () => {
13660
+ action();
13661
+ close();
13662
+ });
13663
+ return el;
13664
+ }
13665
+ function buildSeparator() {
13666
+ const el = document.createElement("div");
13667
+ el.className = "dv-context-menu-separator";
13668
+ el.setAttribute("role", "separator");
13669
+ return el;
13670
+ }
13671
+ function isCoarsePrimaryInput$1() {
13672
+ if (globalThis.window === void 0 || !globalThis.matchMedia) return false;
13673
+ const coarse = globalThis.matchMedia("(pointer: coarse)").matches;
13674
+ const fine = globalThis.matchMedia("(pointer: fine)").matches;
13675
+ return coarse && !fine;
13676
+ }
13677
+ function buildRenameInput(tabGroup) {
13678
+ const wrapper = document.createElement("div");
13679
+ wrapper.className = "dv-context-menu-rename";
13680
+ const input = document.createElement("input");
13681
+ input.className = "dv-context-menu-rename-input";
13682
+ input.type = "text";
13683
+ input.placeholder = "Name This Group";
13684
+ input.value = tabGroup.label;
13685
+ input.addEventListener("input", () => {
13686
+ tabGroup.setLabel(input.value);
13687
+ });
13688
+ input.addEventListener("keydown", (e) => {
13689
+ if (e.key !== "Escape" && e.key !== "Enter") e.stopPropagation();
13690
+ });
13691
+ input.addEventListener("click", (e) => {
13692
+ e.stopPropagation();
13693
+ });
13694
+ wrapper.appendChild(input);
13695
+ if (!isCoarsePrimaryInput$1()) requestAnimationFrame(() => {
13696
+ input.focus();
13697
+ input.select();
13698
+ });
13699
+ return wrapper;
13700
+ }
13701
+ function buildColorPicker(tabGroup, palette) {
13702
+ const wrapper = document.createElement("div");
13703
+ wrapper.className = "dv-context-menu-color-picker";
13704
+ if (!palette.enabled) return wrapper;
13705
+ for (const entry of palette.entries()) {
13706
+ const swatch = document.createElement("div");
13707
+ swatch.className = "dv-context-menu-color-swatch";
13708
+ swatch.style.setProperty("--dv-tab-group-color", entry.value);
13709
+ if (entry.label) swatch.title = entry.label;
13710
+ if (tabGroup.color === entry.id) swatch.classList.add("dv-context-menu-color-swatch--selected");
13711
+ swatch.addEventListener("click", () => {
13712
+ tabGroup.setColor(entry.id);
13713
+ });
13714
+ wrapper.appendChild(swatch);
13715
+ }
13716
+ return wrapper;
13717
+ }
13718
+ var ContextMenuController = class {
13719
+ constructor(accessor) {
13720
+ this.accessor = accessor;
13721
+ }
13722
+ /**
13723
+ * A single maximize/restore toggle whose label and behaviour track the
13724
+ * group's live state: it reads *Restore* + calls `exitMaximized` when the
13725
+ * group is maximized, otherwise *Maximize* + `maximize`. Only grid groups
13726
+ * can be maximized, so the item is disabled for floating / popout panels
13727
+ * that are not already maximized.
13728
+ */
13729
+ buildMaximizeItem(panel, close) {
13730
+ const isMaximized = panel.api.isMaximized();
13731
+ return buildItem(isMaximized ? "Restore" : "Maximize", close, isMaximized ? () => panel.api.exitMaximized() : () => panel.api.maximize(), !isMaximized && panel.api.location.type !== "grid");
13732
+ }
13733
+ /**
13734
+ * A single collapse/expand toggle whose label tracks the tab group's live
13735
+ * state: *Expand* when the group is already collapsed, otherwise *Collapse*.
13736
+ */
13737
+ buildCollapseItem(tabGroup, close) {
13738
+ return buildItem(tabGroup.collapsed ? "Expand" : "Collapse", close, () => tabGroup.toggle());
13739
+ }
13740
+ /**
13741
+ * Whether to auto-inject the built-in Pin/Unpin item at the top of the tab
13742
+ * menu. True only when the PinnedTabs module is registered, pinning is
13743
+ * enabled, and the app has not opted out via `pinnedTabs.contextMenuItem:
13744
+ * false` (the item is on by default). This keeps pinning reachable from the
13745
+ * menu without the app having to return `'pin'` from
13746
+ * `getTabContextMenuItems` itself.
13747
+ */
13748
+ _shouldInjectPin() {
13749
+ const pinnedTabs = this.accessor.options.pinnedTabs;
13750
+ return !!this.accessor.pinnedTabsService && !!(pinnedTabs === null || pinnedTabs === void 0 ? void 0 : pinnedTabs.enabled) && pinnedTabs.contextMenuItem !== false;
13751
+ }
13752
+ /**
13753
+ * The tab menu items: the app's own items (if any) with the built-in
13754
+ * `'pin'` item prepended when {@link _shouldInjectPin} applies, so the app
13755
+ * keeps full control of its list, and pinning is added without disturbing
13756
+ * it. Reuses the existing `'pin'` token rendering below.
13757
+ */
13758
+ _resolveTabItems(panel, group, event) {
13759
+ var _this$accessor$option, _this$accessor$option2, _this$accessor$option3;
13760
+ const appItems = (_this$accessor$option = (_this$accessor$option2 = (_this$accessor$option3 = this.accessor.options).getTabContextMenuItems) === null || _this$accessor$option2 === void 0 ? void 0 : _this$accessor$option2.call(_this$accessor$option3, {
13761
+ panel,
13762
+ group,
13763
+ api: this.accessor.api,
13764
+ event
13765
+ })) !== null && _this$accessor$option !== void 0 ? _this$accessor$option : [];
13766
+ return this._shouldInjectPin() ? ["pin", ...appItems] : appItems;
13767
+ }
13768
+ /**
13769
+ * Render a custom `component` menu item and append it to `menuEl`. Builds
13770
+ * the framework renderer via the host's `createContextMenuItemComponent`
13771
+ * factory and initialises it. Shared by the tab menu and the chip menu,
13772
+ * which differ only in `identity`: the tab menu passes the `panel`, the chip
13773
+ * menu passes the `tabGroup`. No-op when no renderer could be created (no
13774
+ * factory configured, or the factory declined the component).
13775
+ */
13776
+ appendComponentItem(menuEl, item, identity, group, close) {
13777
+ var _this$accessor$option4, _this$accessor$option5;
13778
+ const renderer = (_this$accessor$option4 = (_this$accessor$option5 = this.accessor.options).createContextMenuItemComponent) === null || _this$accessor$option4 === void 0 ? void 0 : _this$accessor$option4.call(_this$accessor$option5, {
13779
+ id: nextContextMenuItemId(),
13780
+ component: item.component
13781
+ });
13782
+ if (!renderer) return;
13783
+ renderer.init(_objectSpread2(_objectSpread2({}, identity), {}, {
13784
+ group,
13785
+ api: this.accessor.api,
13786
+ close,
13787
+ componentProps: item.componentProps
13788
+ }));
13789
+ menuEl.appendChild(renderer.element);
13790
+ }
13791
+ /**
13792
+ * The element for one built-in tab item, or `undefined` for a token this
13793
+ * version doesn't know (an app on a newer typings version, or plain JS):
13794
+ * an unrecognised token renders nothing rather than throwing.
13795
+ */
13796
+ buildBuiltInTabItem(item, panel, group, close) {
13797
+ switch (item) {
13798
+ case "separator": return buildSeparator();
13799
+ case "close": return buildItem("Close", close, () => panel.api.close());
13800
+ case "closeOthers": return buildItem("Close Others", close, () => {
13801
+ group.panels.filter((p) => p !== panel).forEach((p) => p.api.close());
13802
+ });
13803
+ case "closeAll": return buildItem("Close All", close, () => {
13804
+ [...group.panels].forEach((p) => p.api.close());
13805
+ });
13806
+ case "closeLeft": {
13807
+ const index = group.panels.indexOf(panel);
13808
+ return buildItem("Close to the Left", close, () => {
13809
+ group.panels.filter((_, i) => i < index).forEach((p) => p.api.close());
13810
+ }, index <= 0);
13811
+ }
13812
+ case "closeRight": {
13813
+ const index = group.panels.indexOf(panel);
13814
+ return buildItem("Close to the Right", close, () => {
13815
+ group.panels.filter((_, i) => i > index).forEach((p) => p.api.close());
13816
+ }, index === -1 || index >= group.panels.length - 1);
13817
+ }
13818
+ case "maximize": return this.buildMaximizeItem(panel, close);
13819
+ case "float": return buildItem("Float", close, () => this.accessor.api.addFloatingGroup(panel), panel.api.location.type === "floating");
13820
+ case "popout": return buildItem("Open in New Window", close, () => {
13821
+ this.accessor.api.addPopoutGroup(panel);
13822
+ }, panel.api.location.type === "popout");
13823
+ case "pin": return buildItem(panel.api.isPinned ? "Unpin tab" : "Pin tab", close, () => panel.api.setPinned(!panel.api.isPinned));
13824
+ default: return;
13825
+ }
13826
+ }
13827
+ /**
13828
+ * Append one app-supplied item. A raw `element` is used as-is, a
13829
+ * `component` goes through the framework renderer, and a `label` builds the
13830
+ * default row; an item carrying none of the three renders nothing. Shared
13831
+ * by both menus, which differ only in `identity`.
13832
+ */
13833
+ appendConfigItem(menuEl, item, identity, group, close) {
13834
+ if (item.element) menuEl.appendChild(item.element);
13835
+ else if (item.component) this.appendComponentItem(menuEl, item, identity, group, close);
13836
+ else if (item.label) menuEl.appendChild(buildItem(item.label, close, () => {
13837
+ var _item$action;
13838
+ return (_item$action = item.action) === null || _item$action === void 0 ? void 0 : _item$action.call(item);
13839
+ }, item.disabled));
13840
+ }
13841
+ show(panel, group, event) {
13842
+ const items = this._resolveTabItems(panel, group, event);
13843
+ if (items.length === 0) return;
13844
+ event.preventDefault();
13845
+ const popupService = this.accessor.getPopupServiceForGroup(group);
13846
+ const close = () => popupService.close();
13847
+ const menuEl = document.createElement("div");
13848
+ menuEl.className = "dv-context-menu";
13849
+ menuEl.setAttribute("role", "menu");
13850
+ for (const item of items) {
13851
+ if (isItemConfig(item)) {
13852
+ this.appendConfigItem(menuEl, item, { panel }, group, close);
13853
+ continue;
13854
+ }
13855
+ const el = this.buildBuiltInTabItem(item, panel, group, close);
13856
+ if (el) menuEl.appendChild(el);
13857
+ }
13858
+ popupService.openPopover(menuEl, {
13859
+ x: event.clientX,
13860
+ y: event.clientY,
13861
+ zIndex: popoverZIndexFor(event.target, group)
13862
+ });
13863
+ }
13864
+ showForChip(tabGroup, group, event) {
13865
+ if (!this.accessor.options.getTabGroupChipContextMenuItems) return;
13866
+ const items = this.accessor.options.getTabGroupChipContextMenuItems({
13867
+ tabGroup,
13868
+ group,
13869
+ api: this.accessor.api,
13870
+ event
13871
+ });
13872
+ if (items.length === 0) return;
13873
+ event.preventDefault();
13874
+ const popupService = this.accessor.getPopupServiceForGroup(group);
13875
+ const close = () => popupService.close();
13876
+ const menuEl = document.createElement("div");
13877
+ menuEl.className = "dv-context-menu";
13878
+ menuEl.setAttribute("role", "menu");
13879
+ for (const item of items) if (item === "separator") menuEl.appendChild(buildSeparator());
13880
+ else if (item === "rename") menuEl.appendChild(buildRenameInput(tabGroup));
13881
+ else if (item === "colorPicker") menuEl.appendChild(buildColorPicker(tabGroup, this.accessor.tabGroupColorPalette));
13882
+ else if (item === "collapse") menuEl.appendChild(this.buildCollapseItem(tabGroup, close));
13883
+ else if (item === "close") menuEl.appendChild(buildItem("Close All", close, () => {
13884
+ group.panels.filter((p) => tabGroup.containsPanel(p.id)).forEach((p) => p.api.close());
13885
+ }));
13886
+ else if (isItemConfig(item)) this.appendConfigItem(menuEl, item, { tabGroup }, group, close);
13887
+ popupService.openPopover(menuEl, {
13888
+ x: event.clientX,
13889
+ y: event.clientY,
13890
+ zIndex: popoverZIndexFor(event.target, group)
13891
+ });
13892
+ }
13893
+ };
13894
+ const ContextMenuModule = defineModule({
13895
+ name: "ContextMenu",
13896
+ serviceKey: "contextMenuService",
13897
+ create: (host) => new ContextMenuController(host)
13898
+ });
13899
+
13573
13900
  //#endregion
13574
13901
  //#region src/dockview/allModules.ts
13575
13902
  /**
@@ -13587,7 +13914,8 @@ const AllModules = [
13587
13914
  HeaderActionsModule,
13588
13915
  LiveRegionModule,
13589
13916
  AdvancedDnDModule,
13590
- TabGroupChipsModule
13917
+ TabGroupChipsModule,
13918
+ ContextMenuModule
13591
13919
  ];
13592
13920
 
13593
13921
  //#endregion
@@ -14279,6 +14607,14 @@ var PopupService = class extends CompositeDisposable {
14279
14607
  //#endregion
14280
14608
  //#region src/dnd/dropTargetAnchorContainer.ts
14281
14609
  var DropTargetAnchorContainer = class extends CompositeDisposable {
14610
+ /**
14611
+ * The element the live overlay was rendered for, `undefined` when nothing
14612
+ * is showing. The container is shared by every drop target, so a caller
14613
+ * tearing down only its own overlay must check this before `clear()`.
14614
+ */
14615
+ get renderedOutline() {
14616
+ return this._model ? this._outline : void 0;
14617
+ }
14282
14618
  get disabled() {
14283
14619
  return this._disabled;
14284
14620
  }
@@ -14583,6 +14919,10 @@ var MiddleColumnView = class {
14583
14919
  const index = position === "top" ? this._topIndex : this._bottomIndex;
14584
14920
  if (index !== void 0) this._splitview.resizeView(index, size);
14585
14921
  }
14922
+ /** The inner splitview's primary-axis (height) extent; zero until laid out. */
14923
+ get axisSize() {
14924
+ return this._splitview.size;
14925
+ }
14586
14926
  updateMargin(gap) {
14587
14927
  this._splitview.margin = gap;
14588
14928
  }
@@ -14595,6 +14935,7 @@ var ShellManager = class {
14595
14935
  constructor(container, dockviewElement, layoutGrid, gap = 0, defaultCollapsedSize = 35) {
14596
14936
  this._disposables = new CompositeDisposable();
14597
14937
  this._viewConfigs = /* @__PURE__ */ new Map();
14938
+ this._pendingSizes = /* @__PURE__ */ new Map();
14598
14939
  this._currentWidth = 0;
14599
14940
  this._currentHeight = 0;
14600
14941
  this._gap = gap;
@@ -14685,11 +15026,13 @@ var ShellManager = class {
14685
15026
  break;
14686
15027
  }
14687
15028
  this._disposables.addDisposables(view);
15029
+ if (!view.isCollapsed && !this._canResize(position)) this._pendingSizes.set(position, initialSize);
14688
15030
  this.updateTheme(this._gap, this._defaultCollapsedSize);
14689
15031
  return view;
14690
15032
  }
14691
15033
  layout(width, height) {
14692
15034
  this._outerSplitview.layout(width, height);
15035
+ this._flushPendingSizes();
14693
15036
  }
14694
15037
  /**
14695
15038
  * Called when the active theme changes. Updates splitview margins and
@@ -14753,6 +15096,7 @@ var ShellManager = class {
14753
15096
  this._disposables.removeDisposable(view);
14754
15097
  view.dispose();
14755
15098
  this._viewConfigs.delete(position);
15099
+ this._pendingSizes.delete(position);
14756
15100
  this.updateTheme(this._gap, this._defaultCollapsedSize);
14757
15101
  }
14758
15102
  hasEdgeGroup(position) {
@@ -14776,6 +15120,7 @@ var ShellManager = class {
14776
15120
  this._middleColumn.setViewVisible(position, visible);
14777
15121
  break;
14778
15122
  }
15123
+ if (visible) this._flushPendingSizes();
14779
15124
  }
14780
15125
  isEdgeGroupVisible(position) {
14781
15126
  switch (position) {
@@ -14793,20 +15138,63 @@ var ShellManager = class {
14793
15138
  const view = this._getView(position);
14794
15139
  if (!view) return;
14795
15140
  view.setCollapsed(collapsed);
14796
- const targetSize = collapsed ? view.collapsedSize : view.lastExpandedSize;
15141
+ if (collapsed) {
15142
+ this._pendingSizes.delete(position);
15143
+ this._resizeView(position, view.collapsedSize);
15144
+ } else this.resizeEdgeGroup(position, view.lastExpandedSize);
15145
+ }
15146
+ /**
15147
+ * Resize the edge group at `position` along its primary axis (width for
15148
+ * `left`/`right`, height for `top`/`bottom`), clamped by the group's
15149
+ * constraints and the space available. Where `groupApi.setSize` lands.
15150
+ *
15151
+ * The size becomes the group's expanded size, so a collapsed group keeps
15152
+ * its strip and takes it on expand, and it survives a `toJSON` round-trip.
15153
+ */
15154
+ resizeEdgeGroup(position, size) {
15155
+ const view = this._getView(position);
15156
+ if (!view || !Number.isFinite(size)) return;
15157
+ const target = Math.round(size);
15158
+ if (target <= 0) return;
15159
+ view.restoreExpandedSize(target);
15160
+ if (view.isCollapsed) {
15161
+ this._pendingSizes.delete(position);
15162
+ return;
15163
+ }
15164
+ if (this._canResize(position)) {
15165
+ this._pendingSizes.delete(position);
15166
+ this._resizeView(position, target);
15167
+ } else this._pendingSizes.set(position, target);
15168
+ }
15169
+ /** A resize lands only on a visible view (a hidden one is pinned to zero)
15170
+ * whose splitview has extent to distribute. */
15171
+ _canResize(position) {
15172
+ if (!this.isEdgeGroupVisible(position)) return false;
15173
+ return (position === "left" || position === "right" ? this._outerSplitview.size : this._middleColumn.axisSize) > 0;
15174
+ }
15175
+ _resizeView(position, size) {
14797
15176
  switch (position) {
14798
15177
  case "left":
14799
- if (this._leftIndex !== void 0) this._outerSplitview.resizeView(this._leftIndex, targetSize);
15178
+ if (this._leftIndex !== void 0) this._outerSplitview.resizeView(this._leftIndex, size);
14800
15179
  break;
14801
15180
  case "right":
14802
- if (this._rightIndex !== void 0) this._outerSplitview.resizeView(this._rightIndex, targetSize);
15181
+ if (this._rightIndex !== void 0) this._outerSplitview.resizeView(this._rightIndex, size);
14803
15182
  break;
14804
15183
  case "top":
14805
15184
  case "bottom":
14806
- this._middleColumn.resizeView(position, targetSize);
15185
+ this._middleColumn.resizeView(position, size);
14807
15186
  break;
14808
15187
  }
14809
15188
  }
15189
+ _flushPendingSizes() {
15190
+ if (this._pendingSizes.size === 0) return;
15191
+ for (const [position, size] of this._pendingSizes) {
15192
+ const view = this._getView(position);
15193
+ if (!view || view.isCollapsed || !this._canResize(position)) continue;
15194
+ this._pendingSizes.delete(position);
15195
+ this._resizeView(position, size);
15196
+ }
15197
+ }
14810
15198
  isEdgeGroupCollapsed(position) {
14811
15199
  var _this$_getView$isColl, _this$_getView;
14812
15200
  return (_this$_getView$isColl = (_this$_getView = this._getView(position)) === null || _this$_getView === void 0 ? void 0 : _this$_getView.isCollapsed) !== null && _this$_getView$isColl !== void 0 ? _this$_getView$isColl : false;
@@ -14832,15 +15220,17 @@ var ShellManager = class {
14832
15220
  maximumSize: Number.isFinite(view.configuredMaximumSize) ? view.configuredMaximumSize : void 0,
14833
15221
  collapsedSize: view.configuredCollapsedSize
14834
15222
  });
14835
- const expandedSize = (view, isVisible, liveSize, cachedVisibleSize) => {
15223
+ const expandedSize = (view, position, isVisible, liveSize, cachedVisibleSize) => {
14836
15224
  if (view.isCollapsed) return view.lastExpandedSize;
15225
+ const pending = this._pendingSizes.get(position);
15226
+ if (pending !== void 0) return pending;
14837
15227
  if (!isVisible) return cachedVisibleSize !== null && cachedVisibleSize !== void 0 ? cachedVisibleSize : view.lastExpandedSize;
14838
15228
  return liveSize;
14839
15229
  };
14840
15230
  if (this._leftView && this._leftIndex !== void 0) {
14841
15231
  const visible = this._outerSplitview.isViewVisible(this._leftIndex);
14842
15232
  edgeGroups.left = _objectSpread2({
14843
- size: expandedSize(this._leftView, visible, this._outerSplitview.getViewSize(this._leftIndex), this._outerSplitview.getViewCachedVisibleSize(this._leftIndex)),
15233
+ size: expandedSize(this._leftView, "left", visible, this._outerSplitview.getViewSize(this._leftIndex), this._outerSplitview.getViewCachedVisibleSize(this._leftIndex)),
14844
15234
  visible,
14845
15235
  collapsed: this._leftView.isCollapsed || void 0
14846
15236
  }, constraints(this._leftView));
@@ -14848,7 +15238,7 @@ var ShellManager = class {
14848
15238
  if (this._rightView && this._rightIndex !== void 0) {
14849
15239
  const visible = this._outerSplitview.isViewVisible(this._rightIndex);
14850
15240
  edgeGroups.right = _objectSpread2({
14851
- size: expandedSize(this._rightView, visible, this._outerSplitview.getViewSize(this._rightIndex), this._outerSplitview.getViewCachedVisibleSize(this._rightIndex)),
15241
+ size: expandedSize(this._rightView, "right", visible, this._outerSplitview.getViewSize(this._rightIndex), this._outerSplitview.getViewCachedVisibleSize(this._rightIndex)),
14852
15242
  visible,
14853
15243
  collapsed: this._rightView.isCollapsed || void 0
14854
15244
  }, constraints(this._rightView));
@@ -14856,7 +15246,7 @@ var ShellManager = class {
14856
15246
  if (this._topView) {
14857
15247
  const visible = this._middleColumn.isViewVisible("top");
14858
15248
  edgeGroups.top = _objectSpread2({
14859
- size: expandedSize(this._topView, visible, this._middleColumn.getViewSize("top"), this._middleColumn.getViewCachedVisibleSize("top")),
15249
+ size: expandedSize(this._topView, "top", visible, this._middleColumn.getViewSize("top"), this._middleColumn.getViewCachedVisibleSize("top")),
14860
15250
  visible,
14861
15251
  collapsed: this._topView.isCollapsed || void 0
14862
15252
  }, constraints(this._topView));
@@ -14864,7 +15254,7 @@ var ShellManager = class {
14864
15254
  if (this._bottomView) {
14865
15255
  const visible = this._middleColumn.isViewVisible("bottom");
14866
15256
  edgeGroups.bottom = _objectSpread2({
14867
- size: expandedSize(this._bottomView, visible, this._middleColumn.getViewSize("bottom"), this._middleColumn.getViewCachedVisibleSize("bottom")),
15257
+ size: expandedSize(this._bottomView, "bottom", visible, this._middleColumn.getViewSize("bottom"), this._middleColumn.getViewCachedVisibleSize("bottom")),
14868
15258
  visible,
14869
15259
  collapsed: this._bottomView.isCollapsed || void 0
14870
15260
  }, constraints(this._bottomView));
@@ -14872,33 +15262,23 @@ var ShellManager = class {
14872
15262
  return edgeGroups;
14873
15263
  }
14874
15264
  fromJSON(data) {
14875
- if (data.left && this._leftIndex !== void 0) {
14876
- var _this$_leftView2, _this$_leftView3, _data$left$collapsed, _this$_leftView$colla, _this$_leftView4;
14877
- (_this$_leftView2 = this._leftView) === null || _this$_leftView2 === void 0 || _this$_leftView2.restoreExpandedSize(data.left.size);
14878
- (_this$_leftView3 = this._leftView) === null || _this$_leftView3 === void 0 || _this$_leftView3.setCollapsed((_data$left$collapsed = data.left.collapsed) !== null && _data$left$collapsed !== void 0 ? _data$left$collapsed : false);
14879
- this._outerSplitview.resizeView(this._leftIndex, data.left.collapsed ? (_this$_leftView$colla = (_this$_leftView4 = this._leftView) === null || _this$_leftView4 === void 0 ? void 0 : _this$_leftView4.collapsedSize) !== null && _this$_leftView$colla !== void 0 ? _this$_leftView$colla : data.left.size : data.left.size);
14880
- if (!data.left.visible) this._outerSplitview.setViewVisible(this._leftIndex, false);
14881
- }
14882
- if (data.right && this._rightIndex !== void 0) {
14883
- var _this$_rightView2, _this$_rightView3, _data$right$collapsed, _this$_rightView$coll, _this$_rightView4;
14884
- (_this$_rightView2 = this._rightView) === null || _this$_rightView2 === void 0 || _this$_rightView2.restoreExpandedSize(data.right.size);
14885
- (_this$_rightView3 = this._rightView) === null || _this$_rightView3 === void 0 || _this$_rightView3.setCollapsed((_data$right$collapsed = data.right.collapsed) !== null && _data$right$collapsed !== void 0 ? _data$right$collapsed : false);
14886
- this._outerSplitview.resizeView(this._rightIndex, data.right.collapsed ? (_this$_rightView$coll = (_this$_rightView4 = this._rightView) === null || _this$_rightView4 === void 0 ? void 0 : _this$_rightView4.collapsedSize) !== null && _this$_rightView$coll !== void 0 ? _this$_rightView$coll : data.right.size : data.right.size);
14887
- if (!data.right.visible) this._outerSplitview.setViewVisible(this._rightIndex, false);
14888
- }
14889
- if (data.top) {
14890
- var _this$_topView2, _this$_topView3, _data$top$collapsed, _this$_topView$collap, _this$_topView4;
14891
- (_this$_topView2 = this._topView) === null || _this$_topView2 === void 0 || _this$_topView2.restoreExpandedSize(data.top.size);
14892
- (_this$_topView3 = this._topView) === null || _this$_topView3 === void 0 || _this$_topView3.setCollapsed((_data$top$collapsed = data.top.collapsed) !== null && _data$top$collapsed !== void 0 ? _data$top$collapsed : false);
14893
- this._middleColumn.resizeView("top", data.top.collapsed ? (_this$_topView$collap = (_this$_topView4 = this._topView) === null || _this$_topView4 === void 0 ? void 0 : _this$_topView4.collapsedSize) !== null && _this$_topView$collap !== void 0 ? _this$_topView$collap : data.top.size : data.top.size);
14894
- if (!data.top.visible) this._middleColumn.setViewVisible("top", false);
14895
- }
14896
- if (data.bottom) {
14897
- var _this$_bottomView2, _this$_bottomView3, _data$bottom$collapse, _this$_bottomView$col, _this$_bottomView4;
14898
- (_this$_bottomView2 = this._bottomView) === null || _this$_bottomView2 === void 0 || _this$_bottomView2.restoreExpandedSize(data.bottom.size);
14899
- (_this$_bottomView3 = this._bottomView) === null || _this$_bottomView3 === void 0 || _this$_bottomView3.setCollapsed((_data$bottom$collapse = data.bottom.collapsed) !== null && _data$bottom$collapse !== void 0 ? _data$bottom$collapse : false);
14900
- this._middleColumn.resizeView("bottom", data.bottom.collapsed ? (_this$_bottomView$col = (_this$_bottomView4 = this._bottomView) === null || _this$_bottomView4 === void 0 ? void 0 : _this$_bottomView4.collapsedSize) !== null && _this$_bottomView$col !== void 0 ? _this$_bottomView$col : data.bottom.size : data.bottom.size);
14901
- if (!data.bottom.visible) this._middleColumn.setViewVisible("bottom", false);
15265
+ for (const position of [
15266
+ "left",
15267
+ "right",
15268
+ "top",
15269
+ "bottom"
15270
+ ]) {
15271
+ var _state$collapsed;
15272
+ const state = data[position];
15273
+ const view = this._getView(position);
15274
+ if (!state || !view) continue;
15275
+ view.restoreExpandedSize(state.size);
15276
+ view.setCollapsed((_state$collapsed = state.collapsed) !== null && _state$collapsed !== void 0 ? _state$collapsed : false);
15277
+ if (state.collapsed) {
15278
+ this._pendingSizes.delete(position);
15279
+ this._resizeView(position, view.collapsedSize);
15280
+ } else this.resizeEdgeGroup(position, state.size);
15281
+ this.setEdgeGroupVisible(position, !!state.visible);
14902
15282
  }
14903
15283
  }
14904
15284
  dispose() {
@@ -16066,10 +16446,11 @@ var DockviewComponent = class extends BaseGrid {
16066
16446
  group = this.createGroup();
16067
16447
  this._onDidAddGroup.fire(group);
16068
16448
  this.movingLock(() => this.removePanel(item, {
16069
- removeEmptyGroup: true,
16449
+ removeEmptyGroup: false,
16070
16450
  skipDispose: true,
16071
16451
  skipSetActiveGroup: true
16072
16452
  }));
16453
+ this.removeGroupIfEmpty(sourceGroup);
16073
16454
  this.movingLock(() => group.model.openPanel(item, { skipSetGroupActive: true }));
16074
16455
  movedPanels = [{
16075
16456
  panel: item,
@@ -16140,6 +16521,9 @@ var DockviewComponent = class extends BaseGrid {
16140
16521
  });
16141
16522
  for (const { panel, from } of movedPanels) this.fireDidMovePanel(panel, from);
16142
16523
  }
16524
+ removeGroupIfEmpty(group) {
16525
+ if (group.model.size === 0) this.doRemoveGroup(group, { skipActive: true });
16526
+ }
16143
16527
  /**
16144
16528
  * Build an empty gridview configured to match the main grid's styling, for
16145
16529
  * hosting a nested layout inside a floating or popout window.
@@ -16283,6 +16667,13 @@ var DockviewComponent = class extends BaseGrid {
16283
16667
  position
16284
16668
  };
16285
16669
  group.model.headerPosition = position;
16670
+ const resizeDisposable = group.onDidChange((event) => {
16671
+ var _this$_shellManager3;
16672
+ if (!event) return;
16673
+ const size = position === "left" || position === "right" ? event.width : event.height;
16674
+ if (typeof size !== "number") return;
16675
+ (_this$_shellManager3 = this._shellManager) === null || _this$_shellManager3 === void 0 || _this$_shellManager3.resizeEdgeGroup(position, size);
16676
+ });
16286
16677
  const autoCollapseDisposable = group.model.onDidRemovePanel(() => {
16287
16678
  if (!group.model.isEmpty) return;
16288
16679
  if (service.isAutoReveal(group)) queueMicrotask(() => {
@@ -16291,7 +16682,7 @@ var DockviewComponent = class extends BaseGrid {
16291
16682
  });
16292
16683
  else this.setEdgeGroupCollapsed(group, true);
16293
16684
  });
16294
- service.add(position, group, autoCollapseDisposable);
16685
+ service.add(position, group, new CompositeDisposable(autoCollapseDisposable, resizeDisposable));
16295
16686
  if (options.autoHide !== void 0) service.setAutoHide(group, options.autoHide);
16296
16687
  if (options.autoReveal !== void 0) service.setAutoReveal(group, options.autoReveal);
16297
16688
  this._onDidAddGroup.fire(group);
@@ -16386,8 +16777,8 @@ var DockviewComponent = class extends BaseGrid {
16386
16777
  }
16387
16778
  /** The size an edge group expands to (pre-collapse); sizes the peek. */
16388
16779
  getEdgeGroupExpandedSize(position) {
16389
- var _this$_shellManager$g, _this$_shellManager3;
16390
- return (_this$_shellManager$g = (_this$_shellManager3 = this._shellManager) === null || _this$_shellManager3 === void 0 ? void 0 : _this$_shellManager3.getEdgeGroupExpandedSize(position)) !== null && _this$_shellManager$g !== void 0 ? _this$_shellManager$g : 0;
16780
+ var _this$_shellManager$g, _this$_shellManager4;
16781
+ return (_this$_shellManager$g = (_this$_shellManager4 = this._shellManager) === null || _this$_shellManager4 === void 0 ? void 0 : _this$_shellManager4.getEdgeGroupExpandedSize(position)) !== null && _this$_shellManager$g !== void 0 ? _this$_shellManager$g : 0;
16391
16782
  }
16392
16783
  /** Reposition a single `renderer:'always'` panel's overlay over its
16393
16784
  * reference container, optionally forcing it visible (the auto-hide peek
@@ -17548,7 +17939,7 @@ var DockviewComponent = class extends BaseGrid {
17548
17939
  }));
17549
17940
  this.doRemoveGroup(sourceGroup, { skipActive: true });
17550
17941
  const updatedTargetLocation = getRelativeLocation(destinationGridview.orientation, getGridLocation(destinationGroup.element), destinationTarget);
17551
- const newGroup = this.createGroupAtLocation(updatedTargetLocation, void 0, void 0, destinationGridview);
17942
+ const newGroup = this.createGroupAtLocation(updatedTargetLocation, this.dropSizing(getGridLocation(destinationGroup.element)), void 0, destinationGridview);
17552
17943
  this.movingLock(() => newGroup.model.openPanel(removedPanel, { skipSetActive: true }));
17553
17944
  this.doSetGroupAndPanelActive(newGroup);
17554
17945
  this.fireDidMovePanel(this.getGroupPanel(sourceItemId), sourceGroup);
@@ -17565,7 +17956,7 @@ var DockviewComponent = class extends BaseGrid {
17565
17956
  skipSetActiveGroup: true
17566
17957
  }));
17567
17958
  if (!removedPanel) throw new Error(`dockview: No panel with id ${sourceItemId}`);
17568
- const newGroup = this.createGroupAtLocation(targetLocation, void 0, void 0, destinationGridview);
17959
+ const newGroup = this.createGroupAtLocation(targetLocation, this.dropSizing(referenceLocation), void 0, destinationGridview);
17569
17960
  this.movingLock(() => newGroup.model.openPanel(removedPanel, { skipSetGroupActive: true }));
17570
17961
  this.doSetGroupAndPanelActive(newGroup);
17571
17962
  this.fireDidMovePanel(removedPanel, sourceGroup);
@@ -17577,7 +17968,7 @@ var DockviewComponent = class extends BaseGrid {
17577
17968
  }));
17578
17969
  const updatedReferenceLocation = getGridLocation(destinationGroup.element);
17579
17970
  const location = getRelativeLocation(destinationGridview.orientation, updatedReferenceLocation, destinationTarget);
17580
- this.movingLock(() => this.doAddGroup(targetGroup, location, void 0, destinationGridview));
17971
+ this.movingLock(() => this.doAddGroup(targetGroup, location, this.dropSizing(updatedReferenceLocation), destinationGridview));
17581
17972
  this.setGroupLocationForRoot(targetGroup, destinationGridview);
17582
17973
  this.doSetGroupAndPanelActive(targetGroup);
17583
17974
  this.fireDidMovePanel(this.getGroupPanel(sourceItemId), sourceGroup);
@@ -17592,7 +17983,7 @@ var DockviewComponent = class extends BaseGrid {
17592
17983
  }));
17593
17984
  if (!removedPanel) throw new Error(`dockview: No panel with id ${sourceItemId}`);
17594
17985
  const dropLocation = getRelativeLocation(destinationGridview.orientation, referenceLocation, destinationTarget);
17595
- const group = this.createGroupAtLocation(dropLocation, void 0, void 0, destinationGridview);
17986
+ const group = this.createGroupAtLocation(dropLocation, this.dropSizing(referenceLocation), void 0, destinationGridview);
17596
17987
  this.movingLock(() => group.model.openPanel(removedPanel, { skipSetGroupActive: true }));
17597
17988
  this.doSetGroupAndPanelActive(group);
17598
17989
  this.fireDidMovePanel(removedPanel, sourceGroup);
@@ -17636,7 +18027,7 @@ var DockviewComponent = class extends BaseGrid {
17636
18027
  if (!destinationTarget || destinationTarget === "center" || !referenceLocation) targetGroup = destinationGroup;
17637
18028
  else {
17638
18029
  const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, destinationTarget);
17639
- targetGroup = this.createGroupAtLocation(dropLocation);
18030
+ targetGroup = this.createGroupAtLocation(dropLocation, this.dropSizing(referenceLocation));
17640
18031
  }
17641
18032
  if (!options.keepEmptyGroups && sourceGroup.model.size === 0 && sourceGroup !== targetGroup) this.doRemoveGroup(sourceGroup, { skipActive: true });
17642
18033
  addPanelsToGroup(targetGroup);
@@ -17687,6 +18078,21 @@ var DockviewComponent = class extends BaseGrid {
17687
18078
  if (options.skipSetActive !== true) this.doSetGroupAndPanelActive(to);
17688
18079
  else if (!this.activePanel) this.doSetGroupAndPanelActive(to);
17689
18080
  } else {
18081
+ const isReorderWithinBranch = (() => {
18082
+ if (from.api.location.type === "edge" || to.api.location.type === "edge") return false;
18083
+ const root = this.getGridviewForGroup(from);
18084
+ if (root !== this.getGridviewForGroup(to)) return false;
18085
+ let fromLocation;
18086
+ let toLocation;
18087
+ try {
18088
+ fromLocation = getGridLocation(from.element);
18089
+ toLocation = getGridLocation(to.element);
18090
+ } catch (_unused) {
18091
+ return false;
18092
+ }
18093
+ if (fromLocation.length === 0 || toLocation.length === 0) return false;
18094
+ return sequenceEquals(tail(fromLocation)[0], tail(toLocation)[0]) && getLocationOrientation(root.orientation, toLocation) === getDirectionOrientation(target);
18095
+ })();
17690
18096
  if (from.api.location.type === "edge") {
17691
18097
  /**
17692
18098
  * Edge groups are permanent structural elements and must
@@ -17752,13 +18158,10 @@ var DockviewComponent = class extends BaseGrid {
17752
18158
  const referenceLocation = getGridLocation(to.element);
17753
18159
  const dropLocation = getRelativeLocation(destGridview.orientation, referenceLocation, target);
17754
18160
  let size;
17755
- switch (destGridview.orientation) {
17756
- case "VERTICAL":
17757
- size = referenceLocation.length % 2 == 0 ? from.api.width : from.api.height;
17758
- break;
17759
- case "HORIZONTAL":
17760
- size = referenceLocation.length % 2 == 0 ? from.api.height : from.api.width;
17761
- break;
18161
+ if (isReorderWithinBranch) size = getDirectionOrientation(target) === "HORIZONTAL" ? from.api.width : from.api.height;
18162
+ else {
18163
+ var _referenceLocation;
18164
+ size = Sizing.Split((_referenceLocation = referenceLocation[referenceLocation.length - 1]) !== null && _referenceLocation !== void 0 ? _referenceLocation : 0);
17762
18165
  }
17763
18166
  destGridview.addView(source, size, dropLocation);
17764
18167
  this.setGroupLocationForRoot(source, destGridview);
@@ -17883,6 +18286,16 @@ var DockviewComponent = class extends BaseGrid {
17883
18286
  });
17884
18287
  return panel;
17885
18288
  }
18289
+ /**
18290
+ * Sizing for a group created by a drop next to `referenceLocation`: half
18291
+ * of the group the overlay was drawn over, leaving its siblings alone, so
18292
+ * the panel lands in the region the overlay indicated (#1612). Gridview
18293
+ * rewrites the index to 0 when a cross-axis drop wraps the reference in a
18294
+ * new branch, so one value serves both paths.
18295
+ */
18296
+ dropSizing(referenceLocation) {
18297
+ return Sizing.Split(referenceLocation.length === 0 ? 0 : referenceLocation[referenceLocation.length - 1]);
18298
+ }
17886
18299
  createGroupAtLocation(location, size, options, gridview = this.gridview) {
17887
18300
  const group = this.createGroup(options);
17888
18301
  this.doAddGroup(group, location, size, gridview);
@@ -17942,22 +18355,22 @@ var DockviewComponent = class extends BaseGrid {
17942
18355
  return location.length % 2 == 1 ? rootOrientation : orthogonal(rootOrientation);
17943
18356
  }
17944
18357
  updateTheme() {
17945
- var _this$_options$theme, _this$_shellThemeClas, _theme$gap, _this$_popoutWindowSe23, _this$_popoutWindowSe24, _this$_shellManager4, _theme$edgeGroupColla, _theme$tabGroupIndica;
18358
+ var _this$_options$theme, _this$_shellThemeClas, _theme$gap, _this$_popoutWindowSe23, _this$_popoutWindowSe24, _this$_shellManager5, _theme$edgeGroupColla, _theme$tabGroupIndica;
17946
18359
  const theme = (_this$_options$theme = this._options.theme) !== null && _this$_options$theme !== void 0 ? _this$_options$theme : themeAbyss;
17947
18360
  (_this$_shellThemeClas = this._shellThemeClassnames) === null || _this$_shellThemeClas === void 0 || _this$_shellThemeClas.setClassNames(theme.className);
17948
18361
  const gap = (_theme$gap = theme.gap) !== null && _theme$gap !== void 0 ? _theme$gap : 0;
17949
18362
  this.gridview.margin = gap;
17950
18363
  for (const floating of this.floatingGroups) floating.gridview.margin = gap;
17951
18364
  for (const entry of (_this$_popoutWindowSe23 = (_this$_popoutWindowSe24 = this._popoutWindowService) === null || _this$_popoutWindowSe24 === void 0 ? void 0 : _this$_popoutWindowSe24.entries) !== null && _this$_popoutWindowSe23 !== void 0 ? _this$_popoutWindowSe23 : []) entry.gridview.margin = gap;
17952
- (_this$_shellManager4 = this._shellManager) === null || _this$_shellManager4 === void 0 || _this$_shellManager4.updateTheme(gap, (_theme$edgeGroupColla = theme.edgeGroupCollapsedSize) !== null && _theme$edgeGroupColla !== void 0 ? _theme$edgeGroupColla : 35);
18365
+ (_this$_shellManager5 = this._shellManager) === null || _this$_shellManager5 === void 0 || _this$_shellManager5.updateTheme(gap, (_theme$edgeGroupColla = theme.edgeGroupCollapsedSize) !== null && _theme$edgeGroupColla !== void 0 ? _theme$edgeGroupColla : 35);
17953
18366
  if (theme.dndOverlayBorder === void 0) {
17954
- var _this$_shellManager5;
18367
+ var _this$_shellManager6;
17955
18368
  this.element.style.removeProperty("--dv-drag-over-border");
17956
- (_this$_shellManager5 = this._shellManager) === null || _this$_shellManager5 === void 0 || _this$_shellManager5.element.style.removeProperty("--dv-drag-over-border");
18369
+ (_this$_shellManager6 = this._shellManager) === null || _this$_shellManager6 === void 0 || _this$_shellManager6.element.style.removeProperty("--dv-drag-over-border");
17957
18370
  } else {
17958
- var _this$_shellManager6;
18371
+ var _this$_shellManager7;
17959
18372
  this.element.style.setProperty("--dv-drag-over-border", theme.dndOverlayBorder);
17960
- (_this$_shellManager6 = this._shellManager) === null || _this$_shellManager6 === void 0 || _this$_shellManager6.element.style.setProperty("--dv-drag-over-border", theme.dndOverlayBorder);
18373
+ (_this$_shellManager7 = this._shellManager) === null || _this$_shellManager7 === void 0 || _this$_shellManager7.element.style.setProperty("--dv-drag-over-border", theme.dndOverlayBorder);
17961
18374
  }
17962
18375
  switch (theme.dndOverlayMounting) {
17963
18376
  case "absolute":
@@ -18860,6 +19273,8 @@ exports.AdvancedDnDModule = AdvancedDnDModule;
18860
19273
  exports.AdvancedDnDService = AdvancedDnDService;
18861
19274
  exports.BaseGrid = BaseGrid;
18862
19275
  exports.ContentContainer = ContentContainer;
19276
+ exports.ContextMenuController = ContextMenuController;
19277
+ exports.ContextMenuModule = ContextMenuModule;
18863
19278
  exports.DEFAULT_TAB_GROUP_COLORS = DEFAULT_TAB_GROUP_COLORS;
18864
19279
  exports.DefaultDockviewDeserialzier = DefaultDockviewDeserialzier;
18865
19280
  exports.DefaultTab = DefaultTab;