dockview-core 3.2.0 → 4.0.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.
Files changed (110) hide show
  1. package/dist/cjs/api/component.api.d.ts +0 -2
  2. package/dist/cjs/api/component.api.js +0 -10
  3. package/dist/cjs/dnd/abstractDragHandler.js +4 -2
  4. package/dist/cjs/dnd/dropTargetAnchorContainer.d.ts +16 -0
  5. package/dist/cjs/dnd/dropTargetAnchorContainer.js +105 -0
  6. package/dist/cjs/dnd/droptarget.d.ts +16 -0
  7. package/dist/cjs/dnd/droptarget.js +138 -14
  8. package/dist/cjs/dnd/ghost.d.ts +4 -1
  9. package/dist/cjs/dnd/ghost.js +3 -2
  10. package/dist/cjs/dnd/groupDragHandler.js +3 -1
  11. package/dist/cjs/dockview/components/panel/content.js +10 -13
  12. package/dist/cjs/dockview/components/popupService.d.ts +13 -0
  13. package/dist/cjs/dockview/components/popupService.js +76 -0
  14. package/dist/cjs/dockview/components/tab/tab.js +17 -7
  15. package/dist/cjs/dockview/components/titlebar/tabOverflowControl.d.ts +8 -0
  16. package/dist/cjs/dockview/components/titlebar/tabOverflowControl.js +20 -0
  17. package/dist/cjs/dockview/components/titlebar/tabs.d.ts +45 -0
  18. package/dist/cjs/dockview/components/titlebar/tabs.js +288 -0
  19. package/dist/cjs/dockview/components/titlebar/tabsContainer.d.ts +8 -9
  20. package/dist/cjs/dockview/components/titlebar/tabsContainer.js +108 -152
  21. package/dist/cjs/dockview/components/titlebar/voidContainer.js +2 -9
  22. package/dist/cjs/dockview/dockviewComponent.d.ts +10 -3
  23. package/dist/cjs/dockview/dockviewComponent.js +71 -30
  24. package/dist/cjs/dockview/dockviewGroupPanelModel.d.ts +4 -0
  25. package/dist/cjs/dockview/dockviewGroupPanelModel.js +31 -0
  26. package/dist/cjs/dockview/dockviewPanelModel.d.ts +5 -3
  27. package/dist/cjs/dockview/dockviewPanelModel.js +25 -4
  28. package/dist/cjs/dockview/framework.d.ts +4 -1
  29. package/dist/cjs/dockview/options.d.ts +8 -5
  30. package/dist/cjs/dockview/options.js +3 -1
  31. package/dist/cjs/dockview/theme.d.ts +31 -0
  32. package/dist/cjs/dockview/theme.js +42 -0
  33. package/dist/cjs/dockview/types.d.ts +5 -1
  34. package/dist/cjs/dom.d.ts +1 -0
  35. package/dist/cjs/dom.js +15 -1
  36. package/dist/cjs/gridview/baseComponentGridview.d.ts +3 -0
  37. package/dist/cjs/index.d.ts +1 -0
  38. package/dist/cjs/index.js +1 -0
  39. package/dist/cjs/paneview/paneviewComponent.js +1 -0
  40. package/dist/cjs/scrollbar.d.ts +12 -0
  41. package/dist/cjs/scrollbar.js +106 -0
  42. package/dist/cjs/splitview/splitview.js +1 -0
  43. package/dist/cjs/splitview/splitviewComponent.js +1 -0
  44. package/dist/dockview-core.amd.js +930 -293
  45. package/dist/dockview-core.amd.js.map +1 -1
  46. package/dist/dockview-core.amd.min.js +2 -2
  47. package/dist/dockview-core.amd.min.js.map +1 -1
  48. package/dist/dockview-core.amd.min.noStyle.js +2 -2
  49. package/dist/dockview-core.amd.min.noStyle.js.map +1 -1
  50. package/dist/dockview-core.amd.noStyle.js +929 -292
  51. package/dist/dockview-core.amd.noStyle.js.map +1 -1
  52. package/dist/dockview-core.cjs.js +930 -293
  53. package/dist/dockview-core.cjs.js.map +1 -1
  54. package/dist/dockview-core.esm.js +923 -294
  55. package/dist/dockview-core.esm.js.map +1 -1
  56. package/dist/dockview-core.esm.min.js +2 -2
  57. package/dist/dockview-core.esm.min.js.map +1 -1
  58. package/dist/dockview-core.js +930 -293
  59. package/dist/dockview-core.js.map +1 -1
  60. package/dist/dockview-core.min.js +2 -2
  61. package/dist/dockview-core.min.js.map +1 -1
  62. package/dist/dockview-core.min.noStyle.js +2 -2
  63. package/dist/dockview-core.min.noStyle.js.map +1 -1
  64. package/dist/dockview-core.noStyle.js +929 -292
  65. package/dist/dockview-core.noStyle.js.map +1 -1
  66. package/dist/esm/api/component.api.d.ts +0 -2
  67. package/dist/esm/api/component.api.js +0 -6
  68. package/dist/esm/dnd/abstractDragHandler.js +4 -2
  69. package/dist/esm/dnd/dropTargetAnchorContainer.d.ts +16 -0
  70. package/dist/esm/dnd/dropTargetAnchorContainer.js +74 -0
  71. package/dist/esm/dnd/droptarget.d.ts +16 -0
  72. package/dist/esm/dnd/droptarget.js +134 -14
  73. package/dist/esm/dnd/ghost.d.ts +4 -1
  74. package/dist/esm/dnd/ghost.js +3 -2
  75. package/dist/esm/dnd/groupDragHandler.js +3 -1
  76. package/dist/esm/dockview/components/panel/content.js +10 -13
  77. package/dist/esm/dockview/components/popupService.d.ts +13 -0
  78. package/dist/esm/dockview/components/popupService.js +53 -0
  79. package/dist/esm/dockview/components/tab/tab.js +15 -7
  80. package/dist/esm/dockview/components/titlebar/tabOverflowControl.d.ts +8 -0
  81. package/dist/esm/dockview/components/titlebar/tabOverflowControl.js +16 -0
  82. package/dist/esm/dockview/components/titlebar/tabs.d.ts +45 -0
  83. package/dist/esm/dockview/components/titlebar/tabs.js +183 -0
  84. package/dist/esm/dockview/components/titlebar/tabsContainer.d.ts +8 -9
  85. package/dist/esm/dockview/components/titlebar/tabsContainer.js +133 -162
  86. package/dist/esm/dockview/components/titlebar/voidContainer.js +2 -9
  87. package/dist/esm/dockview/dockviewComponent.d.ts +10 -3
  88. package/dist/esm/dockview/dockviewComponent.js +69 -24
  89. package/dist/esm/dockview/dockviewGroupPanelModel.d.ts +4 -0
  90. package/dist/esm/dockview/dockviewGroupPanelModel.js +27 -0
  91. package/dist/esm/dockview/dockviewPanelModel.d.ts +5 -3
  92. package/dist/esm/dockview/dockviewPanelModel.js +14 -4
  93. package/dist/esm/dockview/framework.d.ts +4 -1
  94. package/dist/esm/dockview/options.d.ts +8 -5
  95. package/dist/esm/dockview/options.js +3 -1
  96. package/dist/esm/dockview/theme.d.ts +31 -0
  97. package/dist/esm/dockview/theme.js +39 -0
  98. package/dist/esm/dockview/types.d.ts +5 -1
  99. package/dist/esm/dom.d.ts +1 -0
  100. package/dist/esm/dom.js +13 -0
  101. package/dist/esm/gridview/baseComponentGridview.d.ts +3 -0
  102. package/dist/esm/index.d.ts +1 -0
  103. package/dist/esm/index.js +1 -0
  104. package/dist/esm/paneview/paneviewComponent.js +1 -0
  105. package/dist/esm/scrollbar.d.ts +12 -0
  106. package/dist/esm/scrollbar.js +80 -0
  107. package/dist/esm/splitview/splitview.js +1 -0
  108. package/dist/esm/splitview/splitviewComponent.js +1 -0
  109. package/dist/styles/dockview.css +423 -69
  110. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * dockview-core
3
- * @version 3.2.0
3
+ * @version 4.0.1
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -339,6 +339,20 @@
339
339
  }
340
340
  }
341
341
 
342
+ class OverflowObserver extends CompositeDisposable {
343
+ constructor(el) {
344
+ super();
345
+ this._onDidChange = new Emitter();
346
+ this.onDidChange = this._onDidChange.event;
347
+ this._value = null;
348
+ this.addDisposables(this._onDidChange, watchElementResize(el, (entry) => {
349
+ const hasScrollX = entry.target.scrollWidth > entry.target.clientWidth;
350
+ const hasScrollY = entry.target.scrollHeight > entry.target.clientHeight;
351
+ this._value = { hasScrollX, hasScrollY };
352
+ this._onDidChange.fire(this._value);
353
+ }));
354
+ }
355
+ }
342
356
  function watchElementResize(element, cb) {
343
357
  const observer = new ResizeObserver((entires) => {
344
358
  /**
@@ -577,6 +591,19 @@
577
591
  }
578
592
  }
579
593
  }
594
+ function isChildEntirelyVisibleWithinParent(child, parent) {
595
+ //
596
+ const childPosition = getDomNodePagePosition(child);
597
+ const parentPosition = getDomNodePagePosition(parent);
598
+ if (childPosition.left < parentPosition.left) {
599
+ return false;
600
+ }
601
+ if (childPosition.left + childPosition.width >
602
+ parentPosition.left + parentPosition.width) {
603
+ return false;
604
+ }
605
+ return true;
606
+ }
580
607
 
581
608
  function tail(arr) {
582
609
  if (arr.length === 0) {
@@ -584,9 +611,6 @@
584
611
  }
585
612
  return [arr.slice(0, arr.length - 1), arr[arr.length - 1]];
586
613
  }
587
- function last(arr) {
588
- return arr.length > 0 ? arr[arr.length - 1] : undefined;
589
- }
590
614
  function sequenceEquals(arr1, arr2) {
591
615
  if (arr1.length !== arr2.length) {
592
616
  return false;
@@ -852,6 +876,7 @@
852
876
  }
853
877
  set margin(value) {
854
878
  this._margin = value;
879
+ toggleClass(this.element, 'dv-splitview-has-margin', value !== 0);
855
880
  }
856
881
  constructor(container, options) {
857
882
  var _a, _b;
@@ -3423,9 +3448,6 @@
3423
3448
  get totalPanels() {
3424
3449
  return this.component.totalPanels;
3425
3450
  }
3426
- get gap() {
3427
- return this.component.gap;
3428
- }
3429
3451
  /**
3430
3452
  * Invoked when the active group changes. May be undefined if no group is active.
3431
3453
  */
@@ -3656,9 +3678,6 @@
3656
3678
  addPopoutGroup(item, options) {
3657
3679
  return this.component.addPopoutGroup(item, options);
3658
3680
  }
3659
- setGap(gap) {
3660
- this.component.updateOptions({ gap });
3661
- }
3662
3681
  updateOptions(options) {
3663
3682
  this.component.updateOptions(options);
3664
3683
  }
@@ -3711,14 +3730,16 @@
3711
3730
  * For example: in react-dnd if dataTransfer.types is not set then the dragStart event will be cancelled
3712
3731
  * through .preventDefault(). Since this is applied globally to all drag events this would break dockviews
3713
3732
  * dnd logic. You can see the code at
3714
- * https://github.com/react-dnd/react-dnd/blob/main/packages/backend-html5/src/HTML5BackendImpl.ts#L542
3733
+ P * https://github.com/react-dnd/react-dnd/blob/main/packages/backend-html5/src/HTML5BackendImpl.ts#L542
3715
3734
  */
3716
3735
  event.dataTransfer.setData('text/plain', '');
3717
3736
  }
3718
3737
  }
3719
3738
  }), addDisposableListener(this.el, 'dragend', () => {
3720
3739
  this.pointerEventsDisposable.dispose();
3721
- this.dataDisposable.dispose();
3740
+ setTimeout(() => {
3741
+ this.dataDisposable.dispose(); // allow the data to be read by other handlers before disposing
3742
+ }, 0);
3722
3743
  }));
3723
3744
  }
3724
3745
  }
@@ -3828,6 +3849,12 @@
3828
3849
  const SMALL_WIDTH_BOUNDARY = 100;
3829
3850
  const SMALL_HEIGHT_BOUNDARY = 100;
3830
3851
  class Droptarget extends CompositeDisposable {
3852
+ get disabled() {
3853
+ return this._disabled;
3854
+ }
3855
+ set disabled(value) {
3856
+ this._disabled = value;
3857
+ }
3831
3858
  get state() {
3832
3859
  return this._state;
3833
3860
  }
@@ -3839,23 +3866,34 @@
3839
3866
  this.onDrop = this._onDrop.event;
3840
3867
  this._onWillShowOverlay = new Emitter();
3841
3868
  this.onWillShowOverlay = this._onWillShowOverlay.event;
3869
+ this._disabled = false;
3842
3870
  // use a set to take advantage of #<set>.has
3843
3871
  this._acceptedTargetZonesSet = new Set(this.options.acceptedTargetZones);
3844
3872
  this.dnd = new DragAndDropObserver(this.element, {
3845
- onDragEnter: () => undefined,
3873
+ onDragEnter: () => {
3874
+ var _a, _b, _c;
3875
+ (_c = (_b = (_a = this.options).getOverrideTarget) === null || _b === void 0 ? void 0 : _b.call(_a)) === null || _c === void 0 ? void 0 : _c.getElements();
3876
+ },
3846
3877
  onDragOver: (e) => {
3878
+ var _a, _b, _c, _d, _e, _f, _g;
3879
+ Droptarget.ACTUAL_TARGET = this;
3880
+ const overrideTraget = (_b = (_a = this.options).getOverrideTarget) === null || _b === void 0 ? void 0 : _b.call(_a);
3847
3881
  if (this._acceptedTargetZonesSet.size === 0) {
3882
+ if (overrideTraget) {
3883
+ return;
3884
+ }
3848
3885
  this.removeDropTarget();
3849
3886
  return;
3850
3887
  }
3851
- const width = this.element.clientWidth;
3852
- const height = this.element.clientHeight;
3888
+ const target = (_e = (_d = (_c = this.options).getOverlayOutline) === null || _d === void 0 ? void 0 : _d.call(_c)) !== null && _e !== void 0 ? _e : this.element;
3889
+ const width = target.offsetWidth;
3890
+ const height = target.offsetHeight;
3853
3891
  if (width === 0 || height === 0) {
3854
3892
  return; // avoid div!0
3855
3893
  }
3856
3894
  const rect = e.currentTarget.getBoundingClientRect();
3857
- const x = e.clientX - rect.left;
3858
- const y = e.clientY - rect.top;
3895
+ const x = ((_f = e.clientX) !== null && _f !== void 0 ? _f : 0) - rect.left;
3896
+ const y = ((_g = e.clientY) !== null && _g !== void 0 ? _g : 0) - rect.top;
3859
3897
  const quadrant = this.calculateQuadrant(this._acceptedTargetZonesSet, x, y, width, height);
3860
3898
  /**
3861
3899
  * If the event has already been used by another DropTarget instance
@@ -3868,6 +3906,9 @@
3868
3906
  return;
3869
3907
  }
3870
3908
  if (!this.options.canDisplayOverlay(e, quadrant)) {
3909
+ if (overrideTraget) {
3910
+ return;
3911
+ }
3871
3912
  this.removeDropTarget();
3872
3913
  return;
3873
3914
  }
@@ -3885,29 +3926,57 @@
3885
3926
  return;
3886
3927
  }
3887
3928
  this.markAsUsed(e);
3888
- if (!this.targetElement) {
3929
+ if (overrideTraget) ;
3930
+ else if (!this.targetElement) {
3889
3931
  this.targetElement = document.createElement('div');
3890
3932
  this.targetElement.className = 'dv-drop-target-dropzone';
3891
3933
  this.overlayElement = document.createElement('div');
3892
3934
  this.overlayElement.className = 'dv-drop-target-selection';
3893
3935
  this._state = 'center';
3894
3936
  this.targetElement.appendChild(this.overlayElement);
3895
- this.element.classList.add('dv-drop-target');
3896
- this.element.append(this.targetElement);
3937
+ target.classList.add('dv-drop-target');
3938
+ target.append(this.targetElement);
3939
+ // this.overlayElement.style.opacity = '0';
3940
+ // requestAnimationFrame(() => {
3941
+ // if (this.overlayElement) {
3942
+ // this.overlayElement.style.opacity = '';
3943
+ // }
3944
+ // });
3897
3945
  }
3898
3946
  this.toggleClasses(quadrant, width, height);
3899
3947
  this._state = quadrant;
3900
3948
  },
3901
3949
  onDragLeave: () => {
3950
+ var _a, _b;
3951
+ const target = (_b = (_a = this.options).getOverrideTarget) === null || _b === void 0 ? void 0 : _b.call(_a);
3952
+ if (target) {
3953
+ return;
3954
+ }
3902
3955
  this.removeDropTarget();
3903
3956
  },
3904
- onDragEnd: () => {
3957
+ onDragEnd: (e) => {
3958
+ var _a, _b;
3959
+ const target = (_b = (_a = this.options).getOverrideTarget) === null || _b === void 0 ? void 0 : _b.call(_a);
3960
+ if (target && Droptarget.ACTUAL_TARGET === this) {
3961
+ if (this._state) {
3962
+ // only stop the propagation of the event if we are dealing with it
3963
+ // which is only when the target has state
3964
+ e.stopPropagation();
3965
+ this._onDrop.fire({
3966
+ position: this._state,
3967
+ nativeEvent: e,
3968
+ });
3969
+ }
3970
+ }
3905
3971
  this.removeDropTarget();
3972
+ target === null || target === void 0 ? void 0 : target.clear();
3906
3973
  },
3907
3974
  onDrop: (e) => {
3975
+ var _a, _b, _c;
3908
3976
  e.preventDefault();
3909
3977
  const state = this._state;
3910
3978
  this.removeDropTarget();
3979
+ (_c = (_b = (_a = this.options).getOverrideTarget) === null || _b === void 0 ? void 0 : _b.call(_a)) === null || _c === void 0 ? void 0 : _c.clear();
3911
3980
  if (state) {
3912
3981
  // only stop the propagation of the event if we are dealing with it
3913
3982
  // which is only when the target has state
@@ -3942,8 +4011,9 @@
3942
4011
  return typeof value === 'boolean' && value;
3943
4012
  }
3944
4013
  toggleClasses(quadrant, width, height) {
3945
- var _a, _b;
3946
- if (!this.overlayElement) {
4014
+ var _a, _b, _c, _d, _e, _f, _g;
4015
+ const target = (_b = (_a = this.options).getOverrideTarget) === null || _b === void 0 ? void 0 : _b.call(_a);
4016
+ if (!target && !this.overlayElement) {
3947
4017
  return;
3948
4018
  }
3949
4019
  const isSmallX = width < SMALL_WIDTH_BOUNDARY;
@@ -3957,7 +4027,7 @@
3957
4027
  const topClass = !isSmallY && isTop;
3958
4028
  const bottomClass = !isSmallY && isBottom;
3959
4029
  let size = 1;
3960
- const sizeOptions = (_b = (_a = this.options.overlayModel) === null || _a === void 0 ? void 0 : _a.size) !== null && _b !== void 0 ? _b : DEFAULT_SIZE;
4030
+ const sizeOptions = (_d = (_c = this.options.overlayModel) === null || _c === void 0 ? void 0 : _c.size) !== null && _d !== void 0 ? _d : DEFAULT_SIZE;
3961
4031
  if (sizeOptions.type === 'percentage') {
3962
4032
  size = clamp(sizeOptions.value, 0, 100) / 100;
3963
4033
  }
@@ -3969,6 +4039,74 @@
3969
4039
  size = clamp(0, sizeOptions.value, height) / height;
3970
4040
  }
3971
4041
  }
4042
+ if (target) {
4043
+ const outlineEl = (_g = (_f = (_e = this.options).getOverlayOutline) === null || _f === void 0 ? void 0 : _f.call(_e)) !== null && _g !== void 0 ? _g : this.element;
4044
+ const elBox = outlineEl.getBoundingClientRect();
4045
+ const ta = target.getElements(undefined, outlineEl);
4046
+ const el = ta.root;
4047
+ const overlay = ta.overlay;
4048
+ const bigbox = el.getBoundingClientRect();
4049
+ const rootTop = elBox.top - bigbox.top;
4050
+ const rootLeft = elBox.left - bigbox.left;
4051
+ const box = {
4052
+ top: rootTop,
4053
+ left: rootLeft,
4054
+ width: width,
4055
+ height: height,
4056
+ };
4057
+ if (rightClass) {
4058
+ box.left = rootLeft + width * (1 - size);
4059
+ box.width = width * size;
4060
+ }
4061
+ else if (leftClass) {
4062
+ box.width = width * size;
4063
+ }
4064
+ else if (topClass) {
4065
+ box.height = height * size;
4066
+ }
4067
+ else if (bottomClass) {
4068
+ box.top = rootTop + height * (1 - size);
4069
+ box.height = height * size;
4070
+ }
4071
+ if (isSmallX && isLeft) {
4072
+ box.width = 4;
4073
+ }
4074
+ if (isSmallX && isRight) {
4075
+ box.left = rootLeft + width - 4;
4076
+ box.width = 4;
4077
+ }
4078
+ const topPx = `${Math.round(box.top)}px`;
4079
+ const leftPx = `${Math.round(box.left)}px`;
4080
+ const widthPx = `${Math.round(box.width)}px`;
4081
+ const heightPx = `${Math.round(box.height)}px`;
4082
+ if (overlay.style.top === topPx &&
4083
+ overlay.style.left === leftPx &&
4084
+ overlay.style.width === widthPx &&
4085
+ overlay.style.height === heightPx) {
4086
+ return;
4087
+ }
4088
+ overlay.style.top = topPx;
4089
+ overlay.style.left = leftPx;
4090
+ overlay.style.width = widthPx;
4091
+ overlay.style.height = heightPx;
4092
+ overlay.style.visibility = 'visible';
4093
+ overlay.className = `dv-drop-target-anchor${this.options.className ? ` ${this.options.className}` : ''}`;
4094
+ toggleClass(overlay, 'dv-drop-target-left', isLeft);
4095
+ toggleClass(overlay, 'dv-drop-target-right', isRight);
4096
+ toggleClass(overlay, 'dv-drop-target-top', isTop);
4097
+ toggleClass(overlay, 'dv-drop-target-bottom', isBottom);
4098
+ toggleClass(overlay, 'dv-drop-target-center', quadrant === 'center');
4099
+ if (ta.changed) {
4100
+ toggleClass(overlay, 'dv-drop-target-anchor-container-changed', true);
4101
+ setTimeout(() => {
4102
+ toggleClass(overlay, 'dv-drop-target-anchor-container-changed', false);
4103
+ }, 10);
4104
+ }
4105
+ return;
4106
+ }
4107
+ if (!this.overlayElement) {
4108
+ return;
4109
+ }
3972
4110
  const box = { top: '0px', left: '0px', width: '100%', height: '100%' };
3973
4111
  /**
3974
4112
  * You can also achieve the overlay placement using the transform CSS property
@@ -4025,12 +4163,13 @@
4025
4163
  return calculateQuadrantAsPixels(overlayType, x, y, width, height, activationSizeOptions.value);
4026
4164
  }
4027
4165
  removeDropTarget() {
4166
+ var _a;
4028
4167
  if (this.targetElement) {
4029
4168
  this._state = undefined;
4030
- this.element.removeChild(this.targetElement);
4169
+ (_a = this.targetElement.parentElement) === null || _a === void 0 ? void 0 : _a.classList.remove('dv-drop-target');
4170
+ this.targetElement.remove();
4031
4171
  this.targetElement = undefined;
4032
4172
  this.overlayElement = undefined;
4033
- this.element.classList.remove('dv-drop-target');
4034
4173
  }
4035
4174
  }
4036
4175
  }
@@ -4615,7 +4754,15 @@
4615
4754
  this._element.className = 'dv-content-container';
4616
4755
  this._element.tabIndex = -1;
4617
4756
  this.addDisposables(this._onDidFocus, this._onDidBlur);
4757
+ const target = group.dropTargetContainer;
4618
4758
  this.dropTarget = new Droptarget(this.element, {
4759
+ getOverlayOutline: () => {
4760
+ var _a;
4761
+ return ((_a = accessor.options.theme) === null || _a === void 0 ? void 0 : _a.dndPanelOverlay) === 'group'
4762
+ ? this.element.parentElement
4763
+ : null;
4764
+ },
4765
+ className: 'dv-drop-target-content',
4619
4766
  acceptedTargetZones: ['top', 'bottom', 'left', 'right', 'center'],
4620
4767
  canDisplayOverlay: (event, position) => {
4621
4768
  if (this.group.locked === 'no-drop-target' ||
@@ -4629,22 +4776,11 @@
4629
4776
  return false;
4630
4777
  }
4631
4778
  if (data && data.viewId === this.accessor.id) {
4632
- if (data.groupId === this.group.id) {
4633
- if (position === 'center') {
4634
- // don't allow to drop on self for center position
4635
- return false;
4636
- }
4637
- if (data.panelId === null) {
4638
- // don't allow group move to drop anywhere on self
4639
- return false;
4640
- }
4641
- }
4642
- const groupHasOnePanelAndIsActiveDragElement = this.group.panels.length === 1 &&
4643
- data.groupId === this.group.id;
4644
- return !groupHasOnePanelAndIsActiveDragElement;
4779
+ return true;
4645
4780
  }
4646
4781
  return this.group.canDisplayOverlay(event, position, 'content');
4647
4782
  },
4783
+ getOverrideTarget: target ? () => target.model : undefined,
4648
4784
  });
4649
4785
  this.addDisposables(this.dropTarget);
4650
4786
  }
@@ -4719,6 +4855,18 @@
4719
4855
  }
4720
4856
  }
4721
4857
 
4858
+ function addGhostImage(dataTransfer, ghostElement, options) {
4859
+ var _a, _b;
4860
+ // class dockview provides to force ghost image to be drawn on a different layer and prevent weird rendering issues
4861
+ addClasses(ghostElement, 'dv-dragged');
4862
+ document.body.appendChild(ghostElement);
4863
+ dataTransfer.setDragImage(ghostElement, (_a = options === null || options === void 0 ? void 0 : options.x) !== null && _a !== void 0 ? _a : 0, (_b = options === null || options === void 0 ? void 0 : options.y) !== null && _b !== void 0 ? _b : 0);
4864
+ setTimeout(() => {
4865
+ removeClasses(ghostElement, 'dv-dragged');
4866
+ ghostElement.remove();
4867
+ }, 0);
4868
+ }
4869
+
4722
4870
  class TabDragHandler extends DragHandler {
4723
4871
  constructor(element, accessor, group, panel) {
4724
4872
  super(element);
@@ -4759,25 +4907,32 @@
4759
4907
  toggleClass(this.element, 'dv-inactive-tab', true);
4760
4908
  const dragHandler = new TabDragHandler(this._element, this.accessor, this.group, this.panel);
4761
4909
  this.dropTarget = new Droptarget(this._element, {
4762
- acceptedTargetZones: ['center'],
4910
+ acceptedTargetZones: ['left', 'right'],
4911
+ overlayModel: { activationSize: { value: 50, type: 'percentage' } },
4763
4912
  canDisplayOverlay: (event, position) => {
4764
4913
  if (this.group.locked) {
4765
4914
  return false;
4766
4915
  }
4767
4916
  const data = getPanelData();
4768
4917
  if (data && this.accessor.id === data.viewId) {
4769
- if (data.panelId === null &&
4770
- data.groupId === this.group.id) {
4771
- // don't allow group move to drop on self
4772
- return false;
4773
- }
4774
- return this.panel.id !== data.panelId;
4918
+ return true;
4775
4919
  }
4776
4920
  return this.group.model.canDisplayOverlay(event, position, 'tab');
4777
4921
  },
4922
+ getOverrideTarget: () => { var _a; return (_a = group.model.dropTargetContainer) === null || _a === void 0 ? void 0 : _a.model; },
4778
4923
  });
4779
4924
  this.onWillShowOverlay = this.dropTarget.onWillShowOverlay;
4780
4925
  this.addDisposables(this._onPointDown, this._onDropped, this._onDragStart, dragHandler.onDragStart((event) => {
4926
+ if (event.dataTransfer) {
4927
+ const style = getComputedStyle(this.element);
4928
+ const newNode = this.element.cloneNode(true);
4929
+ Array.from(style).forEach((key) => newNode.style.setProperty(key, style.getPropertyValue(key), style.getPropertyPriority(key)));
4930
+ newNode.style.position = 'absolute';
4931
+ addGhostImage(event.dataTransfer, newNode, {
4932
+ y: -10,
4933
+ x: 30,
4934
+ });
4935
+ }
4781
4936
  this._onDragStart.fire(event);
4782
4937
  }), dragHandler, addDisposableListener(this._element, 'pointerdown', (event) => {
4783
4938
  this._onPointDown.fire(event);
@@ -4801,17 +4956,6 @@
4801
4956
  }
4802
4957
  }
4803
4958
 
4804
- function addGhostImage(dataTransfer, ghostElement) {
4805
- // class dockview provides to force ghost image to be drawn on a different layer and prevent weird rendering issues
4806
- addClasses(ghostElement, 'dv-dragged');
4807
- document.body.appendChild(ghostElement);
4808
- dataTransfer.setDragImage(ghostElement, 0, 0);
4809
- setTimeout(() => {
4810
- removeClasses(ghostElement, 'dv-dragged');
4811
- ghostElement.remove();
4812
- }, 0);
4813
- }
4814
-
4815
4959
  class GroupDragHandler extends DragHandler {
4816
4960
  constructor(element, accessor, group) {
4817
4961
  super(element);
@@ -4851,8 +4995,10 @@
4851
4995
  ghostElement.style.lineHeight = '20px';
4852
4996
  ghostElement.style.borderRadius = '12px';
4853
4997
  ghostElement.style.position = 'absolute';
4998
+ ghostElement.style.pointerEvents = 'none';
4999
+ ghostElement.style.top = '-9999px';
4854
5000
  ghostElement.textContent = `Multiple Panels (${this.group.size})`;
4855
- addGhostImage(dataTransfer, ghostElement);
5001
+ addGhostImage(dataTransfer, ghostElement, { y: -10, x: 30 });
4856
5002
  }
4857
5003
  return {
4858
5004
  dispose: () => {
@@ -4884,19 +5030,13 @@
4884
5030
  this.dropTraget = new Droptarget(this._element, {
4885
5031
  acceptedTargetZones: ['center'],
4886
5032
  canDisplayOverlay: (event, position) => {
4887
- var _a;
4888
5033
  const data = getPanelData();
4889
5034
  if (data && this.accessor.id === data.viewId) {
4890
- if (data.panelId === null &&
4891
- data.groupId === this.group.id) {
4892
- // don't allow group move to drop on self
4893
- return false;
4894
- }
4895
- // don't show the overlay if the tab being dragged is the last panel of this group
4896
- return ((_a = last(this.group.panels)) === null || _a === void 0 ? void 0 : _a.id) !== data.panelId;
5035
+ return true;
4897
5036
  }
4898
5037
  return group.model.canDisplayOverlay(event, position, 'header_space');
4899
5038
  },
5039
+ getOverrideTarget: () => { var _a; return (_a = group.model.dropTargetContainer) === null || _a === void 0 ? void 0 : _a.model; },
4900
5040
  });
4901
5041
  this.onWillShowOverlay = this.dropTraget.onWillShowOverlay;
4902
5042
  this.addDisposables(handler, handler.onDragStart((event) => {
@@ -4907,88 +5047,338 @@
4907
5047
  }
4908
5048
  }
4909
5049
 
4910
- class TabsContainer extends CompositeDisposable {
4911
- get panels() {
4912
- return this.tabs.map((_) => _.value.panel.id);
4913
- }
4914
- get size() {
4915
- return this.tabs.length;
4916
- }
4917
- get hidden() {
4918
- return this._hidden;
5050
+ class Scrollbar extends CompositeDisposable {
5051
+ get element() {
5052
+ return this._element;
4919
5053
  }
4920
- set hidden(value) {
4921
- this._hidden = value;
4922
- this.element.style.display = value ? 'none' : '';
5054
+ constructor(scrollableElement) {
5055
+ super();
5056
+ this.scrollableElement = scrollableElement;
5057
+ this._scrollLeft = 0;
5058
+ this._element = document.createElement('div');
5059
+ this._element.className = 'dv-scrollable';
5060
+ this._horizontalScrollbar = document.createElement('div');
5061
+ this._horizontalScrollbar.className = 'dv-scrollbar-horizontal';
5062
+ this.element.appendChild(scrollableElement);
5063
+ this.element.appendChild(this._horizontalScrollbar);
5064
+ this.addDisposables(addDisposableListener(this.element, 'wheel', (event) => {
5065
+ this._scrollLeft += event.deltaY * Scrollbar.MouseWheelSpeed;
5066
+ this.calculateScrollbarStyles();
5067
+ }), addDisposableListener(this._horizontalScrollbar, 'pointerdown', (event) => {
5068
+ event.preventDefault();
5069
+ toggleClass(this.element, 'dv-scrollable-scrolling', true);
5070
+ const originalClientX = event.clientX;
5071
+ const originalScrollLeft = this._scrollLeft;
5072
+ const onPointerMove = (event) => {
5073
+ const deltaX = event.clientX - originalClientX;
5074
+ const { clientWidth } = this.element;
5075
+ const { scrollWidth } = this.scrollableElement;
5076
+ const p = clientWidth / scrollWidth;
5077
+ this._scrollLeft = originalScrollLeft + deltaX / p;
5078
+ this.calculateScrollbarStyles();
5079
+ };
5080
+ const onEnd = () => {
5081
+ toggleClass(this.element, 'dv-scrollable-scrolling', false);
5082
+ document.removeEventListener('pointermove', onPointerMove);
5083
+ document.removeEventListener('pointerup', onEnd);
5084
+ document.removeEventListener('pointercancel', onEnd);
5085
+ };
5086
+ document.addEventListener('pointermove', onPointerMove);
5087
+ document.addEventListener('pointerup', onEnd);
5088
+ document.addEventListener('pointercancel', onEnd);
5089
+ }), addDisposableListener(this.element, 'scroll', () => {
5090
+ this.calculateScrollbarStyles();
5091
+ }), addDisposableListener(this.scrollableElement, 'scroll', () => {
5092
+ this._scrollLeft = this.scrollableElement.scrollLeft;
5093
+ this.calculateScrollbarStyles();
5094
+ }), watchElementResize(this.element, () => {
5095
+ toggleClass(this.element, 'dv-scrollable-resizing', true);
5096
+ if (this._animationTimer) {
5097
+ clearTimeout(this._animationTimer);
5098
+ }
5099
+ this._animationTimer = setTimeout(() => {
5100
+ clearTimeout(this._animationTimer);
5101
+ toggleClass(this.element, 'dv-scrollable-resizing', false);
5102
+ }, 500);
5103
+ this.calculateScrollbarStyles();
5104
+ }));
4923
5105
  }
4924
- show() {
4925
- if (!this.hidden) {
4926
- this.element.style.display = '';
5106
+ calculateScrollbarStyles() {
5107
+ const { clientWidth } = this.element;
5108
+ const { scrollWidth } = this.scrollableElement;
5109
+ const hasScrollbar = scrollWidth > clientWidth;
5110
+ if (hasScrollbar) {
5111
+ const px = clientWidth * (clientWidth / scrollWidth);
5112
+ this._horizontalScrollbar.style.width = `${px}px`;
5113
+ this._scrollLeft = clamp(this._scrollLeft, 0, this.scrollableElement.scrollWidth - clientWidth);
5114
+ this.scrollableElement.scrollLeft = this._scrollLeft;
5115
+ const percentageComplete = this._scrollLeft / (scrollWidth - clientWidth);
5116
+ this._horizontalScrollbar.style.left = `${(clientWidth - px) * percentageComplete}px`;
5117
+ }
5118
+ else {
5119
+ this._horizontalScrollbar.style.width = `0px`;
5120
+ this._horizontalScrollbar.style.left = `0px`;
5121
+ this._scrollLeft = 0;
4927
5122
  }
4928
5123
  }
4929
- hide() {
4930
- this._element.style.display = 'none';
5124
+ }
5125
+ Scrollbar.MouseWheelSpeed = 1;
5126
+
5127
+ class Tabs extends CompositeDisposable {
5128
+ get showTabsOverflowControl() {
5129
+ return this._showTabsOverflowControl;
4931
5130
  }
4932
- setRightActionsElement(element) {
4933
- if (this.rightActions === element) {
5131
+ set showTabsOverflowControl(value) {
5132
+ if (this._showTabsOverflowControl == value) {
4934
5133
  return;
4935
5134
  }
4936
- if (this.rightActions) {
4937
- this.rightActions.remove();
4938
- this.rightActions = undefined;
4939
- }
4940
- if (element) {
4941
- this.rightActionsContainer.appendChild(element);
4942
- this.rightActions = element;
5135
+ this._showTabsOverflowControl = value;
5136
+ if (value) {
5137
+ const observer = new OverflowObserver(this._tabsList);
5138
+ this._observerDisposable.value = new CompositeDisposable(observer, observer.onDidChange((event) => {
5139
+ const hasOverflow = event.hasScrollX || event.hasScrollY;
5140
+ this.toggleDropdown({ reset: !hasOverflow });
5141
+ }), addDisposableListener(this._tabsList, 'scroll', () => {
5142
+ this.toggleDropdown({ reset: false });
5143
+ }));
4943
5144
  }
4944
5145
  }
4945
- setLeftActionsElement(element) {
4946
- if (this.leftActions === element) {
4947
- return;
4948
- }
4949
- if (this.leftActions) {
4950
- this.leftActions.remove();
4951
- this.leftActions = undefined;
4952
- }
4953
- if (element) {
4954
- this.leftActionsContainer.appendChild(element);
4955
- this.leftActions = element;
5146
+ get element() {
5147
+ return this._element;
5148
+ }
5149
+ get panels() {
5150
+ return this._tabs.map((_) => _.value.panel.id);
5151
+ }
5152
+ get size() {
5153
+ return this._tabs.length;
5154
+ }
5155
+ get tabs() {
5156
+ return this._tabs.map((_) => _.value);
5157
+ }
5158
+ constructor(group, accessor, options) {
5159
+ super();
5160
+ this.group = group;
5161
+ this.accessor = accessor;
5162
+ this._observerDisposable = new MutableDisposable();
5163
+ this._tabs = [];
5164
+ this.selectedIndex = -1;
5165
+ this._showTabsOverflowControl = false;
5166
+ this._onTabDragStart = new Emitter();
5167
+ this.onTabDragStart = this._onTabDragStart.event;
5168
+ this._onDrop = new Emitter();
5169
+ this.onDrop = this._onDrop.event;
5170
+ this._onWillShowOverlay = new Emitter();
5171
+ this.onWillShowOverlay = this._onWillShowOverlay.event;
5172
+ this._onOverflowTabsChange = new Emitter();
5173
+ this.onOverflowTabsChange = this._onOverflowTabsChange.event;
5174
+ this._tabsList = document.createElement('div');
5175
+ this._tabsList.className = 'dv-tabs-container dv-horizontal';
5176
+ this.showTabsOverflowControl = options.showTabsOverflowControl;
5177
+ const scrollbar = new Scrollbar(this._tabsList);
5178
+ this._element = scrollbar.element;
5179
+ this.addDisposables(this._onOverflowTabsChange, this._observerDisposable, scrollbar, this._onWillShowOverlay, this._onDrop, this._onTabDragStart, addDisposableListener(this.element, 'pointerdown', (event) => {
5180
+ if (event.defaultPrevented) {
5181
+ return;
5182
+ }
5183
+ const isLeftClick = event.button === 0;
5184
+ if (isLeftClick) {
5185
+ this.accessor.doSetGroupActive(this.group);
5186
+ }
5187
+ }), exports.DockviewDisposable.from(() => {
5188
+ for (const { value, disposable } of this._tabs) {
5189
+ disposable.dispose();
5190
+ value.dispose();
5191
+ }
5192
+ this._tabs = [];
5193
+ }));
5194
+ }
5195
+ indexOf(id) {
5196
+ return this._tabs.findIndex((tab) => tab.value.panel.id === id);
5197
+ }
5198
+ isActive(tab) {
5199
+ return (this.selectedIndex > -1 &&
5200
+ this._tabs[this.selectedIndex].value === tab);
5201
+ }
5202
+ setActivePanel(panel) {
5203
+ let runningWidth = 0;
5204
+ for (const tab of this._tabs) {
5205
+ const isActivePanel = panel.id === tab.value.panel.id;
5206
+ tab.value.setActive(isActivePanel);
5207
+ if (isActivePanel) {
5208
+ const element = tab.value.element;
5209
+ const parentElement = element.parentElement;
5210
+ if (runningWidth < parentElement.scrollLeft ||
5211
+ runningWidth + element.clientWidth >
5212
+ parentElement.scrollLeft + parentElement.clientWidth) {
5213
+ parentElement.scrollLeft = runningWidth;
5214
+ }
5215
+ }
5216
+ runningWidth += tab.value.element.clientWidth;
4956
5217
  }
4957
5218
  }
4958
- setPrefixActionsElement(element) {
4959
- if (this.preActions === element) {
5219
+ openPanel(panel, index = this._tabs.length) {
5220
+ if (this._tabs.find((tab) => tab.value.panel.id === panel.id)) {
4960
5221
  return;
4961
5222
  }
4962
- if (this.preActions) {
4963
- this.preActions.remove();
4964
- this.preActions = undefined;
5223
+ const tab = new Tab(panel, this.accessor, this.group);
5224
+ tab.setContent(panel.view.tab);
5225
+ const disposable = new CompositeDisposable(tab.onDragStart((event) => {
5226
+ this._onTabDragStart.fire({ nativeEvent: event, panel });
5227
+ }), tab.onPointerDown((event) => {
5228
+ if (event.defaultPrevented) {
5229
+ return;
5230
+ }
5231
+ const isFloatingGroupsEnabled = !this.accessor.options.disableFloatingGroups;
5232
+ const isFloatingWithOnePanel = this.group.api.location.type === 'floating' &&
5233
+ this.size === 1;
5234
+ if (isFloatingGroupsEnabled &&
5235
+ !isFloatingWithOnePanel &&
5236
+ event.shiftKey) {
5237
+ event.preventDefault();
5238
+ const panel = this.accessor.getGroupPanel(tab.panel.id);
5239
+ const { top, left } = tab.element.getBoundingClientRect();
5240
+ const { top: rootTop, left: rootLeft } = this.accessor.element.getBoundingClientRect();
5241
+ this.accessor.addFloatingGroup(panel, {
5242
+ x: left - rootLeft,
5243
+ y: top - rootTop,
5244
+ inDragMode: true,
5245
+ });
5246
+ return;
5247
+ }
5248
+ switch (event.button) {
5249
+ case 0: // left click or touch
5250
+ if (this.group.activePanel !== panel) {
5251
+ this.group.model.openPanel(panel);
5252
+ }
5253
+ break;
5254
+ }
5255
+ }), tab.onDrop((event) => {
5256
+ this._onDrop.fire({
5257
+ event: event.nativeEvent,
5258
+ index: this._tabs.findIndex((x) => x.value === tab),
5259
+ });
5260
+ }), tab.onWillShowOverlay((event) => {
5261
+ this._onWillShowOverlay.fire(new WillShowOverlayLocationEvent(event, {
5262
+ kind: 'tab',
5263
+ panel: this.group.activePanel,
5264
+ api: this.accessor.api,
5265
+ group: this.group,
5266
+ getData: getPanelData,
5267
+ }));
5268
+ }));
5269
+ const value = { value: tab, disposable };
5270
+ this.addTab(value, index);
5271
+ }
5272
+ delete(id) {
5273
+ const index = this.indexOf(id);
5274
+ const tabToRemove = this._tabs.splice(index, 1)[0];
5275
+ const { value, disposable } = tabToRemove;
5276
+ disposable.dispose();
5277
+ value.dispose();
5278
+ value.element.remove();
5279
+ }
5280
+ addTab(tab, index = this._tabs.length) {
5281
+ if (index < 0 || index > this._tabs.length) {
5282
+ throw new Error('invalid location');
4965
5283
  }
4966
- if (element) {
4967
- this.preActionsContainer.appendChild(element);
4968
- this.preActions = element;
5284
+ this._tabsList.insertBefore(tab.value.element, this._tabsList.children[index]);
5285
+ this._tabs = [
5286
+ ...this._tabs.slice(0, index),
5287
+ tab,
5288
+ ...this._tabs.slice(index),
5289
+ ];
5290
+ if (this.selectedIndex < 0) {
5291
+ this.selectedIndex = index;
4969
5292
  }
4970
5293
  }
4971
- get element() {
4972
- return this._element;
5294
+ toggleDropdown(options) {
5295
+ const tabs = options.reset
5296
+ ? []
5297
+ : this._tabs
5298
+ .filter((tab) => !isChildEntirelyVisibleWithinParent(tab.value.element, this._tabsList))
5299
+ .map((x) => x.value.panel.id);
5300
+ this._onOverflowTabsChange.fire({ tabs, reset: options.reset });
4973
5301
  }
4974
- isActive(tab) {
4975
- return (this.selectedIndex > -1 &&
4976
- this.tabs[this.selectedIndex].value === tab);
5302
+ }
5303
+
5304
+ const createSvgElementFromPath = (params) => {
5305
+ const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
5306
+ svg.setAttributeNS(null, 'height', params.height);
5307
+ svg.setAttributeNS(null, 'width', params.width);
5308
+ svg.setAttributeNS(null, 'viewBox', params.viewbox);
5309
+ svg.setAttributeNS(null, 'aria-hidden', 'false');
5310
+ svg.setAttributeNS(null, 'focusable', 'false');
5311
+ svg.classList.add('dv-svg');
5312
+ const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
5313
+ path.setAttributeNS(null, 'd', params.path);
5314
+ svg.appendChild(path);
5315
+ return svg;
5316
+ };
5317
+ const createCloseButton = () => createSvgElementFromPath({
5318
+ width: '11',
5319
+ height: '11',
5320
+ viewbox: '0 0 28 28',
5321
+ path: 'M2.1 27.3L0 25.2L11.55 13.65L0 2.1L2.1 0L13.65 11.55L25.2 0L27.3 2.1L15.75 13.65L27.3 25.2L25.2 27.3L13.65 15.75L2.1 27.3Z',
5322
+ });
5323
+ const createExpandMoreButton = () => createSvgElementFromPath({
5324
+ width: '11',
5325
+ height: '11',
5326
+ viewbox: '0 0 24 15',
5327
+ path: 'M12 14.15L0 2.15L2.15 0L12 9.9L21.85 0.0499992L24 2.2L12 14.15Z',
5328
+ });
5329
+ const createChevronRightButton = () => createSvgElementFromPath({
5330
+ width: '11',
5331
+ height: '11',
5332
+ viewbox: '0 0 15 25',
5333
+ path: 'M2.15 24.1L0 21.95L9.9 12.05L0 2.15L2.15 0L14.2 12.05L2.15 24.1Z',
5334
+ });
5335
+
5336
+ function createDropdownElementHandle() {
5337
+ const el = document.createElement('div');
5338
+ el.className = 'dv-tabs-overflow-dropdown-default';
5339
+ const text = document.createElement('span');
5340
+ text.textContent = ``;
5341
+ const icon = createChevronRightButton();
5342
+ el.appendChild(icon);
5343
+ el.appendChild(text);
5344
+ return {
5345
+ element: el,
5346
+ update: (params) => {
5347
+ text.textContent = `${params.tabs}`;
5348
+ },
5349
+ };
5350
+ }
5351
+
5352
+ class TabsContainer extends CompositeDisposable {
5353
+ get onTabDragStart() {
5354
+ return this.tabs.onTabDragStart;
4977
5355
  }
4978
- indexOf(id) {
4979
- return this.tabs.findIndex((tab) => tab.value.panel.id === id);
5356
+ get panels() {
5357
+ return this.tabs.panels;
5358
+ }
5359
+ get size() {
5360
+ return this.tabs.size;
5361
+ }
5362
+ get hidden() {
5363
+ return this._hidden;
5364
+ }
5365
+ set hidden(value) {
5366
+ this._hidden = value;
5367
+ this.element.style.display = value ? 'none' : '';
5368
+ }
5369
+ get element() {
5370
+ return this._element;
4980
5371
  }
4981
5372
  constructor(accessor, group) {
4982
5373
  super();
4983
5374
  this.accessor = accessor;
4984
5375
  this.group = group;
4985
- this.tabs = [];
4986
- this.selectedIndex = -1;
4987
5376
  this._hidden = false;
5377
+ this.dropdownPart = null;
5378
+ this._overflowTabs = [];
5379
+ this._dropdownDisposable = new MutableDisposable();
4988
5380
  this._onDrop = new Emitter();
4989
5381
  this.onDrop = this._onDrop.event;
4990
- this._onTabDragStart = new Emitter();
4991
- this.onTabDragStart = this._onTabDragStart.event;
4992
5382
  this._onGroupDragStart = new Emitter();
4993
5383
  this.onGroupDragStart = this._onGroupDragStart.event;
4994
5384
  this._onWillShowOverlay = new Emitter();
@@ -5002,15 +5392,21 @@
5002
5392
  this.leftActionsContainer.className = 'dv-left-actions-container';
5003
5393
  this.preActionsContainer = document.createElement('div');
5004
5394
  this.preActionsContainer.className = 'dv-pre-actions-container';
5005
- this.tabContainer = document.createElement('div');
5006
- this.tabContainer.className = 'dv-tabs-container';
5395
+ this.tabs = new Tabs(group, accessor, {
5396
+ showTabsOverflowControl: !accessor.options.disableTabsOverflowList,
5397
+ });
5007
5398
  this.voidContainer = new VoidContainer(this.accessor, this.group);
5008
5399
  this._element.appendChild(this.preActionsContainer);
5009
- this._element.appendChild(this.tabContainer);
5400
+ this._element.appendChild(this.tabs.element);
5010
5401
  this._element.appendChild(this.leftActionsContainer);
5011
5402
  this._element.appendChild(this.voidContainer.element);
5012
5403
  this._element.appendChild(this.rightActionsContainer);
5013
- this.addDisposables(this._onWillShowOverlay, this._onDrop, this._onTabDragStart, this._onGroupDragStart, this.voidContainer, this.voidContainer.onDragStart((event) => {
5404
+ this.addDisposables(accessor.onDidOptionsChange(() => {
5405
+ this.tabs.showTabsOverflowControl =
5406
+ !accessor.options.disableTabsOverflowList;
5407
+ }), this.tabs.onOverflowTabsChange((event) => {
5408
+ this.toggleDropdown(event);
5409
+ }), this.tabs, this._onWillShowOverlay, this._onDrop, this._onGroupDragStart, this.voidContainer, this.voidContainer.onDragStart((event) => {
5014
5410
  this._onGroupDragStart.fire({
5015
5411
  nativeEvent: event,
5016
5412
  group: this.group,
@@ -5018,7 +5414,7 @@
5018
5414
  }), this.voidContainer.onDrop((event) => {
5019
5415
  this._onDrop.fire({
5020
5416
  event: event.nativeEvent,
5021
- index: this.tabs.length,
5417
+ index: this.tabs.size,
5022
5418
  });
5023
5419
  }), this.voidContainer.onWillShowOverlay((event) => {
5024
5420
  this._onWillShowOverlay.fire(new WillShowOverlayLocationEvent(event, {
@@ -5028,133 +5424,149 @@
5028
5424
  group: this.group,
5029
5425
  getData: getPanelData,
5030
5426
  }));
5031
- }), addDisposableListener(this.voidContainer.element, 'pointerdown', (event) => {
5032
- const isFloatingGroupsEnabled = !this.accessor.options.disableFloatingGroups;
5033
- if (isFloatingGroupsEnabled &&
5034
- event.shiftKey &&
5035
- this.group.api.location.type !== 'floating') {
5036
- event.preventDefault();
5037
- const { top, left } = this.element.getBoundingClientRect();
5038
- const { top: rootTop, left: rootLeft } = this.accessor.element.getBoundingClientRect();
5039
- this.accessor.addFloatingGroup(this.group, {
5040
- x: left - rootLeft + 20,
5041
- y: top - rootTop + 20,
5042
- inDragMode: true,
5043
- });
5044
- }
5045
- }), addDisposableListener(this.tabContainer, 'pointerdown', (event) => {
5046
- if (event.defaultPrevented) {
5047
- return;
5048
- }
5049
- const isLeftClick = event.button === 0;
5050
- if (isLeftClick) {
5051
- this.accessor.doSetGroupActive(this.group);
5052
- }
5053
- }));
5054
- }
5055
- setActive(_isGroupActive) {
5056
- // noop
5057
- }
5058
- delete(id) {
5059
- const index = this.tabs.findIndex((tab) => tab.value.panel.id === id);
5060
- const tabToRemove = this.tabs.splice(index, 1)[0];
5061
- if (!tabToRemove) {
5062
- throw new Error(`dockview: Tab not found`);
5063
- }
5064
- const { value, disposable } = tabToRemove;
5065
- disposable.dispose();
5066
- value.dispose();
5067
- value.element.remove();
5068
- this.updateClassnames();
5069
- }
5070
- setActivePanel(panel) {
5071
- this.tabs.forEach((tab) => {
5072
- const isActivePanel = panel.id === tab.value.panel.id;
5073
- tab.value.setActive(isActivePanel);
5074
- });
5075
- }
5076
- openPanel(panel, index = this.tabs.length) {
5077
- if (this.tabs.find((tab) => tab.value.panel.id === panel.id)) {
5078
- return;
5079
- }
5080
- const tab = new Tab(panel, this.accessor, this.group);
5081
- tab.setContent(panel.view.tab);
5082
- const disposable = new CompositeDisposable(tab.onDragStart((event) => {
5083
- this._onTabDragStart.fire({ nativeEvent: event, panel });
5084
- }), tab.onPointerDown((event) => {
5427
+ }), addDisposableListener(this.voidContainer.element, 'pointerdown', (event) => {
5085
5428
  if (event.defaultPrevented) {
5086
5429
  return;
5087
5430
  }
5088
5431
  const isFloatingGroupsEnabled = !this.accessor.options.disableFloatingGroups;
5089
- const isFloatingWithOnePanel = this.group.api.location.type === 'floating' &&
5090
- this.size === 1;
5091
5432
  if (isFloatingGroupsEnabled &&
5092
- !isFloatingWithOnePanel &&
5093
- event.shiftKey) {
5433
+ event.shiftKey &&
5434
+ this.group.api.location.type !== 'floating') {
5094
5435
  event.preventDefault();
5095
- const panel = this.accessor.getGroupPanel(tab.panel.id);
5096
- const { top, left } = tab.element.getBoundingClientRect();
5436
+ const { top, left } = this.element.getBoundingClientRect();
5097
5437
  const { top: rootTop, left: rootLeft } = this.accessor.element.getBoundingClientRect();
5098
- this.accessor.addFloatingGroup(panel, {
5099
- x: left - rootLeft,
5100
- y: top - rootTop,
5438
+ this.accessor.addFloatingGroup(this.group, {
5439
+ x: left - rootLeft + 20,
5440
+ y: top - rootTop + 20,
5101
5441
  inDragMode: true,
5102
5442
  });
5103
- return;
5104
- }
5105
- switch (event.button) {
5106
- case 0: // left click or touch
5107
- if (this.group.activePanel !== panel) {
5108
- this.group.model.openPanel(panel);
5109
- }
5110
- break;
5111
5443
  }
5112
- }), tab.onDrop((event) => {
5113
- this._onDrop.fire({
5114
- event: event.nativeEvent,
5115
- index: this.tabs.findIndex((x) => x.value === tab),
5116
- });
5117
- }), tab.onWillShowOverlay((event) => {
5118
- this._onWillShowOverlay.fire(new WillShowOverlayLocationEvent(event, {
5119
- kind: 'tab',
5120
- panel: this.group.activePanel,
5121
- api: this.accessor.api,
5122
- group: this.group,
5123
- getData: getPanelData,
5124
- }));
5125
5444
  }));
5126
- const value = { value: tab, disposable };
5127
- this.addTab(value, index);
5128
5445
  }
5129
- closePanel(panel) {
5130
- this.delete(panel.id);
5446
+ show() {
5447
+ if (!this.hidden) {
5448
+ this.element.style.display = '';
5449
+ }
5131
5450
  }
5132
- dispose() {
5133
- super.dispose();
5134
- for (const { value, disposable } of this.tabs) {
5135
- disposable.dispose();
5136
- value.dispose();
5451
+ hide() {
5452
+ this._element.style.display = 'none';
5453
+ }
5454
+ setRightActionsElement(element) {
5455
+ if (this.rightActions === element) {
5456
+ return;
5457
+ }
5458
+ if (this.rightActions) {
5459
+ this.rightActions.remove();
5460
+ this.rightActions = undefined;
5461
+ }
5462
+ if (element) {
5463
+ this.rightActionsContainer.appendChild(element);
5464
+ this.rightActions = element;
5137
5465
  }
5138
- this.tabs = [];
5139
5466
  }
5140
- addTab(tab, index = this.tabs.length) {
5141
- if (index < 0 || index > this.tabs.length) {
5142
- throw new Error('invalid location');
5467
+ setLeftActionsElement(element) {
5468
+ if (this.leftActions === element) {
5469
+ return;
5143
5470
  }
5144
- this.tabContainer.insertBefore(tab.value.element, this.tabContainer.children[index]);
5145
- this.tabs = [
5146
- ...this.tabs.slice(0, index),
5147
- tab,
5148
- ...this.tabs.slice(index),
5149
- ];
5150
- if (this.selectedIndex < 0) {
5151
- this.selectedIndex = index;
5471
+ if (this.leftActions) {
5472
+ this.leftActions.remove();
5473
+ this.leftActions = undefined;
5474
+ }
5475
+ if (element) {
5476
+ this.leftActionsContainer.appendChild(element);
5477
+ this.leftActions = element;
5478
+ }
5479
+ }
5480
+ setPrefixActionsElement(element) {
5481
+ if (this.preActions === element) {
5482
+ return;
5483
+ }
5484
+ if (this.preActions) {
5485
+ this.preActions.remove();
5486
+ this.preActions = undefined;
5487
+ }
5488
+ if (element) {
5489
+ this.preActionsContainer.appendChild(element);
5490
+ this.preActions = element;
5152
5491
  }
5492
+ }
5493
+ isActive(tab) {
5494
+ return this.tabs.isActive(tab);
5495
+ }
5496
+ indexOf(id) {
5497
+ return this.tabs.indexOf(id);
5498
+ }
5499
+ setActive(_isGroupActive) {
5500
+ // noop
5501
+ }
5502
+ delete(id) {
5503
+ this.tabs.delete(id);
5504
+ this.updateClassnames();
5505
+ }
5506
+ setActivePanel(panel) {
5507
+ this.tabs.setActivePanel(panel);
5508
+ }
5509
+ openPanel(panel, index = this.tabs.size) {
5510
+ this.tabs.openPanel(panel, index);
5153
5511
  this.updateClassnames();
5154
5512
  }
5513
+ closePanel(panel) {
5514
+ this.delete(panel.id);
5515
+ }
5155
5516
  updateClassnames() {
5156
5517
  toggleClass(this._element, 'dv-single-tab', this.size === 1);
5157
5518
  }
5519
+ toggleDropdown(options) {
5520
+ const tabs = options.reset ? [] : options.tabs;
5521
+ this._overflowTabs = tabs;
5522
+ if (this._overflowTabs.length > 0 && this.dropdownPart) {
5523
+ this.dropdownPart.update({ tabs: tabs.length });
5524
+ return;
5525
+ }
5526
+ if (this._overflowTabs.length === 0) {
5527
+ this._dropdownDisposable.dispose();
5528
+ return;
5529
+ }
5530
+ const root = document.createElement('div');
5531
+ root.className = 'dv-tabs-overflow-dropdown-root';
5532
+ const part = createDropdownElementHandle();
5533
+ part.update({ tabs: tabs.length });
5534
+ this.dropdownPart = part;
5535
+ root.appendChild(part.element);
5536
+ this.rightActionsContainer.prepend(root);
5537
+ this._dropdownDisposable.value = new CompositeDisposable(exports.DockviewDisposable.from(() => {
5538
+ var _a, _b;
5539
+ root.remove();
5540
+ (_b = (_a = this.dropdownPart) === null || _a === void 0 ? void 0 : _a.dispose) === null || _b === void 0 ? void 0 : _b.call(_a);
5541
+ this.dropdownPart = null;
5542
+ }), addDisposableListener(root, 'pointerdown', (event) => {
5543
+ event.preventDefault();
5544
+ }, { capture: true }), addDisposableListener(root, 'click', (event) => {
5545
+ const el = document.createElement('div');
5546
+ el.style.overflow = 'auto';
5547
+ el.className = 'dv-tabs-overflow-container';
5548
+ for (const tab of this.tabs.tabs.filter((tab) => this._overflowTabs.includes(tab.panel.id))) {
5549
+ const panelObject = this.group.panels.find((panel) => panel === tab.panel);
5550
+ const tabComponent = panelObject.view.createTabRenderer('headerOverflow');
5551
+ const child = tabComponent.element;
5552
+ const wrapper = document.createElement('div');
5553
+ toggleClass(wrapper, 'dv-tab', true);
5554
+ toggleClass(wrapper, 'dv-active-tab', panelObject.api.isActive);
5555
+ toggleClass(wrapper, 'dv-inactive-tab', !panelObject.api.isActive);
5556
+ wrapper.addEventListener('mousedown', () => {
5557
+ this.accessor.popupService.close();
5558
+ tab.element.scrollIntoView();
5559
+ tab.panel.api.setActive();
5560
+ });
5561
+ wrapper.appendChild(child);
5562
+ el.appendChild(wrapper);
5563
+ }
5564
+ this.accessor.popupService.openPopover(el, {
5565
+ x: event.clientX,
5566
+ y: event.clientY,
5567
+ });
5568
+ }));
5569
+ }
5158
5570
  }
5159
5571
 
5160
5572
  class DockviewUnhandledDragOverEvent extends AcceptableEvent {
@@ -5184,9 +5596,11 @@
5184
5596
  rootOverlayModel: undefined,
5185
5597
  locked: undefined,
5186
5598
  disableDnd: undefined,
5187
- gap: undefined,
5188
5599
  className: undefined,
5189
5600
  noPanelsOverlay: undefined,
5601
+ dndEdges: undefined,
5602
+ theme: undefined,
5603
+ disableTabsOverflowList: undefined,
5190
5604
  };
5191
5605
  return Object.keys(properties);
5192
5606
  })();
@@ -5365,6 +5779,7 @@
5365
5779
  this._location = { type: 'grid' };
5366
5780
  this.mostRecentlyUsed = [];
5367
5781
  this._overwriteRenderContainer = null;
5782
+ this._overwriteDropTargetContainer = null;
5368
5783
  this._onDidChange = new Emitter();
5369
5784
  this.onDidChange = this._onDidChange.event;
5370
5785
  this._width = 0;
@@ -5442,6 +5857,13 @@
5442
5857
  var _a;
5443
5858
  return ((_a = this._overwriteRenderContainer) !== null && _a !== void 0 ? _a : this.accessor.overlayRenderContainer);
5444
5859
  }
5860
+ set dropTargetContainer(value) {
5861
+ this._overwriteDropTargetContainer = value;
5862
+ }
5863
+ get dropTargetContainer() {
5864
+ var _a;
5865
+ return ((_a = this._overwriteDropTargetContainer) !== null && _a !== void 0 ? _a : this.accessor.rootDropTargetContainer);
5866
+ }
5445
5867
  initialize() {
5446
5868
  if (this.options.panels) {
5447
5869
  this.options.panels.forEach((panel) => {
@@ -5790,6 +6212,25 @@
5790
6212
  }
5791
6213
  const data = getPanelData();
5792
6214
  if (data && data.viewId === this.accessor.id) {
6215
+ if (type === 'content') {
6216
+ if (data.groupId === this.id) {
6217
+ // don't allow to drop on self for center position
6218
+ if (position === 'center') {
6219
+ return;
6220
+ }
6221
+ if (data.panelId === null) {
6222
+ // don't allow group move to drop anywhere on self
6223
+ return;
6224
+ }
6225
+ }
6226
+ }
6227
+ if (type === 'header') {
6228
+ if (data.groupId === this.id) {
6229
+ if (data.panelId === null) {
6230
+ return;
6231
+ }
6232
+ }
6233
+ }
5793
6234
  if (data.panelId === null) {
5794
6235
  // this is a group move dnd event
5795
6236
  const { groupId } = data;
@@ -6218,6 +6659,46 @@
6218
6659
  }
6219
6660
  }
6220
6661
 
6662
+ const themeDark = {
6663
+ name: 'dark',
6664
+ className: 'dockview-theme-dark',
6665
+ };
6666
+ const themeLight = {
6667
+ name: 'light',
6668
+ className: 'dockview-theme-light',
6669
+ };
6670
+ const themeVisualStudio = {
6671
+ name: 'visualStudio',
6672
+ className: 'dockview-theme-vs',
6673
+ };
6674
+ const themeAbyss = {
6675
+ name: 'abyss',
6676
+ className: 'dockview-theme-abyss',
6677
+ };
6678
+ const themeDracula = {
6679
+ name: 'dracula',
6680
+ className: 'dockview-theme-dracula',
6681
+ };
6682
+ const themeReplit = {
6683
+ name: 'replit',
6684
+ className: 'dockview-theme-replit',
6685
+ gap: 10,
6686
+ };
6687
+ const themeAbyssSpaced = {
6688
+ name: 'abyssSpaced',
6689
+ className: 'dockview-theme-abyss-spaced',
6690
+ gap: 10,
6691
+ dndOverlayMounting: 'absolute',
6692
+ dndPanelOverlay: 'group',
6693
+ };
6694
+ const themeLightSpaced = {
6695
+ name: 'lightSpaced',
6696
+ className: 'dockview-theme-light-spaced',
6697
+ gap: 10,
6698
+ dndOverlayMounting: 'absolute',
6699
+ dndPanelOverlay: 'group',
6700
+ };
6701
+
6221
6702
  class DockviewPanelApiImpl extends GridviewPanelApiImpl {
6222
6703
  get location() {
6223
6704
  return this.group.api.location;
@@ -6492,38 +6973,6 @@
6492
6973
  }
6493
6974
  }
6494
6975
 
6495
- const createSvgElementFromPath = (params) => {
6496
- const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
6497
- svg.setAttributeNS(null, 'height', params.height);
6498
- svg.setAttributeNS(null, 'width', params.width);
6499
- svg.setAttributeNS(null, 'viewBox', params.viewbox);
6500
- svg.setAttributeNS(null, 'aria-hidden', 'false');
6501
- svg.setAttributeNS(null, 'focusable', 'false');
6502
- svg.classList.add('dv-svg');
6503
- const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
6504
- path.setAttributeNS(null, 'd', params.path);
6505
- svg.appendChild(path);
6506
- return svg;
6507
- };
6508
- const createCloseButton = () => createSvgElementFromPath({
6509
- width: '11',
6510
- height: '11',
6511
- viewbox: '0 0 28 28',
6512
- path: 'M2.1 27.3L0 25.2L11.55 13.65L0 2.1L2.1 0L13.65 11.55L25.2 0L27.3 2.1L15.75 13.65L27.3 25.2L25.2 27.3L13.65 15.75L2.1 27.3Z',
6513
- });
6514
- const createExpandMoreButton = () => createSvgElementFromPath({
6515
- width: '11',
6516
- height: '11',
6517
- viewbox: '0 0 24 15',
6518
- path: 'M12 14.15L0 2.15L2.15 0L12 9.9L21.85 0.0499992L24 2.2L12 14.15Z',
6519
- });
6520
- const createChevronRightButton = () => createSvgElementFromPath({
6521
- width: '11',
6522
- height: '11',
6523
- viewbox: '0 0 15 25',
6524
- path: 'M2.15 24.1L0 21.95L9.9 12.05L0 2.15L2.15 0L14.2 12.05L2.15 24.1Z',
6525
- });
6526
-
6527
6976
  class DefaultTab extends CompositeDisposable {
6528
6977
  get element() {
6529
6978
  return this._element;
@@ -6580,12 +7029,21 @@
6580
7029
  this._content = this.createContentComponent(this.id, contentComponent);
6581
7030
  this._tab = this.createTabComponent(this.id, tabComponent);
6582
7031
  }
7032
+ createTabRenderer(tabLocation) {
7033
+ var _a;
7034
+ const cmp = this.createTabComponent(this.id, this.tabComponent);
7035
+ if (this._params) {
7036
+ cmp.init(Object.assign(Object.assign({}, this._params), { tabLocation }));
7037
+ }
7038
+ if (this._updateEvent) {
7039
+ (_a = cmp.update) === null || _a === void 0 ? void 0 : _a.call(cmp, this._updateEvent);
7040
+ }
7041
+ return cmp;
7042
+ }
6583
7043
  init(params) {
7044
+ this._params = params;
6584
7045
  this.content.init(params);
6585
- this.tab.init(params);
6586
- }
6587
- updateParentGroup(_group, _isPanelVisible) {
6588
- // noop
7046
+ this.tab.init(Object.assign(Object.assign({}, params), { tabLocation: 'header' }));
6589
7047
  }
6590
7048
  layout(width, height) {
6591
7049
  var _a, _b;
@@ -6593,6 +7051,7 @@
6593
7051
  }
6594
7052
  update(event) {
6595
7053
  var _a, _b, _c, _d;
7054
+ this._updateEvent = event;
6596
7055
  (_b = (_a = this.content).update) === null || _b === void 0 ? void 0 : _b.call(_a, event);
6597
7056
  (_d = (_c = this.tab).update) === null || _d === void 0 ? void 0 : _d.call(_c, event);
6598
7057
  }
@@ -7453,6 +7912,132 @@
7453
7912
  }
7454
7913
  }
7455
7914
 
7915
+ class PopupService extends CompositeDisposable {
7916
+ constructor(root) {
7917
+ super();
7918
+ this.root = root;
7919
+ this._active = null;
7920
+ this._activeDisposable = new MutableDisposable();
7921
+ this._element = document.createElement('div');
7922
+ this._element.className = 'dv-popover-anchor';
7923
+ this._element.style.position = 'relative';
7924
+ this.root.prepend(this._element);
7925
+ this.addDisposables(exports.DockviewDisposable.from(() => {
7926
+ this.close();
7927
+ }), this._activeDisposable);
7928
+ }
7929
+ openPopover(element, position) {
7930
+ this.close();
7931
+ const wrapper = document.createElement('div');
7932
+ wrapper.style.position = 'absolute';
7933
+ wrapper.style.zIndex = '99';
7934
+ wrapper.appendChild(element);
7935
+ const anchorBox = this._element.getBoundingClientRect();
7936
+ const offsetX = anchorBox.left;
7937
+ const offsetY = anchorBox.top;
7938
+ wrapper.style.top = `${position.y - offsetY}px`;
7939
+ wrapper.style.left = `${position.x - offsetX}px`;
7940
+ this._element.appendChild(wrapper);
7941
+ this._active = wrapper;
7942
+ this._activeDisposable.value = new CompositeDisposable(addDisposableWindowListener(window, 'pointerdown', (event) => {
7943
+ var _a;
7944
+ const target = event.target;
7945
+ if (!(target instanceof HTMLElement)) {
7946
+ return;
7947
+ }
7948
+ let el = target;
7949
+ while (el && el !== wrapper) {
7950
+ el = (_a = el === null || el === void 0 ? void 0 : el.parentElement) !== null && _a !== void 0 ? _a : null;
7951
+ }
7952
+ if (el) {
7953
+ return; // clicked within popover
7954
+ }
7955
+ this.close();
7956
+ }));
7957
+ }
7958
+ close() {
7959
+ if (this._active) {
7960
+ this._active.remove();
7961
+ this._activeDisposable.dispose();
7962
+ this._active = null;
7963
+ }
7964
+ }
7965
+ }
7966
+
7967
+ class DropTargetAnchorContainer extends CompositeDisposable {
7968
+ get disabled() {
7969
+ return this._disabled;
7970
+ }
7971
+ set disabled(value) {
7972
+ var _a;
7973
+ if (this.disabled === value) {
7974
+ return;
7975
+ }
7976
+ this._disabled = value;
7977
+ if (value) {
7978
+ (_a = this.model) === null || _a === void 0 ? void 0 : _a.clear();
7979
+ }
7980
+ }
7981
+ get model() {
7982
+ if (this.disabled) {
7983
+ return undefined;
7984
+ }
7985
+ return {
7986
+ clear: () => {
7987
+ var _a;
7988
+ if (this._model) {
7989
+ (_a = this._model.root.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(this._model.root);
7990
+ }
7991
+ this._model = undefined;
7992
+ },
7993
+ exists: () => {
7994
+ return !!this._model;
7995
+ },
7996
+ getElements: (event, outline) => {
7997
+ const changed = this._outline !== outline;
7998
+ this._outline = outline;
7999
+ if (this._model) {
8000
+ this._model.changed = changed;
8001
+ return this._model;
8002
+ }
8003
+ const container = this.createContainer();
8004
+ const anchor = this.createAnchor();
8005
+ this._model = { root: container, overlay: anchor, changed };
8006
+ container.appendChild(anchor);
8007
+ this.element.appendChild(container);
8008
+ if ((event === null || event === void 0 ? void 0 : event.target) instanceof HTMLElement) {
8009
+ const targetBox = event.target.getBoundingClientRect();
8010
+ const box = this.element.getBoundingClientRect();
8011
+ anchor.style.left = `${targetBox.left - box.left}px`;
8012
+ anchor.style.top = `${targetBox.top - box.top}px`;
8013
+ }
8014
+ return this._model;
8015
+ },
8016
+ };
8017
+ }
8018
+ constructor(element, options) {
8019
+ super();
8020
+ this.element = element;
8021
+ this._disabled = false;
8022
+ this._disabled = options.disabled;
8023
+ this.addDisposables(exports.DockviewDisposable.from(() => {
8024
+ var _a;
8025
+ (_a = this.model) === null || _a === void 0 ? void 0 : _a.clear();
8026
+ }));
8027
+ }
8028
+ createContainer() {
8029
+ const el = document.createElement('div');
8030
+ el.className = 'dv-drop-target-container';
8031
+ return el;
8032
+ }
8033
+ createAnchor() {
8034
+ const el = document.createElement('div');
8035
+ el.className = 'dv-drop-target-anchor';
8036
+ el.style.visibility = 'hidden';
8037
+ return el;
8038
+ }
8039
+ }
8040
+
7456
8041
  const DEFAULT_ROOT_OVERLAY_MODEL = {
7457
8042
  activationSize: { type: 'pixels', value: 10 },
7458
8043
  size: { type: 'pixels', value: 20 },
@@ -7498,14 +8083,11 @@
7498
8083
  get api() {
7499
8084
  return this._api;
7500
8085
  }
7501
- get gap() {
7502
- return this.gridview.margin;
7503
- }
7504
8086
  get floatingGroups() {
7505
8087
  return this._floatingGroups;
7506
8088
  }
7507
8089
  constructor(container, options) {
7508
- var _a;
8090
+ var _a, _b, _c;
7509
8091
  super(container, {
7510
8092
  proportionalLayout: true,
7511
8093
  orientation: exports.Orientation.HORIZONTAL,
@@ -7514,12 +8096,12 @@
7514
8096
  : undefined,
7515
8097
  disableAutoResizing: options.disableAutoResizing,
7516
8098
  locked: options.locked,
7517
- margin: options.gap,
8099
+ margin: (_b = (_a = options.theme) === null || _a === void 0 ? void 0 : _a.gap) !== null && _b !== void 0 ? _b : 0,
7518
8100
  className: options.className,
7519
8101
  });
7520
8102
  this.nextGroupId = sequentialNumberGenerator();
7521
8103
  this._deserializer = new DefaultDockviewDeserialzier(this);
7522
- this.watermark = null;
8104
+ this._watermark = null;
7523
8105
  this._onWillDragPanel = new Emitter();
7524
8106
  this.onWillDragPanel = this._onWillDragPanel.event;
7525
8107
  this._onWillDragGroup = new Emitter();
@@ -7550,16 +8132,22 @@
7550
8132
  this.onDidRemoveGroup = this._onDidRemoveGroup.event;
7551
8133
  this._onDidAddGroup = new Emitter();
7552
8134
  this.onDidAddGroup = this._onDidAddGroup.event;
8135
+ this._onDidOptionsChange = new Emitter();
8136
+ this.onDidOptionsChange = this._onDidOptionsChange.event;
7553
8137
  this._onDidActiveGroupChange = new Emitter();
7554
8138
  this.onDidActiveGroupChange = this._onDidActiveGroupChange.event;
7555
8139
  this._moving = false;
8140
+ this.popupService = new PopupService(this.element);
8141
+ this.updateDropTargetModel(options);
8142
+ this._themeClassnames = new Classnames(this.element);
8143
+ this.rootDropTargetContainer = new DropTargetAnchorContainer(this.element, { disabled: true });
7556
8144
  this.overlayRenderContainer = new OverlayRenderContainer(this.gridview.element, this);
7557
8145
  toggleClass(this.gridview.element, 'dv-dockview', true);
7558
8146
  toggleClass(this.element, 'dv-debug', !!options.debug);
7559
8147
  if (options.debug) {
7560
8148
  this.addDisposables(new StrictEventsSequencing(this));
7561
8149
  }
7562
- this.addDisposables(this.overlayRenderContainer, this._onWillDragPanel, this._onWillDragGroup, this._onWillShowOverlay, this._onDidActivePanelChange, this._onDidAddPanel, this._onDidRemovePanel, this._onDidLayoutFromJSON, this._onDidDrop, this._onWillDrop, this._onDidMovePanel, this._onDidAddGroup, this._onDidRemoveGroup, this._onDidActiveGroupChange, this._onUnhandledDragOverEvent, this._onDidMaximizedGroupChange, this.onDidViewVisibilityChangeMicroTaskQueue(() => {
8150
+ this.addDisposables(this.rootDropTargetContainer, this.overlayRenderContainer, this._onWillDragPanel, this._onWillDragGroup, this._onWillShowOverlay, this._onDidActivePanelChange, this._onDidAddPanel, this._onDidRemovePanel, this._onDidLayoutFromJSON, this._onDidDrop, this._onWillDrop, this._onDidMovePanel, this._onDidAddGroup, this._onDidRemoveGroup, this._onDidActiveGroupChange, this._onUnhandledDragOverEvent, this._onDidMaximizedGroupChange, this._onDidOptionsChange, this.onDidViewVisibilityChangeMicroTaskQueue(() => {
7563
8151
  this.updateWatermark();
7564
8152
  }), this.onDidAdd((event) => {
7565
8153
  if (!this._moving) {
@@ -7593,7 +8181,9 @@
7593
8181
  }
7594
8182
  }));
7595
8183
  this._options = options;
8184
+ this.updateTheme();
7596
8185
  this._rootDropTarget = new Droptarget(this.element, {
8186
+ className: 'dv-drop-target-edge',
7597
8187
  canDisplayOverlay: (event, position) => {
7598
8188
  const data = getPanelData();
7599
8189
  if (data) {
@@ -7620,7 +8210,8 @@
7620
8210
  return firedEvent.isAccepted;
7621
8211
  },
7622
8212
  acceptedTargetZones: ['top', 'bottom', 'left', 'right', 'center'],
7623
- overlayModel: (_a = this.options.rootOverlayModel) !== null && _a !== void 0 ? _a : DEFAULT_ROOT_OVERLAY_MODEL,
8213
+ overlayModel: (_c = this.options.rootOverlayModel) !== null && _c !== void 0 ? _c : DEFAULT_ROOT_OVERLAY_MODEL,
8214
+ getOverrideTarget: () => { var _a; return (_a = this.rootDropTargetContainer) === null || _a === void 0 ? void 0 : _a.model; },
7624
8215
  });
7625
8216
  this.addDisposables(this._rootDropTarget, this._rootDropTarget.onWillShowOverlay((event) => {
7626
8217
  if (this.gridview.length > 0 && event.position === 'center') {
@@ -7798,6 +8389,10 @@
7798
8389
  popoutContainer.style.overflow = 'hidden';
7799
8390
  popoutContainer.appendChild(gready);
7800
8391
  popoutContainer.appendChild(group.element);
8392
+ const anchor = document.createElement('div');
8393
+ const dropTargetContainer = new DropTargetAnchorContainer(anchor, { disabled: this.rootDropTargetContainer.disabled });
8394
+ popoutContainer.appendChild(anchor);
8395
+ group.model.dropTargetContainer = dropTargetContainer;
7801
8396
  group.model.location = {
7802
8397
  type: 'popout',
7803
8398
  getWindow: () => _window.window,
@@ -7864,6 +8459,8 @@
7864
8459
  else if (this.getPanel(group.id)) {
7865
8460
  group.model.renderContainer =
7866
8461
  this.overlayRenderContainer;
8462
+ group.model.dropTargetContainer =
8463
+ this.rootDropTargetContainer;
7867
8464
  returnedGroup = group;
7868
8465
  const alreadyRemoved = !this._popoutGroups.find((p) => p.popoutGroup === group);
7869
8466
  if (alreadyRemoved) {
@@ -8084,7 +8681,7 @@
8084
8681
  }
8085
8682
  }
8086
8683
  updateOptions(options) {
8087
- var _a, _b, _c, _d;
8684
+ var _a, _b;
8088
8685
  super.updateOptions(options);
8089
8686
  if ('floatingGroupBounds' in options) {
8090
8687
  for (const group of this._floatingGroups) {
@@ -8108,13 +8705,11 @@
8108
8705
  group.overlay.setBounds();
8109
8706
  }
8110
8707
  }
8111
- if ('rootOverlayModel' in options) {
8112
- this._rootDropTarget.setOverlayModel((_c = options.rootOverlayModel) !== null && _c !== void 0 ? _c : DEFAULT_ROOT_OVERLAY_MODEL);
8113
- }
8114
- if ('gap' in options) {
8115
- this.gridview.margin = (_d = options.gap) !== null && _d !== void 0 ? _d : 0;
8116
- }
8708
+ this.updateDropTargetModel(options);
8117
8709
  this._options = Object.assign(Object.assign({}, this.options), options);
8710
+ if ('theme' in options) {
8711
+ this.updateTheme();
8712
+ }
8118
8713
  this.layout(this.gridview.width, this.gridview.height, true);
8119
8714
  }
8120
8715
  layout(width, height, forceResize) {
@@ -8532,22 +9127,22 @@
8532
9127
  updateWatermark() {
8533
9128
  var _a, _b;
8534
9129
  if (this.groups.filter((x) => x.api.location.type === 'grid' && x.api.isVisible).length === 0) {
8535
- if (!this.watermark) {
8536
- this.watermark = this.createWatermarkComponent();
8537
- this.watermark.init({
9130
+ if (!this._watermark) {
9131
+ this._watermark = this.createWatermarkComponent();
9132
+ this._watermark.init({
8538
9133
  containerApi: new DockviewApi(this),
8539
9134
  });
8540
9135
  const watermarkContainer = document.createElement('div');
8541
9136
  watermarkContainer.className = 'dv-watermark-container';
8542
9137
  addTestId(watermarkContainer, 'watermark-component');
8543
- watermarkContainer.appendChild(this.watermark.element);
9138
+ watermarkContainer.appendChild(this._watermark.element);
8544
9139
  this.gridview.element.appendChild(watermarkContainer);
8545
9140
  }
8546
9141
  }
8547
- else if (this.watermark) {
8548
- this.watermark.element.parentElement.remove();
8549
- (_b = (_a = this.watermark).dispose) === null || _b === void 0 ? void 0 : _b.call(_a);
8550
- this.watermark = null;
9142
+ else if (this._watermark) {
9143
+ this._watermark.element.parentElement.remove();
9144
+ (_b = (_a = this._watermark).dispose) === null || _b === void 0 ? void 0 : _b.call(_a);
9145
+ this._watermark = null;
8551
9146
  }
8552
9147
  }
8553
9148
  addGroup(options) {
@@ -9033,6 +9628,38 @@
9033
9628
  ? rootOrientation
9034
9629
  : orthogonal(rootOrientation);
9035
9630
  }
9631
+ updateDropTargetModel(options) {
9632
+ if ('dndEdges' in options) {
9633
+ this._rootDropTarget.disabled =
9634
+ typeof options.dndEdges === 'boolean' &&
9635
+ options.dndEdges === false;
9636
+ if (typeof options.dndEdges === 'object' &&
9637
+ options.dndEdges !== null) {
9638
+ this._rootDropTarget.setOverlayModel(options.dndEdges);
9639
+ }
9640
+ else {
9641
+ this._rootDropTarget.setOverlayModel(DEFAULT_ROOT_OVERLAY_MODEL);
9642
+ }
9643
+ }
9644
+ if ('rootOverlayModel' in options) {
9645
+ this.updateDropTargetModel({ dndEdges: options.dndEdges });
9646
+ }
9647
+ }
9648
+ updateTheme() {
9649
+ var _a, _b;
9650
+ const theme = (_a = this._options.theme) !== null && _a !== void 0 ? _a : themeAbyss;
9651
+ this._themeClassnames.setClassNames(theme.className);
9652
+ this.gridview.margin = (_b = theme.gap) !== null && _b !== void 0 ? _b : 0;
9653
+ switch (theme.dndOverlayMounting) {
9654
+ case 'absolute':
9655
+ this.rootDropTargetContainer.disabled = false;
9656
+ break;
9657
+ case 'relative':
9658
+ default:
9659
+ this.rootDropTargetContainer.disabled = true;
9660
+ break;
9661
+ }
9662
+ }
9036
9663
  }
9037
9664
 
9038
9665
  class GridviewComponent extends BaseGrid {
@@ -9556,6 +10183,7 @@
9556
10183
  for (const view of views) {
9557
10184
  view.dispose();
9558
10185
  }
10186
+ this.element.remove();
9559
10187
  super.dispose();
9560
10188
  }
9561
10189
  }
@@ -9896,6 +10524,7 @@
9896
10524
  value.dispose();
9897
10525
  }
9898
10526
  this._viewDisposables.clear();
10527
+ this.element.remove();
9899
10528
  this.paneview.dispose();
9900
10529
  }
9901
10530
  }
@@ -10079,6 +10708,14 @@
10079
10708
  exports.isPanelOptionsWithPanel = isPanelOptionsWithPanel;
10080
10709
  exports.orthogonal = orthogonal;
10081
10710
  exports.positionToDirection = positionToDirection;
10711
+ exports.themeAbyss = themeAbyss;
10712
+ exports.themeAbyssSpaced = themeAbyssSpaced;
10713
+ exports.themeDark = themeDark;
10714
+ exports.themeDracula = themeDracula;
10715
+ exports.themeLight = themeLight;
10716
+ exports.themeLightSpaced = themeLightSpaced;
10717
+ exports.themeReplit = themeReplit;
10718
+ exports.themeVisualStudio = themeVisualStudio;
10082
10719
  exports.toTarget = toTarget;
10083
10720
 
10084
10721
  }));