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
  */
@@ -1048,8 +1048,14 @@ var Splitview = class {
1048
1048
  container.appendChild(view.element);
1049
1049
  let viewSize;
1050
1050
  if (typeof size === "number") viewSize = size;
1051
- else if (size.type === "split") viewSize = this.getViewSize(size.index) / 2;
1052
- else if (size.type === "invisible") viewSize = { cachedVisibleSize: size.cachedVisibleSize };
1051
+ else if (size.type === "split") {
1052
+ const splitTarget = this.viewItems[size.index];
1053
+ if (splitTarget) {
1054
+ const half = Math.floor(splitTarget.size / 2);
1055
+ viewSize = splitTarget.size - half;
1056
+ splitTarget.size = half;
1057
+ } else viewSize = this.getViewSize(size.index) / 2;
1058
+ } else if (size.type === "invisible") viewSize = { cachedVisibleSize: size.cachedVisibleSize };
1053
1059
  else viewSize = view.minimumSize;
1054
1060
  const disposable = view.onDidChange((newSize) => this.onDidChange(viewItem, newSize.size));
1055
1061
  const viewItem = new ViewItem(container, view, viewSize, { dispose: () => {
@@ -4441,8 +4447,9 @@ var PointerDragController = class PointerDragController extends CompositeDisposa
4441
4447
  for (const el of elements) {
4442
4448
  let current = el;
4443
4449
  while (current) {
4450
+ var _target$isHitTestTran;
4444
4451
  const target = this._targetByElement.get(current);
4445
- if (target) return target;
4452
+ if (target && !((_target$isHitTestTran = target.isHitTestTransparent) === null || _target$isHitTestTran === void 0 ? void 0 : _target$isHitTestTran.call(target))) return target;
4446
4453
  current = current.parentElement;
4447
4454
  }
4448
4455
  }
@@ -4538,10 +4545,14 @@ var PointerDropTarget = class extends CompositeDisposable {
4538
4545
  element: this.element,
4539
4546
  handleDragOver: (e) => this._onDragOver(e),
4540
4547
  handleDragLeave: () => this._onDragLeave(),
4541
- handleDrop: (e) => this._onDropEvent(e)
4548
+ handleDrop: (e) => this._onDropEvent(e),
4549
+ isHitTestTransparent: options.isHitTestTransparent
4542
4550
  };
4543
4551
  this.addDisposables(this._onDrop, this._onWillShowOverlay, PointerDragController.getInstance().registerTarget(handle));
4544
4552
  }
4553
+ clearOverlay() {
4554
+ this._clearOwnOverlay();
4555
+ }
4545
4556
  setTargetZones(zones) {
4546
4557
  this._acceptedTargetZonesSet = new Set(zones);
4547
4558
  }
@@ -5794,7 +5805,7 @@ function resolveDndCapabilities(options) {
5794
5805
  };
5795
5806
  case "auto":
5796
5807
  case void 0:
5797
- default: return isCoarsePrimaryInput$1() ? {
5808
+ default: return isCoarsePrimaryInput$2() ? {
5798
5809
  html5: false,
5799
5810
  pointer: true,
5800
5811
  pointerHandlesMouse: true
@@ -5805,7 +5816,7 @@ function resolveDndCapabilities(options) {
5805
5816
  };
5806
5817
  }
5807
5818
  }
5808
- function isCoarsePrimaryInput$1() {
5819
+ function isCoarsePrimaryInput$2() {
5809
5820
  if (globalThis.window === void 0 || !globalThis.matchMedia) return false;
5810
5821
  const coarse = globalThis.matchMedia("(pointer: coarse)").matches;
5811
5822
  const fine = globalThis.matchMedia("(pointer: fine)").matches;
@@ -5861,6 +5872,7 @@ var Tab = class extends CompositeDisposable {
5861
5872
  if (this.accessor.id === (data === null || data === void 0 ? void 0 : data.viewId)) {
5862
5873
  var _this$accessor$option;
5863
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;
5864
5876
  return true;
5865
5877
  }
5866
5878
  return this.group.model.canDisplayOverlay(event, position, "tab");
@@ -7308,7 +7320,23 @@ var TabGroupManager = class {
7308
7320
  }
7309
7321
  updateDirection() {
7310
7322
  const isVertical = this._ctx.getDirection() === "vertical";
7311
- 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
+ }
7312
7340
  }
7313
7341
  snapshotChipWidths() {
7314
7342
  const widths = /* @__PURE__ */ new Map();
@@ -7557,9 +7585,8 @@ var TabGroupManager = class {
7557
7585
  };
7558
7586
  if (chip instanceof TabGroupChip) disposables.push(chip.onContextMenu(onContextMenu));
7559
7587
  else disposables.push(new LongPressDetector(chip.element, { onLongPress: onContextMenu }), addDisposableListener(chip.element, "contextmenu", onContextMenu));
7560
- const isVertical = this._ctx.getDirection() === "vertical";
7561
- const dropTarget = new Droptarget(chip.element, {
7562
- acceptedTargetZones: isVertical ? ["top"] : ["left"],
7588
+ const dropTargetOptions = {
7589
+ acceptedTargetZones: this._ctx.getDirection() === "vertical" ? ["top"] : ["left"],
7563
7590
  overlayModel: { activationSize: {
7564
7591
  value: 100,
7565
7592
  type: "percentage"
@@ -7570,15 +7597,18 @@ var TabGroupManager = class {
7570
7597
  const data = getPanelData();
7571
7598
  if (this._ctx.accessor.id === (data === null || data === void 0 ? void 0 : data.viewId)) {
7572
7599
  var _this$_ctx$accessor$o3;
7573
- 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;
7574
7601
  return true;
7575
7602
  }
7576
7603
  return this._ctx.group.model.canDisplayOverlay(event, position, "tab");
7577
7604
  }
7578
- });
7579
- 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) => {
7580
7609
  this._callbacks.onChipDrop(tabGroup, event);
7581
- }));
7610
+ };
7611
+ disposables.push(dropTarget, dropTarget.onDrop(onDrop), pointerDropTarget, pointerDropTarget.onDrop(onDrop));
7582
7612
  const disposable = new CompositeDisposable(...disposables);
7583
7613
  this._chipRenderers.set(tabGroup.id, {
7584
7614
  chip,
@@ -7586,7 +7616,8 @@ var TabGroupManager = class {
7586
7616
  pointerDragSource: dragSources.pointerDragSource,
7587
7617
  dragSourcesDisposable: dragSources.disposable,
7588
7618
  disposable,
7589
- dropTarget
7619
+ dropTarget,
7620
+ pointerDropTarget
7590
7621
  });
7591
7622
  if (tabGroup.collapsed) this._skipNextCollapseAnimation = true;
7592
7623
  }
@@ -7831,7 +7862,14 @@ var TabReorderController = class extends CompositeDisposable {
7831
7862
  * dragover bridge may have installed.
7832
7863
  */
7833
7864
  handlePointerDragEnd(e) {
7834
- 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
+ }
7835
7873
  this._pointerInsideTabsList = false;
7836
7874
  this.resetDragAnimation();
7837
7875
  }
@@ -7960,11 +7998,28 @@ var TabReorderController = class extends CompositeDisposable {
7960
7998
  if (this._voidContainer && related && (related === this._voidContainer || this._voidContainer.contains(related))) return;
7961
7999
  this.resetTabTransforms();
7962
8000
  if (this._animState.sourceIndex === -1) {
7963
- var _this$group$model$dro2;
7964
- (_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();
8001
+ this.clearHeaderAnchorOverlay();
7965
8002
  this._animState = null;
7966
8003
  } else this._animState.currentInsertionIndex = null;
7967
8004
  }
8005
+ /**
8006
+ * Clear the anchored overlay only when this header is what rendered it.
8007
+ * The container is shared with the group's content drop target, which
8008
+ * renders into it on the same frame the cursor leaves the strip: the
8009
+ * pointer backend calls `handleDragOver` on the new target before the
8010
+ * global `onDragMove` that reaches us (#1612).
8011
+ */
8012
+ clearHeaderAnchorOverlay() {
8013
+ var _container$model;
8014
+ const container = this.group.model.dropTargetContainer;
8015
+ const outline = container === null || container === void 0 ? void 0 : container.renderedOutline;
8016
+ if (outline && ![
8017
+ this._tabsList,
8018
+ this._voidContainer,
8019
+ this._extendedDropZone
8020
+ ].some((scope) => scope === null || scope === void 0 ? void 0 : scope.contains(outline))) return;
8021
+ container === null || container === void 0 || (_container$model = container.model) === null || _container$model === void 0 || _container$model.clear();
8022
+ }
7968
8023
  handleDragOver(event) {
7969
8024
  var _this$accessor$option2;
7970
8025
  if (!this._animState) return;
@@ -8450,6 +8505,7 @@ var TabReorderController = class extends CompositeDisposable {
8450
8505
  commitGroupMove(sourceTabGroupId, insertionIndex) {
8451
8506
  const data = getPanelData();
8452
8507
  this._tabGroupManager.disposeChipDrag(sourceTabGroupId);
8508
+ this._tabGroupManager.clearChipDropOverlays();
8453
8509
  if (this.group.model.getTabGroups().some((tg) => tg.id === sourceTabGroupId)) {
8454
8510
  var _this$accessor$option3;
8455
8511
  if (((_this$accessor$option3 = this.accessor.options.theme) === null || _this$accessor$option3 === void 0 ? void 0 : _this$accessor$option3.tabAnimation) === "smooth") {
@@ -8807,7 +8863,16 @@ var Tabs = class extends CompositeDisposable {
8807
8863
  }
8808
8864
  });
8809
8865
  this._reorder = new TabReorderController(this);
8810
- 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) => {
8811
8876
  this._reorder.handlePointerDragEnd(e);
8812
8877
  }), PointerDragController.getInstance().onDragMove((e) => {
8813
8878
  this._reorder.handlePointerDragMove(e.clientX, e.clientY);
@@ -9283,6 +9348,10 @@ var Tabs = class extends CompositeDisposable {
9283
9348
  * (when the source tab is currently to the left of the target slot, its
9284
9349
  * removal shifts the insertion index down by one). Always clears
9285
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.
9286
9355
  */
9287
9356
  _handleChipDrop(tabGroup, event) {
9288
9357
  const firstPanelId = tabGroup.panelIds[0];
@@ -9290,6 +9359,14 @@ var Tabs = class extends CompositeDisposable {
9290
9359
  const insertionIndex = this._tabs.findIndex((x) => x.value.panel.id === firstPanelId);
9291
9360
  if (insertionIndex === -1) return;
9292
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
+ }
9293
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;
9294
9371
  const adjustedIndex = insertionIndex - (sourceIndex !== -1 && sourceIndex < insertionIndex ? 1 : 0);
9295
9372
  this._onDrop.fire({
@@ -12394,7 +12471,6 @@ const ENTERPRISE_MODULE_NAMES = /* @__PURE__ */ new Set([
12394
12471
  "AdvancedOverflow",
12395
12472
  "AutoEdgeGroup",
12396
12473
  "AutoHideEdgeGroup",
12397
- "ContextMenu",
12398
12474
  "DndCompass",
12399
12475
  "KeyboardDocking",
12400
12476
  "KeyboardNavigation",
@@ -12476,8 +12552,8 @@ function logMissingModule(moduleName, reason) {
12476
12552
  * case: calling `undo()` having never set the option at all.
12477
12553
  *
12478
12554
  * Interaction handlers are queries in this sense too: a right-click reaching an
12479
- * absent ContextMenu module means the app never asked for one, so it stays
12480
- * silent (`?.`) and the browser's own menu shows. Options are where intent is
12555
+ * absent module means the app never asked for that feature, so it stays silent
12556
+ * (`?.`) and the browser's own behaviour applies. Options are where intent is
12481
12557
  * declared; see `optionsModules.ts`.
12482
12558
  */
12483
12559
  function assertModule(service, moduleName, context) {
@@ -12557,10 +12633,9 @@ function clearRegisteredModules() {
12557
12633
  *
12558
12634
  * This is the "declared intent" diagnostic. It fires when the user asks for a
12559
12635
  * feature via options, at construction and on every `updateOptions`. It
12560
- * deliberately does *not* fire on user interaction: right-clicking without the
12561
- * ContextMenu module stays silent (the browser's own menu shows), because the
12562
- * `?.` service-slot call sites can't tell a missing module from a feature the
12563
- * app never wanted.
12636
+ * deliberately does *not* fire on user interaction: an interaction reaching an
12637
+ * absent module stays silent, because the `?.` service-slot call sites can't
12638
+ * tell a missing module from a feature the app never wanted.
12564
12639
  *
12565
12640
  * Rules are a flat list rather than a `Record<keyof DockviewOptions, ...>`
12566
12641
  * because dockview's options are nested and value-gated: `overflow.mode:
@@ -12656,18 +12731,6 @@ const OPTION_MODULE_RULES = [
12656
12731
  moduleName: "AutoEdgeGroup",
12657
12732
  when: (o) => isAnyEdgeGroupEnabled(o.dockToEdgeGroups)
12658
12733
  },
12659
- {
12660
- optionKey: "getTabContextMenuItems",
12661
- reason: "getTabContextMenuItems",
12662
- moduleName: "ContextMenu",
12663
- when: (o) => o.getTabContextMenuItems != null
12664
- },
12665
- {
12666
- optionKey: "getTabGroupChipContextMenuItems",
12667
- reason: "getTabGroupChipContextMenuItems",
12668
- moduleName: "ContextMenu",
12669
- when: (o) => o.getTabGroupChipContextMenuItems != null
12670
- },
12671
12734
  {
12672
12735
  optionKey: "dndCompass",
12673
12736
  reason: "dndCompass",
@@ -13568,6 +13631,270 @@ const TabGroupChipsModule = defineModule({
13568
13631
  }
13569
13632
  });
13570
13633
 
13634
+ //#endregion
13635
+ //#region src/dockview/contextMenuService.ts
13636
+ function popoverZIndexFor(target, group) {
13637
+ var _group$api, _group$api$isPeeking;
13638
+ 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)";
13639
+ if (!(target instanceof HTMLElement)) return;
13640
+ const relativeParent = findRelativeZIndexParent(target);
13641
+ return (relativeParent === null || relativeParent === void 0 ? void 0 : relativeParent.style.zIndex) ? `calc(${relativeParent.style.zIndex} * 2)` : void 0;
13642
+ }
13643
+ let _nextId = 0;
13644
+ const nextContextMenuItemId = () => `dv-ctx-menu-item-${_nextId++}`;
13645
+ function isItemConfig(item) {
13646
+ return typeof item === "object";
13647
+ }
13648
+ function buildItem(label, close, action, disabled) {
13649
+ const el = document.createElement("div");
13650
+ el.className = "dv-context-menu-item";
13651
+ el.setAttribute("role", "menuitem");
13652
+ if (disabled) {
13653
+ el.classList.add("dv-context-menu-item--disabled");
13654
+ el.setAttribute("aria-disabled", "true");
13655
+ }
13656
+ el.textContent = label;
13657
+ if (!disabled) el.addEventListener("click", () => {
13658
+ action();
13659
+ close();
13660
+ });
13661
+ return el;
13662
+ }
13663
+ function buildSeparator() {
13664
+ const el = document.createElement("div");
13665
+ el.className = "dv-context-menu-separator";
13666
+ el.setAttribute("role", "separator");
13667
+ return el;
13668
+ }
13669
+ function isCoarsePrimaryInput$1() {
13670
+ if (globalThis.window === void 0 || !globalThis.matchMedia) return false;
13671
+ const coarse = globalThis.matchMedia("(pointer: coarse)").matches;
13672
+ const fine = globalThis.matchMedia("(pointer: fine)").matches;
13673
+ return coarse && !fine;
13674
+ }
13675
+ function buildRenameInput(tabGroup) {
13676
+ const wrapper = document.createElement("div");
13677
+ wrapper.className = "dv-context-menu-rename";
13678
+ const input = document.createElement("input");
13679
+ input.className = "dv-context-menu-rename-input";
13680
+ input.type = "text";
13681
+ input.placeholder = "Name This Group";
13682
+ input.value = tabGroup.label;
13683
+ input.addEventListener("input", () => {
13684
+ tabGroup.setLabel(input.value);
13685
+ });
13686
+ input.addEventListener("keydown", (e) => {
13687
+ if (e.key !== "Escape" && e.key !== "Enter") e.stopPropagation();
13688
+ });
13689
+ input.addEventListener("click", (e) => {
13690
+ e.stopPropagation();
13691
+ });
13692
+ wrapper.appendChild(input);
13693
+ if (!isCoarsePrimaryInput$1()) requestAnimationFrame(() => {
13694
+ input.focus();
13695
+ input.select();
13696
+ });
13697
+ return wrapper;
13698
+ }
13699
+ function buildColorPicker(tabGroup, palette) {
13700
+ const wrapper = document.createElement("div");
13701
+ wrapper.className = "dv-context-menu-color-picker";
13702
+ if (!palette.enabled) return wrapper;
13703
+ for (const entry of palette.entries()) {
13704
+ const swatch = document.createElement("div");
13705
+ swatch.className = "dv-context-menu-color-swatch";
13706
+ swatch.style.setProperty("--dv-tab-group-color", entry.value);
13707
+ if (entry.label) swatch.title = entry.label;
13708
+ if (tabGroup.color === entry.id) swatch.classList.add("dv-context-menu-color-swatch--selected");
13709
+ swatch.addEventListener("click", () => {
13710
+ tabGroup.setColor(entry.id);
13711
+ });
13712
+ wrapper.appendChild(swatch);
13713
+ }
13714
+ return wrapper;
13715
+ }
13716
+ var ContextMenuController = class {
13717
+ constructor(accessor) {
13718
+ this.accessor = accessor;
13719
+ }
13720
+ /**
13721
+ * A single maximize/restore toggle whose label and behaviour track the
13722
+ * group's live state: it reads *Restore* + calls `exitMaximized` when the
13723
+ * group is maximized, otherwise *Maximize* + `maximize`. Only grid groups
13724
+ * can be maximized, so the item is disabled for floating / popout panels
13725
+ * that are not already maximized.
13726
+ */
13727
+ buildMaximizeItem(panel, close) {
13728
+ const isMaximized = panel.api.isMaximized();
13729
+ return buildItem(isMaximized ? "Restore" : "Maximize", close, isMaximized ? () => panel.api.exitMaximized() : () => panel.api.maximize(), !isMaximized && panel.api.location.type !== "grid");
13730
+ }
13731
+ /**
13732
+ * A single collapse/expand toggle whose label tracks the tab group's live
13733
+ * state: *Expand* when the group is already collapsed, otherwise *Collapse*.
13734
+ */
13735
+ buildCollapseItem(tabGroup, close) {
13736
+ return buildItem(tabGroup.collapsed ? "Expand" : "Collapse", close, () => tabGroup.toggle());
13737
+ }
13738
+ /**
13739
+ * Whether to auto-inject the built-in Pin/Unpin item at the top of the tab
13740
+ * menu. True only when the PinnedTabs module is registered, pinning is
13741
+ * enabled, and the app has not opted out via `pinnedTabs.contextMenuItem:
13742
+ * false` (the item is on by default). This keeps pinning reachable from the
13743
+ * menu without the app having to return `'pin'` from
13744
+ * `getTabContextMenuItems` itself.
13745
+ */
13746
+ _shouldInjectPin() {
13747
+ const pinnedTabs = this.accessor.options.pinnedTabs;
13748
+ return !!this.accessor.pinnedTabsService && !!(pinnedTabs === null || pinnedTabs === void 0 ? void 0 : pinnedTabs.enabled) && pinnedTabs.contextMenuItem !== false;
13749
+ }
13750
+ /**
13751
+ * The tab menu items: the app's own items (if any) with the built-in
13752
+ * `'pin'` item prepended when {@link _shouldInjectPin} applies, so the app
13753
+ * keeps full control of its list, and pinning is added without disturbing
13754
+ * it. Reuses the existing `'pin'` token rendering below.
13755
+ */
13756
+ _resolveTabItems(panel, group, event) {
13757
+ var _this$accessor$option, _this$accessor$option2, _this$accessor$option3;
13758
+ 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, {
13759
+ panel,
13760
+ group,
13761
+ api: this.accessor.api,
13762
+ event
13763
+ })) !== null && _this$accessor$option !== void 0 ? _this$accessor$option : [];
13764
+ return this._shouldInjectPin() ? ["pin", ...appItems] : appItems;
13765
+ }
13766
+ /**
13767
+ * Render a custom `component` menu item and append it to `menuEl`. Builds
13768
+ * the framework renderer via the host's `createContextMenuItemComponent`
13769
+ * factory and initialises it. Shared by the tab menu and the chip menu,
13770
+ * which differ only in `identity`: the tab menu passes the `panel`, the chip
13771
+ * menu passes the `tabGroup`. No-op when no renderer could be created (no
13772
+ * factory configured, or the factory declined the component).
13773
+ */
13774
+ appendComponentItem(menuEl, item, identity, group, close) {
13775
+ var _this$accessor$option4, _this$accessor$option5;
13776
+ 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, {
13777
+ id: nextContextMenuItemId(),
13778
+ component: item.component
13779
+ });
13780
+ if (!renderer) return;
13781
+ renderer.init(_objectSpread2(_objectSpread2({}, identity), {}, {
13782
+ group,
13783
+ api: this.accessor.api,
13784
+ close,
13785
+ componentProps: item.componentProps
13786
+ }));
13787
+ menuEl.appendChild(renderer.element);
13788
+ }
13789
+ /**
13790
+ * The element for one built-in tab item, or `undefined` for a token this
13791
+ * version doesn't know (an app on a newer typings version, or plain JS):
13792
+ * an unrecognised token renders nothing rather than throwing.
13793
+ */
13794
+ buildBuiltInTabItem(item, panel, group, close) {
13795
+ switch (item) {
13796
+ case "separator": return buildSeparator();
13797
+ case "close": return buildItem("Close", close, () => panel.api.close());
13798
+ case "closeOthers": return buildItem("Close Others", close, () => {
13799
+ group.panels.filter((p) => p !== panel).forEach((p) => p.api.close());
13800
+ });
13801
+ case "closeAll": return buildItem("Close All", close, () => {
13802
+ [...group.panels].forEach((p) => p.api.close());
13803
+ });
13804
+ case "closeLeft": {
13805
+ const index = group.panels.indexOf(panel);
13806
+ return buildItem("Close to the Left", close, () => {
13807
+ group.panels.filter((_, i) => i < index).forEach((p) => p.api.close());
13808
+ }, index <= 0);
13809
+ }
13810
+ case "closeRight": {
13811
+ const index = group.panels.indexOf(panel);
13812
+ return buildItem("Close to the Right", close, () => {
13813
+ group.panels.filter((_, i) => i > index).forEach((p) => p.api.close());
13814
+ }, index === -1 || index >= group.panels.length - 1);
13815
+ }
13816
+ case "maximize": return this.buildMaximizeItem(panel, close);
13817
+ case "float": return buildItem("Float", close, () => this.accessor.api.addFloatingGroup(panel), panel.api.location.type === "floating");
13818
+ case "popout": return buildItem("Open in New Window", close, () => {
13819
+ this.accessor.api.addPopoutGroup(panel);
13820
+ }, panel.api.location.type === "popout");
13821
+ case "pin": return buildItem(panel.api.isPinned ? "Unpin tab" : "Pin tab", close, () => panel.api.setPinned(!panel.api.isPinned));
13822
+ default: return;
13823
+ }
13824
+ }
13825
+ /**
13826
+ * Append one app-supplied item. A raw `element` is used as-is, a
13827
+ * `component` goes through the framework renderer, and a `label` builds the
13828
+ * default row; an item carrying none of the three renders nothing. Shared
13829
+ * by both menus, which differ only in `identity`.
13830
+ */
13831
+ appendConfigItem(menuEl, item, identity, group, close) {
13832
+ if (item.element) menuEl.appendChild(item.element);
13833
+ else if (item.component) this.appendComponentItem(menuEl, item, identity, group, close);
13834
+ else if (item.label) menuEl.appendChild(buildItem(item.label, close, () => {
13835
+ var _item$action;
13836
+ return (_item$action = item.action) === null || _item$action === void 0 ? void 0 : _item$action.call(item);
13837
+ }, item.disabled));
13838
+ }
13839
+ show(panel, group, event) {
13840
+ const items = this._resolveTabItems(panel, group, event);
13841
+ if (items.length === 0) return;
13842
+ event.preventDefault();
13843
+ const popupService = this.accessor.getPopupServiceForGroup(group);
13844
+ const close = () => popupService.close();
13845
+ const menuEl = document.createElement("div");
13846
+ menuEl.className = "dv-context-menu";
13847
+ menuEl.setAttribute("role", "menu");
13848
+ for (const item of items) {
13849
+ if (isItemConfig(item)) {
13850
+ this.appendConfigItem(menuEl, item, { panel }, group, close);
13851
+ continue;
13852
+ }
13853
+ const el = this.buildBuiltInTabItem(item, panel, group, close);
13854
+ if (el) menuEl.appendChild(el);
13855
+ }
13856
+ popupService.openPopover(menuEl, {
13857
+ x: event.clientX,
13858
+ y: event.clientY,
13859
+ zIndex: popoverZIndexFor(event.target, group)
13860
+ });
13861
+ }
13862
+ showForChip(tabGroup, group, event) {
13863
+ if (!this.accessor.options.getTabGroupChipContextMenuItems) return;
13864
+ const items = this.accessor.options.getTabGroupChipContextMenuItems({
13865
+ tabGroup,
13866
+ group,
13867
+ api: this.accessor.api,
13868
+ event
13869
+ });
13870
+ if (items.length === 0) return;
13871
+ event.preventDefault();
13872
+ const popupService = this.accessor.getPopupServiceForGroup(group);
13873
+ const close = () => popupService.close();
13874
+ const menuEl = document.createElement("div");
13875
+ menuEl.className = "dv-context-menu";
13876
+ menuEl.setAttribute("role", "menu");
13877
+ for (const item of items) if (item === "separator") menuEl.appendChild(buildSeparator());
13878
+ else if (item === "rename") menuEl.appendChild(buildRenameInput(tabGroup));
13879
+ else if (item === "colorPicker") menuEl.appendChild(buildColorPicker(tabGroup, this.accessor.tabGroupColorPalette));
13880
+ else if (item === "collapse") menuEl.appendChild(this.buildCollapseItem(tabGroup, close));
13881
+ else if (item === "close") menuEl.appendChild(buildItem("Close All", close, () => {
13882
+ group.panels.filter((p) => tabGroup.containsPanel(p.id)).forEach((p) => p.api.close());
13883
+ }));
13884
+ else if (isItemConfig(item)) this.appendConfigItem(menuEl, item, { tabGroup }, group, close);
13885
+ popupService.openPopover(menuEl, {
13886
+ x: event.clientX,
13887
+ y: event.clientY,
13888
+ zIndex: popoverZIndexFor(event.target, group)
13889
+ });
13890
+ }
13891
+ };
13892
+ const ContextMenuModule = defineModule({
13893
+ name: "ContextMenu",
13894
+ serviceKey: "contextMenuService",
13895
+ create: (host) => new ContextMenuController(host)
13896
+ });
13897
+
13571
13898
  //#endregion
13572
13899
  //#region src/dockview/allModules.ts
13573
13900
  /**
@@ -13585,7 +13912,8 @@ const AllModules = [
13585
13912
  HeaderActionsModule,
13586
13913
  LiveRegionModule,
13587
13914
  AdvancedDnDModule,
13588
- TabGroupChipsModule
13915
+ TabGroupChipsModule,
13916
+ ContextMenuModule
13589
13917
  ];
13590
13918
 
13591
13919
  //#endregion
@@ -14277,6 +14605,14 @@ var PopupService = class extends CompositeDisposable {
14277
14605
  //#endregion
14278
14606
  //#region src/dnd/dropTargetAnchorContainer.ts
14279
14607
  var DropTargetAnchorContainer = class extends CompositeDisposable {
14608
+ /**
14609
+ * The element the live overlay was rendered for, `undefined` when nothing
14610
+ * is showing. The container is shared by every drop target, so a caller
14611
+ * tearing down only its own overlay must check this before `clear()`.
14612
+ */
14613
+ get renderedOutline() {
14614
+ return this._model ? this._outline : void 0;
14615
+ }
14280
14616
  get disabled() {
14281
14617
  return this._disabled;
14282
14618
  }
@@ -14581,6 +14917,10 @@ var MiddleColumnView = class {
14581
14917
  const index = position === "top" ? this._topIndex : this._bottomIndex;
14582
14918
  if (index !== void 0) this._splitview.resizeView(index, size);
14583
14919
  }
14920
+ /** The inner splitview's primary-axis (height) extent; zero until laid out. */
14921
+ get axisSize() {
14922
+ return this._splitview.size;
14923
+ }
14584
14924
  updateMargin(gap) {
14585
14925
  this._splitview.margin = gap;
14586
14926
  }
@@ -14593,6 +14933,7 @@ var ShellManager = class {
14593
14933
  constructor(container, dockviewElement, layoutGrid, gap = 0, defaultCollapsedSize = 35) {
14594
14934
  this._disposables = new CompositeDisposable();
14595
14935
  this._viewConfigs = /* @__PURE__ */ new Map();
14936
+ this._pendingSizes = /* @__PURE__ */ new Map();
14596
14937
  this._currentWidth = 0;
14597
14938
  this._currentHeight = 0;
14598
14939
  this._gap = gap;
@@ -14683,11 +15024,13 @@ var ShellManager = class {
14683
15024
  break;
14684
15025
  }
14685
15026
  this._disposables.addDisposables(view);
15027
+ if (!view.isCollapsed && !this._canResize(position)) this._pendingSizes.set(position, initialSize);
14686
15028
  this.updateTheme(this._gap, this._defaultCollapsedSize);
14687
15029
  return view;
14688
15030
  }
14689
15031
  layout(width, height) {
14690
15032
  this._outerSplitview.layout(width, height);
15033
+ this._flushPendingSizes();
14691
15034
  }
14692
15035
  /**
14693
15036
  * Called when the active theme changes. Updates splitview margins and
@@ -14751,6 +15094,7 @@ var ShellManager = class {
14751
15094
  this._disposables.removeDisposable(view);
14752
15095
  view.dispose();
14753
15096
  this._viewConfigs.delete(position);
15097
+ this._pendingSizes.delete(position);
14754
15098
  this.updateTheme(this._gap, this._defaultCollapsedSize);
14755
15099
  }
14756
15100
  hasEdgeGroup(position) {
@@ -14774,6 +15118,7 @@ var ShellManager = class {
14774
15118
  this._middleColumn.setViewVisible(position, visible);
14775
15119
  break;
14776
15120
  }
15121
+ if (visible) this._flushPendingSizes();
14777
15122
  }
14778
15123
  isEdgeGroupVisible(position) {
14779
15124
  switch (position) {
@@ -14791,20 +15136,63 @@ var ShellManager = class {
14791
15136
  const view = this._getView(position);
14792
15137
  if (!view) return;
14793
15138
  view.setCollapsed(collapsed);
14794
- const targetSize = collapsed ? view.collapsedSize : view.lastExpandedSize;
15139
+ if (collapsed) {
15140
+ this._pendingSizes.delete(position);
15141
+ this._resizeView(position, view.collapsedSize);
15142
+ } else this.resizeEdgeGroup(position, view.lastExpandedSize);
15143
+ }
15144
+ /**
15145
+ * Resize the edge group at `position` along its primary axis (width for
15146
+ * `left`/`right`, height for `top`/`bottom`), clamped by the group's
15147
+ * constraints and the space available. Where `groupApi.setSize` lands.
15148
+ *
15149
+ * The size becomes the group's expanded size, so a collapsed group keeps
15150
+ * its strip and takes it on expand, and it survives a `toJSON` round-trip.
15151
+ */
15152
+ resizeEdgeGroup(position, size) {
15153
+ const view = this._getView(position);
15154
+ if (!view || !Number.isFinite(size)) return;
15155
+ const target = Math.round(size);
15156
+ if (target <= 0) return;
15157
+ view.restoreExpandedSize(target);
15158
+ if (view.isCollapsed) {
15159
+ this._pendingSizes.delete(position);
15160
+ return;
15161
+ }
15162
+ if (this._canResize(position)) {
15163
+ this._pendingSizes.delete(position);
15164
+ this._resizeView(position, target);
15165
+ } else this._pendingSizes.set(position, target);
15166
+ }
15167
+ /** A resize lands only on a visible view (a hidden one is pinned to zero)
15168
+ * whose splitview has extent to distribute. */
15169
+ _canResize(position) {
15170
+ if (!this.isEdgeGroupVisible(position)) return false;
15171
+ return (position === "left" || position === "right" ? this._outerSplitview.size : this._middleColumn.axisSize) > 0;
15172
+ }
15173
+ _resizeView(position, size) {
14795
15174
  switch (position) {
14796
15175
  case "left":
14797
- if (this._leftIndex !== void 0) this._outerSplitview.resizeView(this._leftIndex, targetSize);
15176
+ if (this._leftIndex !== void 0) this._outerSplitview.resizeView(this._leftIndex, size);
14798
15177
  break;
14799
15178
  case "right":
14800
- if (this._rightIndex !== void 0) this._outerSplitview.resizeView(this._rightIndex, targetSize);
15179
+ if (this._rightIndex !== void 0) this._outerSplitview.resizeView(this._rightIndex, size);
14801
15180
  break;
14802
15181
  case "top":
14803
15182
  case "bottom":
14804
- this._middleColumn.resizeView(position, targetSize);
15183
+ this._middleColumn.resizeView(position, size);
14805
15184
  break;
14806
15185
  }
14807
15186
  }
15187
+ _flushPendingSizes() {
15188
+ if (this._pendingSizes.size === 0) return;
15189
+ for (const [position, size] of this._pendingSizes) {
15190
+ const view = this._getView(position);
15191
+ if (!view || view.isCollapsed || !this._canResize(position)) continue;
15192
+ this._pendingSizes.delete(position);
15193
+ this._resizeView(position, size);
15194
+ }
15195
+ }
14808
15196
  isEdgeGroupCollapsed(position) {
14809
15197
  var _this$_getView$isColl, _this$_getView;
14810
15198
  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;
@@ -14830,15 +15218,17 @@ var ShellManager = class {
14830
15218
  maximumSize: Number.isFinite(view.configuredMaximumSize) ? view.configuredMaximumSize : void 0,
14831
15219
  collapsedSize: view.configuredCollapsedSize
14832
15220
  });
14833
- const expandedSize = (view, isVisible, liveSize, cachedVisibleSize) => {
15221
+ const expandedSize = (view, position, isVisible, liveSize, cachedVisibleSize) => {
14834
15222
  if (view.isCollapsed) return view.lastExpandedSize;
15223
+ const pending = this._pendingSizes.get(position);
15224
+ if (pending !== void 0) return pending;
14835
15225
  if (!isVisible) return cachedVisibleSize !== null && cachedVisibleSize !== void 0 ? cachedVisibleSize : view.lastExpandedSize;
14836
15226
  return liveSize;
14837
15227
  };
14838
15228
  if (this._leftView && this._leftIndex !== void 0) {
14839
15229
  const visible = this._outerSplitview.isViewVisible(this._leftIndex);
14840
15230
  edgeGroups.left = _objectSpread2({
14841
- size: expandedSize(this._leftView, visible, this._outerSplitview.getViewSize(this._leftIndex), this._outerSplitview.getViewCachedVisibleSize(this._leftIndex)),
15231
+ size: expandedSize(this._leftView, "left", visible, this._outerSplitview.getViewSize(this._leftIndex), this._outerSplitview.getViewCachedVisibleSize(this._leftIndex)),
14842
15232
  visible,
14843
15233
  collapsed: this._leftView.isCollapsed || void 0
14844
15234
  }, constraints(this._leftView));
@@ -14846,7 +15236,7 @@ var ShellManager = class {
14846
15236
  if (this._rightView && this._rightIndex !== void 0) {
14847
15237
  const visible = this._outerSplitview.isViewVisible(this._rightIndex);
14848
15238
  edgeGroups.right = _objectSpread2({
14849
- size: expandedSize(this._rightView, visible, this._outerSplitview.getViewSize(this._rightIndex), this._outerSplitview.getViewCachedVisibleSize(this._rightIndex)),
15239
+ size: expandedSize(this._rightView, "right", visible, this._outerSplitview.getViewSize(this._rightIndex), this._outerSplitview.getViewCachedVisibleSize(this._rightIndex)),
14850
15240
  visible,
14851
15241
  collapsed: this._rightView.isCollapsed || void 0
14852
15242
  }, constraints(this._rightView));
@@ -14854,7 +15244,7 @@ var ShellManager = class {
14854
15244
  if (this._topView) {
14855
15245
  const visible = this._middleColumn.isViewVisible("top");
14856
15246
  edgeGroups.top = _objectSpread2({
14857
- size: expandedSize(this._topView, visible, this._middleColumn.getViewSize("top"), this._middleColumn.getViewCachedVisibleSize("top")),
15247
+ size: expandedSize(this._topView, "top", visible, this._middleColumn.getViewSize("top"), this._middleColumn.getViewCachedVisibleSize("top")),
14858
15248
  visible,
14859
15249
  collapsed: this._topView.isCollapsed || void 0
14860
15250
  }, constraints(this._topView));
@@ -14862,7 +15252,7 @@ var ShellManager = class {
14862
15252
  if (this._bottomView) {
14863
15253
  const visible = this._middleColumn.isViewVisible("bottom");
14864
15254
  edgeGroups.bottom = _objectSpread2({
14865
- size: expandedSize(this._bottomView, visible, this._middleColumn.getViewSize("bottom"), this._middleColumn.getViewCachedVisibleSize("bottom")),
15255
+ size: expandedSize(this._bottomView, "bottom", visible, this._middleColumn.getViewSize("bottom"), this._middleColumn.getViewCachedVisibleSize("bottom")),
14866
15256
  visible,
14867
15257
  collapsed: this._bottomView.isCollapsed || void 0
14868
15258
  }, constraints(this._bottomView));
@@ -14870,33 +15260,23 @@ var ShellManager = class {
14870
15260
  return edgeGroups;
14871
15261
  }
14872
15262
  fromJSON(data) {
14873
- if (data.left && this._leftIndex !== void 0) {
14874
- var _this$_leftView2, _this$_leftView3, _data$left$collapsed, _this$_leftView$colla, _this$_leftView4;
14875
- (_this$_leftView2 = this._leftView) === null || _this$_leftView2 === void 0 || _this$_leftView2.restoreExpandedSize(data.left.size);
14876
- (_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);
14877
- 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);
14878
- if (!data.left.visible) this._outerSplitview.setViewVisible(this._leftIndex, false);
14879
- }
14880
- if (data.right && this._rightIndex !== void 0) {
14881
- var _this$_rightView2, _this$_rightView3, _data$right$collapsed, _this$_rightView$coll, _this$_rightView4;
14882
- (_this$_rightView2 = this._rightView) === null || _this$_rightView2 === void 0 || _this$_rightView2.restoreExpandedSize(data.right.size);
14883
- (_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);
14884
- 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);
14885
- if (!data.right.visible) this._outerSplitview.setViewVisible(this._rightIndex, false);
14886
- }
14887
- if (data.top) {
14888
- var _this$_topView2, _this$_topView3, _data$top$collapsed, _this$_topView$collap, _this$_topView4;
14889
- (_this$_topView2 = this._topView) === null || _this$_topView2 === void 0 || _this$_topView2.restoreExpandedSize(data.top.size);
14890
- (_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);
14891
- 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);
14892
- if (!data.top.visible) this._middleColumn.setViewVisible("top", false);
14893
- }
14894
- if (data.bottom) {
14895
- var _this$_bottomView2, _this$_bottomView3, _data$bottom$collapse, _this$_bottomView$col, _this$_bottomView4;
14896
- (_this$_bottomView2 = this._bottomView) === null || _this$_bottomView2 === void 0 || _this$_bottomView2.restoreExpandedSize(data.bottom.size);
14897
- (_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);
14898
- 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);
14899
- if (!data.bottom.visible) this._middleColumn.setViewVisible("bottom", false);
15263
+ for (const position of [
15264
+ "left",
15265
+ "right",
15266
+ "top",
15267
+ "bottom"
15268
+ ]) {
15269
+ var _state$collapsed;
15270
+ const state = data[position];
15271
+ const view = this._getView(position);
15272
+ if (!state || !view) continue;
15273
+ view.restoreExpandedSize(state.size);
15274
+ view.setCollapsed((_state$collapsed = state.collapsed) !== null && _state$collapsed !== void 0 ? _state$collapsed : false);
15275
+ if (state.collapsed) {
15276
+ this._pendingSizes.delete(position);
15277
+ this._resizeView(position, view.collapsedSize);
15278
+ } else this.resizeEdgeGroup(position, state.size);
15279
+ this.setEdgeGroupVisible(position, !!state.visible);
14900
15280
  }
14901
15281
  }
14902
15282
  dispose() {
@@ -16064,10 +16444,11 @@ var DockviewComponent = class extends BaseGrid {
16064
16444
  group = this.createGroup();
16065
16445
  this._onDidAddGroup.fire(group);
16066
16446
  this.movingLock(() => this.removePanel(item, {
16067
- removeEmptyGroup: true,
16447
+ removeEmptyGroup: false,
16068
16448
  skipDispose: true,
16069
16449
  skipSetActiveGroup: true
16070
16450
  }));
16451
+ this.removeGroupIfEmpty(sourceGroup);
16071
16452
  this.movingLock(() => group.model.openPanel(item, { skipSetGroupActive: true }));
16072
16453
  movedPanels = [{
16073
16454
  panel: item,
@@ -16138,6 +16519,9 @@ var DockviewComponent = class extends BaseGrid {
16138
16519
  });
16139
16520
  for (const { panel, from } of movedPanels) this.fireDidMovePanel(panel, from);
16140
16521
  }
16522
+ removeGroupIfEmpty(group) {
16523
+ if (group.model.size === 0) this.doRemoveGroup(group, { skipActive: true });
16524
+ }
16141
16525
  /**
16142
16526
  * Build an empty gridview configured to match the main grid's styling, for
16143
16527
  * hosting a nested layout inside a floating or popout window.
@@ -16281,6 +16665,13 @@ var DockviewComponent = class extends BaseGrid {
16281
16665
  position
16282
16666
  };
16283
16667
  group.model.headerPosition = position;
16668
+ const resizeDisposable = group.onDidChange((event) => {
16669
+ var _this$_shellManager3;
16670
+ if (!event) return;
16671
+ const size = position === "left" || position === "right" ? event.width : event.height;
16672
+ if (typeof size !== "number") return;
16673
+ (_this$_shellManager3 = this._shellManager) === null || _this$_shellManager3 === void 0 || _this$_shellManager3.resizeEdgeGroup(position, size);
16674
+ });
16284
16675
  const autoCollapseDisposable = group.model.onDidRemovePanel(() => {
16285
16676
  if (!group.model.isEmpty) return;
16286
16677
  if (service.isAutoReveal(group)) queueMicrotask(() => {
@@ -16289,7 +16680,7 @@ var DockviewComponent = class extends BaseGrid {
16289
16680
  });
16290
16681
  else this.setEdgeGroupCollapsed(group, true);
16291
16682
  });
16292
- service.add(position, group, autoCollapseDisposable);
16683
+ service.add(position, group, new CompositeDisposable(autoCollapseDisposable, resizeDisposable));
16293
16684
  if (options.autoHide !== void 0) service.setAutoHide(group, options.autoHide);
16294
16685
  if (options.autoReveal !== void 0) service.setAutoReveal(group, options.autoReveal);
16295
16686
  this._onDidAddGroup.fire(group);
@@ -16384,8 +16775,8 @@ var DockviewComponent = class extends BaseGrid {
16384
16775
  }
16385
16776
  /** The size an edge group expands to (pre-collapse); sizes the peek. */
16386
16777
  getEdgeGroupExpandedSize(position) {
16387
- var _this$_shellManager$g, _this$_shellManager3;
16388
- 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;
16778
+ var _this$_shellManager$g, _this$_shellManager4;
16779
+ 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;
16389
16780
  }
16390
16781
  /** Reposition a single `renderer:'always'` panel's overlay over its
16391
16782
  * reference container, optionally forcing it visible (the auto-hide peek
@@ -17546,7 +17937,7 @@ var DockviewComponent = class extends BaseGrid {
17546
17937
  }));
17547
17938
  this.doRemoveGroup(sourceGroup, { skipActive: true });
17548
17939
  const updatedTargetLocation = getRelativeLocation(destinationGridview.orientation, getGridLocation(destinationGroup.element), destinationTarget);
17549
- const newGroup = this.createGroupAtLocation(updatedTargetLocation, void 0, void 0, destinationGridview);
17940
+ const newGroup = this.createGroupAtLocation(updatedTargetLocation, this.dropSizing(getGridLocation(destinationGroup.element)), void 0, destinationGridview);
17550
17941
  this.movingLock(() => newGroup.model.openPanel(removedPanel, { skipSetActive: true }));
17551
17942
  this.doSetGroupAndPanelActive(newGroup);
17552
17943
  this.fireDidMovePanel(this.getGroupPanel(sourceItemId), sourceGroup);
@@ -17563,7 +17954,7 @@ var DockviewComponent = class extends BaseGrid {
17563
17954
  skipSetActiveGroup: true
17564
17955
  }));
17565
17956
  if (!removedPanel) throw new Error(`dockview: No panel with id ${sourceItemId}`);
17566
- const newGroup = this.createGroupAtLocation(targetLocation, void 0, void 0, destinationGridview);
17957
+ const newGroup = this.createGroupAtLocation(targetLocation, this.dropSizing(referenceLocation), void 0, destinationGridview);
17567
17958
  this.movingLock(() => newGroup.model.openPanel(removedPanel, { skipSetGroupActive: true }));
17568
17959
  this.doSetGroupAndPanelActive(newGroup);
17569
17960
  this.fireDidMovePanel(removedPanel, sourceGroup);
@@ -17575,7 +17966,7 @@ var DockviewComponent = class extends BaseGrid {
17575
17966
  }));
17576
17967
  const updatedReferenceLocation = getGridLocation(destinationGroup.element);
17577
17968
  const location = getRelativeLocation(destinationGridview.orientation, updatedReferenceLocation, destinationTarget);
17578
- this.movingLock(() => this.doAddGroup(targetGroup, location, void 0, destinationGridview));
17969
+ this.movingLock(() => this.doAddGroup(targetGroup, location, this.dropSizing(updatedReferenceLocation), destinationGridview));
17579
17970
  this.setGroupLocationForRoot(targetGroup, destinationGridview);
17580
17971
  this.doSetGroupAndPanelActive(targetGroup);
17581
17972
  this.fireDidMovePanel(this.getGroupPanel(sourceItemId), sourceGroup);
@@ -17590,7 +17981,7 @@ var DockviewComponent = class extends BaseGrid {
17590
17981
  }));
17591
17982
  if (!removedPanel) throw new Error(`dockview: No panel with id ${sourceItemId}`);
17592
17983
  const dropLocation = getRelativeLocation(destinationGridview.orientation, referenceLocation, destinationTarget);
17593
- const group = this.createGroupAtLocation(dropLocation, void 0, void 0, destinationGridview);
17984
+ const group = this.createGroupAtLocation(dropLocation, this.dropSizing(referenceLocation), void 0, destinationGridview);
17594
17985
  this.movingLock(() => group.model.openPanel(removedPanel, { skipSetGroupActive: true }));
17595
17986
  this.doSetGroupAndPanelActive(group);
17596
17987
  this.fireDidMovePanel(removedPanel, sourceGroup);
@@ -17634,7 +18025,7 @@ var DockviewComponent = class extends BaseGrid {
17634
18025
  if (!destinationTarget || destinationTarget === "center" || !referenceLocation) targetGroup = destinationGroup;
17635
18026
  else {
17636
18027
  const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, destinationTarget);
17637
- targetGroup = this.createGroupAtLocation(dropLocation);
18028
+ targetGroup = this.createGroupAtLocation(dropLocation, this.dropSizing(referenceLocation));
17638
18029
  }
17639
18030
  if (!options.keepEmptyGroups && sourceGroup.model.size === 0 && sourceGroup !== targetGroup) this.doRemoveGroup(sourceGroup, { skipActive: true });
17640
18031
  addPanelsToGroup(targetGroup);
@@ -17685,6 +18076,21 @@ var DockviewComponent = class extends BaseGrid {
17685
18076
  if (options.skipSetActive !== true) this.doSetGroupAndPanelActive(to);
17686
18077
  else if (!this.activePanel) this.doSetGroupAndPanelActive(to);
17687
18078
  } else {
18079
+ const isReorderWithinBranch = (() => {
18080
+ if (from.api.location.type === "edge" || to.api.location.type === "edge") return false;
18081
+ const root = this.getGridviewForGroup(from);
18082
+ if (root !== this.getGridviewForGroup(to)) return false;
18083
+ let fromLocation;
18084
+ let toLocation;
18085
+ try {
18086
+ fromLocation = getGridLocation(from.element);
18087
+ toLocation = getGridLocation(to.element);
18088
+ } catch (_unused) {
18089
+ return false;
18090
+ }
18091
+ if (fromLocation.length === 0 || toLocation.length === 0) return false;
18092
+ return sequenceEquals(tail(fromLocation)[0], tail(toLocation)[0]) && getLocationOrientation(root.orientation, toLocation) === getDirectionOrientation(target);
18093
+ })();
17688
18094
  if (from.api.location.type === "edge") {
17689
18095
  /**
17690
18096
  * Edge groups are permanent structural elements and must
@@ -17750,13 +18156,10 @@ var DockviewComponent = class extends BaseGrid {
17750
18156
  const referenceLocation = getGridLocation(to.element);
17751
18157
  const dropLocation = getRelativeLocation(destGridview.orientation, referenceLocation, target);
17752
18158
  let size;
17753
- switch (destGridview.orientation) {
17754
- case "VERTICAL":
17755
- size = referenceLocation.length % 2 == 0 ? from.api.width : from.api.height;
17756
- break;
17757
- case "HORIZONTAL":
17758
- size = referenceLocation.length % 2 == 0 ? from.api.height : from.api.width;
17759
- break;
18159
+ if (isReorderWithinBranch) size = getDirectionOrientation(target) === "HORIZONTAL" ? from.api.width : from.api.height;
18160
+ else {
18161
+ var _referenceLocation;
18162
+ size = Sizing.Split((_referenceLocation = referenceLocation[referenceLocation.length - 1]) !== null && _referenceLocation !== void 0 ? _referenceLocation : 0);
17760
18163
  }
17761
18164
  destGridview.addView(source, size, dropLocation);
17762
18165
  this.setGroupLocationForRoot(source, destGridview);
@@ -17881,6 +18284,16 @@ var DockviewComponent = class extends BaseGrid {
17881
18284
  });
17882
18285
  return panel;
17883
18286
  }
18287
+ /**
18288
+ * Sizing for a group created by a drop next to `referenceLocation`: half
18289
+ * of the group the overlay was drawn over, leaving its siblings alone, so
18290
+ * the panel lands in the region the overlay indicated (#1612). Gridview
18291
+ * rewrites the index to 0 when a cross-axis drop wraps the reference in a
18292
+ * new branch, so one value serves both paths.
18293
+ */
18294
+ dropSizing(referenceLocation) {
18295
+ return Sizing.Split(referenceLocation.length === 0 ? 0 : referenceLocation[referenceLocation.length - 1]);
18296
+ }
17884
18297
  createGroupAtLocation(location, size, options, gridview = this.gridview) {
17885
18298
  const group = this.createGroup(options);
17886
18299
  this.doAddGroup(group, location, size, gridview);
@@ -17940,22 +18353,22 @@ var DockviewComponent = class extends BaseGrid {
17940
18353
  return location.length % 2 == 1 ? rootOrientation : orthogonal(rootOrientation);
17941
18354
  }
17942
18355
  updateTheme() {
17943
- var _this$_options$theme, _this$_shellThemeClas, _theme$gap, _this$_popoutWindowSe23, _this$_popoutWindowSe24, _this$_shellManager4, _theme$edgeGroupColla, _theme$tabGroupIndica;
18356
+ var _this$_options$theme, _this$_shellThemeClas, _theme$gap, _this$_popoutWindowSe23, _this$_popoutWindowSe24, _this$_shellManager5, _theme$edgeGroupColla, _theme$tabGroupIndica;
17944
18357
  const theme = (_this$_options$theme = this._options.theme) !== null && _this$_options$theme !== void 0 ? _this$_options$theme : themeAbyss;
17945
18358
  (_this$_shellThemeClas = this._shellThemeClassnames) === null || _this$_shellThemeClas === void 0 || _this$_shellThemeClas.setClassNames(theme.className);
17946
18359
  const gap = (_theme$gap = theme.gap) !== null && _theme$gap !== void 0 ? _theme$gap : 0;
17947
18360
  this.gridview.margin = gap;
17948
18361
  for (const floating of this.floatingGroups) floating.gridview.margin = gap;
17949
18362
  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;
17950
- (_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);
18363
+ (_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);
17951
18364
  if (theme.dndOverlayBorder === void 0) {
17952
- var _this$_shellManager5;
18365
+ var _this$_shellManager6;
17953
18366
  this.element.style.removeProperty("--dv-drag-over-border");
17954
- (_this$_shellManager5 = this._shellManager) === null || _this$_shellManager5 === void 0 || _this$_shellManager5.element.style.removeProperty("--dv-drag-over-border");
18367
+ (_this$_shellManager6 = this._shellManager) === null || _this$_shellManager6 === void 0 || _this$_shellManager6.element.style.removeProperty("--dv-drag-over-border");
17955
18368
  } else {
17956
- var _this$_shellManager6;
18369
+ var _this$_shellManager7;
17957
18370
  this.element.style.setProperty("--dv-drag-over-border", theme.dndOverlayBorder);
17958
- (_this$_shellManager6 = this._shellManager) === null || _this$_shellManager6 === void 0 || _this$_shellManager6.element.style.setProperty("--dv-drag-over-border", theme.dndOverlayBorder);
18371
+ (_this$_shellManager7 = this._shellManager) === null || _this$_shellManager7 === void 0 || _this$_shellManager7.element.style.setProperty("--dv-drag-over-border", theme.dndOverlayBorder);
17959
18372
  }
17960
18373
  switch (theme.dndOverlayMounting) {
17961
18374
  case "absolute":
@@ -18854,4 +19267,4 @@ function createPaneview(element, options) {
18854
19267
  }
18855
19268
 
18856
19269
  //#endregion
18857
- export { AdvancedDnDModule, AdvancedDnDService, BaseGrid, ContentContainer, DEFAULT_TAB_GROUP_COLORS, DefaultDockviewDeserialzier, DefaultTab, DockviewApi, DockviewComponent, CompositeDisposable as DockviewCompositeDisposable, DockviewDidDropEvent, Disposable as DockviewDisposable, Emitter as DockviewEmitter, Event as DockviewEvent, DockviewGroupPanel, DockviewGroupPanelModel, MutableDisposable as DockviewMutableDisposable, DockviewPanel, DockviewUnhandledDragOverEvent, DockviewWillDropEvent, DockviewWillShowOverlayLocationEvent, DraggablePaneviewPanel, EdgeGroupModule, FloatingGroupModule, Gridview, GridviewApi, GridviewComponent, GridviewPanel, LayoutPriority, LiveRegionModule, LocalSelectionTransfer, OVERFLOW_MAX_TAB_ROWS_VARIABLE, OVERFLOW_WRAP_TABS_CAPPED_CLASS, OVERFLOW_WRAP_TABS_CLASS, OVERFLOW_WRAP_TABS_VERTICAL_TAB_HEIGHT_VARIABLE, Orientation, PROPERTY_KEYS_DOCKVIEW, PROPERTY_KEYS_GRIDVIEW, PROPERTY_KEYS_PANEVIEW, PROPERTY_KEYS_SPLITVIEW, PaneFramework, PaneTransfer, PanelTransfer, Paneview, PaneviewApi, PaneviewComponent, PaneviewPanel, PaneviewUnhandledDragOverEvent, SashState, Sizing, Splitview, SplitviewApi, SplitviewComponent, SplitviewPanel, Tab, TabGroupChipsModule, TabGroupChipsService, TabGroupColorPalette, applyTabGroupAccent, clearRegisteredModules, createCloseButton, createDismissableLayer, createDockview, createGridview, createPaneview, createPinButton, createSplitview, defineModule, directionToPosition, findRelativeZIndexParent, getDirectionOrientation, getGridLocation, getLocationOrientation, getPaneData, getPanelData, getRegisteredModules, getRelativeLocation, indexInParent, isAnyEdgeGroupEnabled, isEdgeGroupEnabled, isGridBranchNode, isGroupOptionsWithGroup, isGroupOptionsWithPanel, isPanelOptionsWithGroup, isPanelOptionsWithPanel, orthogonal, positionToDirection, prefersReducedMotion, registerModules, resolveMessages, resolveOpaqueBackground, resolveTabGroupAccent, themeAbyss, themeAbyssSpaced, themeCatppuccinMocha, themeCatppuccinMochaSpaced, themeDark, themeDracula, themeGithubDark, themeGithubDarkSpaced, themeGithubLight, themeGithubLightSpaced, themeLight, themeLightSpaced, themeMonokai, themeNord, themeNordSpaced, themeSolarizedLight, themeSolarizedLightSpaced, themeVisualStudio, toTarget };
19270
+ export { AdvancedDnDModule, AdvancedDnDService, BaseGrid, ContentContainer, ContextMenuController, ContextMenuModule, DEFAULT_TAB_GROUP_COLORS, DefaultDockviewDeserialzier, DefaultTab, DockviewApi, DockviewComponent, CompositeDisposable as DockviewCompositeDisposable, DockviewDidDropEvent, Disposable as DockviewDisposable, Emitter as DockviewEmitter, Event as DockviewEvent, DockviewGroupPanel, DockviewGroupPanelModel, MutableDisposable as DockviewMutableDisposable, DockviewPanel, DockviewUnhandledDragOverEvent, DockviewWillDropEvent, DockviewWillShowOverlayLocationEvent, DraggablePaneviewPanel, EdgeGroupModule, FloatingGroupModule, Gridview, GridviewApi, GridviewComponent, GridviewPanel, LayoutPriority, LiveRegionModule, LocalSelectionTransfer, OVERFLOW_MAX_TAB_ROWS_VARIABLE, OVERFLOW_WRAP_TABS_CAPPED_CLASS, OVERFLOW_WRAP_TABS_CLASS, OVERFLOW_WRAP_TABS_VERTICAL_TAB_HEIGHT_VARIABLE, Orientation, PROPERTY_KEYS_DOCKVIEW, PROPERTY_KEYS_GRIDVIEW, PROPERTY_KEYS_PANEVIEW, PROPERTY_KEYS_SPLITVIEW, PaneFramework, PaneTransfer, PanelTransfer, Paneview, PaneviewApi, PaneviewComponent, PaneviewPanel, PaneviewUnhandledDragOverEvent, SashState, Sizing, Splitview, SplitviewApi, SplitviewComponent, SplitviewPanel, Tab, TabGroupChipsModule, TabGroupChipsService, TabGroupColorPalette, applyTabGroupAccent, clearRegisteredModules, createCloseButton, createDismissableLayer, createDockview, createGridview, createPaneview, createPinButton, createSplitview, defineModule, directionToPosition, findRelativeZIndexParent, getDirectionOrientation, getGridLocation, getLocationOrientation, getPaneData, getPanelData, getRegisteredModules, getRelativeLocation, indexInParent, isAnyEdgeGroupEnabled, isEdgeGroupEnabled, isGridBranchNode, isGroupOptionsWithGroup, isGroupOptionsWithPanel, isPanelOptionsWithGroup, isPanelOptionsWithPanel, orthogonal, positionToDirection, prefersReducedMotion, registerModules, resolveMessages, resolveOpaqueBackground, resolveTabGroupAccent, themeAbyss, themeAbyssSpaced, themeCatppuccinMocha, themeCatppuccinMochaSpaced, themeDark, themeDracula, themeGithubDark, themeGithubDarkSpaced, themeGithubLight, themeGithubLightSpaced, themeLight, themeLightSpaced, themeMonokai, themeNord, themeNordSpaced, themeSolarizedLight, themeSolarizedLightSpaced, themeVisualStudio, toTarget };