dockview-core 6.2.1 → 6.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/dist/cjs/api/dockviewGroupPanelApi.d.ts +10 -1
  2. package/dist/cjs/api/dockviewGroupPanelApi.js +16 -0
  3. package/dist/cjs/dnd/groupDragHandler.js +34 -12
  4. package/dist/cjs/dockview/components/titlebar/tabGroupIndicator.js +2 -2
  5. package/dist/cjs/dockview/components/titlebar/tabs.js +9 -2
  6. package/dist/cjs/dockview/components/titlebar/voidContainer.js +6 -0
  7. package/dist/cjs/dockview/dockviewComponent.d.ts +1 -0
  8. package/dist/cjs/dockview/dockviewComponent.js +187 -125
  9. package/dist/cjs/dockview/dockviewGroupPanelModel.d.ts +1 -0
  10. package/dist/cjs/dockview/dockviewGroupPanelModel.js +9 -0
  11. package/dist/cjs/dockview/dockviewPanel.js +5 -0
  12. package/dist/cjs/dockview/dockviewPanelModel.d.ts +2 -0
  13. package/dist/cjs/dockview/dockviewPanelModel.js +8 -0
  14. package/dist/cjs/dockview/framework.d.ts +8 -0
  15. package/dist/cjs/dockview/options.d.ts +13 -2
  16. package/dist/cjs/dockview/options.js +2 -0
  17. package/dist/cjs/dom.d.ts +5 -1
  18. package/dist/cjs/dom.js +14 -2
  19. package/dist/cjs/index.d.ts +1 -1
  20. package/dist/cjs/overlay/overlayRenderContainer.js +13 -3
  21. package/dist/cjs/popoutWindow.d.ts +2 -0
  22. package/dist/cjs/popoutWindow.js +3 -1
  23. package/dist/dockview-core.js +169 -30
  24. package/dist/dockview-core.min.js +2 -2
  25. package/dist/dockview-core.min.js.map +1 -1
  26. package/dist/dockview-core.min.noStyle.js +2 -2
  27. package/dist/dockview-core.min.noStyle.js.map +1 -1
  28. package/dist/dockview-core.noStyle.js +169 -30
  29. package/dist/esm/api/dockviewGroupPanelApi.d.ts +10 -1
  30. package/dist/esm/api/dockviewGroupPanelApi.js +12 -0
  31. package/dist/esm/dnd/groupDragHandler.js +34 -12
  32. package/dist/esm/dockview/components/titlebar/tabGroupIndicator.js +2 -2
  33. package/dist/esm/dockview/components/titlebar/tabs.js +12 -2
  34. package/dist/esm/dockview/components/titlebar/voidContainer.js +6 -0
  35. package/dist/esm/dockview/dockviewComponent.d.ts +1 -0
  36. package/dist/esm/dockview/dockviewComponent.js +49 -7
  37. package/dist/esm/dockview/dockviewGroupPanelModel.d.ts +1 -0
  38. package/dist/esm/dockview/dockviewGroupPanelModel.js +9 -0
  39. package/dist/esm/dockview/dockviewPanel.js +5 -0
  40. package/dist/esm/dockview/dockviewPanelModel.d.ts +2 -0
  41. package/dist/esm/dockview/dockviewPanelModel.js +8 -0
  42. package/dist/esm/dockview/framework.d.ts +8 -0
  43. package/dist/esm/dockview/options.d.ts +13 -2
  44. package/dist/esm/dockview/options.js +2 -0
  45. package/dist/esm/dom.d.ts +5 -1
  46. package/dist/esm/dom.js +13 -2
  47. package/dist/esm/index.d.ts +1 -1
  48. package/dist/esm/overlay/overlayRenderContainer.js +13 -3
  49. package/dist/esm/popoutWindow.d.ts +2 -0
  50. package/dist/esm/popoutWindow.js +3 -1
  51. package/dist/package/main.cjs.js +169 -30
  52. package/dist/package/main.cjs.min.js +2 -2
  53. package/dist/package/main.esm.min.mjs +2 -2
  54. package/dist/package/main.esm.mjs +169 -30
  55. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  import { Position } from '../dnd/droptarget';
2
2
  import { DockviewComponent } from '../dockview/dockviewComponent';
3
3
  import { DockviewGroupPanel } from '../dockview/dockviewGroupPanel';
4
- import { DockviewGroupChangeEvent, DockviewGroupLocation } from '../dockview/dockviewGroupPanelModel';
4
+ import { DockviewGroupChangeEvent, DockviewGroupLocation, DockviewGroupPanelLocked } from '../dockview/dockviewGroupPanelModel';
5
5
  import { DockviewHeaderPosition } from '../dockview/options';
6
6
  import { Emitter, Event } from '../events';
7
7
  import { GridviewPanelApi, GridviewPanelApiImpl, SizeEvent } from './gridviewPanelApi';
@@ -29,6 +29,13 @@ export interface DockviewGroupPanelApi extends GridviewPanelApi {
29
29
  */
30
30
  readonly onDidCollapsedChange: Event<DockviewGroupPanelCollapsedChangeEvent>;
31
31
  readonly location: DockviewGroupLocation;
32
+ /**
33
+ * Whether this group is locked against drop interactions.
34
+ * - `true`: panels cannot be dropped into the group (center / tabs),
35
+ * but the group can still be split from its edges.
36
+ * - `'no-drop-target'`: all drop zones are disabled for this group.
37
+ */
38
+ locked: DockviewGroupPanelLocked;
32
39
  /**
33
40
  * If you require the Window object
34
41
  */
@@ -68,6 +75,8 @@ export declare class DockviewGroupPanelApiImpl extends GridviewPanelApiImpl {
68
75
  readonly _onDidCollapsedChange: Emitter<DockviewGroupPanelCollapsedChangeEvent>;
69
76
  readonly onDidCollapsedChange: Event<DockviewGroupPanelCollapsedChangeEvent>;
70
77
  get location(): DockviewGroupLocation;
78
+ get locked(): DockviewGroupPanelLocked;
79
+ set locked(value: DockviewGroupPanelLocked);
71
80
  constructor(id: string, accessor: DockviewComponent);
72
81
  setSize(event: SizeEvent): void;
73
82
  close(): void;
@@ -61,6 +61,22 @@ var DockviewGroupPanelApiImpl = /** @class */ (function (_super) {
61
61
  enumerable: false,
62
62
  configurable: true
63
63
  });
64
+ Object.defineProperty(DockviewGroupPanelApiImpl.prototype, "locked", {
65
+ get: function () {
66
+ if (!this._group) {
67
+ throw new Error(NOT_INITIALIZED_MESSAGE);
68
+ }
69
+ return this._group.locked;
70
+ },
71
+ set: function (value) {
72
+ if (!this._group) {
73
+ throw new Error(NOT_INITIALIZED_MESSAGE);
74
+ }
75
+ this._group.locked = value;
76
+ },
77
+ enumerable: false,
78
+ configurable: true
79
+ });
64
80
  DockviewGroupPanelApiImpl.prototype.setSize = function (event) {
65
81
  // Always store the requested size
66
82
  this._pendingSize = __assign({}, event);
@@ -57,19 +57,41 @@ var GroupDragHandler = /** @class */ (function (_super) {
57
57
  var bgColor = style.getPropertyValue('--dv-activegroup-visiblepanel-tab-background-color');
58
58
  var color = style.getPropertyValue('--dv-activegroup-visiblepanel-tab-color');
59
59
  if (dataTransfer) {
60
- var ghostElement = document.createElement('div');
61
- ghostElement.style.backgroundColor = bgColor;
62
- ghostElement.style.color = color;
63
- ghostElement.style.padding = '2px 8px';
64
- ghostElement.style.height = '24px';
65
- ghostElement.style.fontSize = '11px';
66
- ghostElement.style.lineHeight = '20px';
67
- ghostElement.style.borderRadius = '12px';
68
- ghostElement.style.position = 'absolute';
69
- ghostElement.style.pointerEvents = 'none';
70
- ghostElement.style.top = '-9999px';
71
- ghostElement.textContent = "Multiple Panels (".concat(this.group.size, ")");
60
+ var createGhost = this.accessor.options.createGroupDragGhostComponent;
61
+ var ghostElement = void 0;
62
+ var customRenderer = void 0;
63
+ if (createGhost) {
64
+ customRenderer = createGhost(this.group);
65
+ customRenderer.init({
66
+ group: this.group,
67
+ api: this.accessor.api,
68
+ });
69
+ ghostElement = customRenderer.element;
70
+ ghostElement.style.position = 'absolute';
71
+ ghostElement.style.pointerEvents = 'none';
72
+ ghostElement.style.top = '-9999px';
73
+ }
74
+ else {
75
+ ghostElement = document.createElement('div');
76
+ ghostElement.style.backgroundColor = bgColor;
77
+ ghostElement.style.color = color;
78
+ ghostElement.style.padding = '2px 8px';
79
+ ghostElement.style.height = '24px';
80
+ ghostElement.style.fontSize = '11px';
81
+ ghostElement.style.lineHeight = '20px';
82
+ ghostElement.style.borderRadius = '12px';
83
+ ghostElement.style.position = 'absolute';
84
+ ghostElement.style.pointerEvents = 'none';
85
+ ghostElement.style.top = '-9999px';
86
+ ghostElement.textContent = "Multiple Panels (".concat(this.group.size, ")");
87
+ }
72
88
  (0, ghost_1.addGhostImage)(dataTransfer, ghostElement, { y: -10, x: 30 });
89
+ if (customRenderer === null || customRenderer === void 0 ? void 0 : customRenderer.dispose) {
90
+ // addGhostImage removes the element from the DOM on the next
91
+ // tick; dispose the framework renderer on the same schedule.
92
+ var renderer_1 = customRenderer;
93
+ setTimeout(function () { var _a; return (_a = renderer_1.dispose) === null || _a === void 0 ? void 0 : _a.call(renderer_1); }, 0);
94
+ }
73
95
  }
74
96
  return {
75
97
  dispose: function () {
@@ -350,7 +350,7 @@ var WrapTabGroupIndicator = /** @class */ (function (_super) {
350
350
  var svg = underline.firstElementChild;
351
351
  var path;
352
352
  if (!svg || svg.tagName !== 'svg') {
353
- underline.innerHTML = '';
353
+ underline.replaceChildren();
354
354
  svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
355
355
  svg.style.display = 'block';
356
356
  path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
@@ -454,7 +454,7 @@ var NoneTabGroupIndicator = /** @class */ (function (_super) {
454
454
  underline.style.display = '';
455
455
  // Clear any SVG content left over from a mode switch
456
456
  if (underline.firstElementChild) {
457
- underline.innerHTML = '';
457
+ underline.replaceChildren();
458
458
  }
459
459
  underline.style.backgroundColor = color;
460
460
  if (isVertical) {
@@ -1213,11 +1213,15 @@ var Tabs = /** @class */ (function (_super) {
1213
1213
  if (!isInsideRange && !isJustBeforeGroup) {
1214
1214
  return "continue";
1215
1215
  }
1216
- if (isGroupDrag) {
1216
+ if (isGroupDrag && isInsideRange) {
1217
1217
  // A group cannot be dropped inside another group.
1218
1218
  // Snap the insertion index to just before or just
1219
1219
  // after this group based on cursor position relative
1220
- // to the group's midpoint.
1220
+ // to the group's midpoint. Only applies when the
1221
+ // insertion would land *inside* the group — for
1222
+ // `isJustBeforeGroup`, the index is already outside
1223
+ // (immediately left of the group) and is a valid
1224
+ // drop position, so leave it untouched (issue #1264).
1221
1225
  var groupMid = (firstIdx + lastIdx + 1) / 2;
1222
1226
  if (insertionIndex < groupMid) {
1223
1227
  insertionIndex = firstIdx;
@@ -1227,6 +1231,9 @@ var Tabs = /** @class */ (function (_super) {
1227
1231
  }
1228
1232
  return "break";
1229
1233
  }
1234
+ if (isGroupDrag && isJustBeforeGroup) {
1235
+ return "break";
1236
+ }
1230
1237
  if (isJustBeforeGroup) {
1231
1238
  // Check whether only the source tab (or source group
1232
1239
  // tabs) sits between insertionIndex and firstIdx.
@@ -43,6 +43,12 @@ var VoidContainer = /** @class */ (function (_super) {
43
43
  _this.dropTarget = new droptarget_1.Droptarget(_this._element, {
44
44
  acceptedTargetZones: ['center'],
45
45
  canDisplayOverlay: function (event, position) {
46
+ if (_this.group.api.locked) {
47
+ // Dropping on the void/header space adds the panel
48
+ // to this group, which `locked` is meant to prevent
49
+ // (both `true` and `'no-drop-target'`).
50
+ return false;
51
+ }
46
52
  var data = (0, dataTransfer_1.getPanelData)();
47
53
  if (data && _this.accessor.id === data.viewId) {
48
54
  return true;
@@ -262,6 +262,7 @@ export declare class DockviewComponent extends BaseGrid<DockviewGroupPanel> impl
262
262
  private readonly _popoutGroups;
263
263
  private readonly _rootDropTarget;
264
264
  private _popoutRestorationPromise;
265
+ private readonly _popoutRestorationCleanups;
265
266
  private readonly _onDidRemoveGroup;
266
267
  readonly onDidRemoveGroup: Event<DockviewGroupPanel>;
267
268
  protected readonly _onDidAddGroup: Emitter<DockviewGroupPanel>;