dockview 1.4.1 → 1.5.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 (156) hide show
  1. package/README.md +4 -195
  2. package/dist/cjs/api/component.api.d.ts +8 -3
  3. package/dist/cjs/api/component.api.js +16 -4
  4. package/dist/cjs/api/component.api.js.map +1 -1
  5. package/dist/cjs/dnd/droptarget.d.ts +1 -2
  6. package/dist/cjs/dockview/components/tab/defaultTab.d.ts +1 -0
  7. package/dist/cjs/dockview/components/tab/defaultTab.js +6 -3
  8. package/dist/cjs/dockview/components/tab/defaultTab.js.map +1 -1
  9. package/dist/cjs/dockview/components/watermark/watermark.js +3 -1
  10. package/dist/cjs/dockview/components/watermark/watermark.js.map +1 -1
  11. package/dist/cjs/dockview/defaultGroupPanelView.d.ts +1 -5
  12. package/dist/cjs/dockview/defaultGroupPanelView.js +5 -20
  13. package/dist/cjs/dockview/defaultGroupPanelView.js.map +1 -1
  14. package/dist/cjs/dockview/deserializer.d.ts +0 -12
  15. package/dist/cjs/dockview/deserializer.js +0 -52
  16. package/dist/cjs/dockview/deserializer.js.map +1 -1
  17. package/dist/cjs/dockview/dockviewComponent.d.ts +6 -8
  18. package/dist/cjs/dockview/dockviewComponent.js +84 -58
  19. package/dist/cjs/dockview/dockviewComponent.js.map +1 -1
  20. package/dist/cjs/dockview/options.d.ts +11 -1
  21. package/dist/cjs/gridview/baseComponentGridview.d.ts +4 -2
  22. package/dist/cjs/gridview/baseComponentGridview.js +1 -1
  23. package/dist/cjs/gridview/baseComponentGridview.js.map +1 -1
  24. package/dist/cjs/gridview/gridviewComponent.d.ts +1 -0
  25. package/dist/cjs/gridview/gridviewComponent.js +26 -18
  26. package/dist/cjs/gridview/gridviewComponent.js.map +1 -1
  27. package/dist/cjs/groupview/groupview.d.ts +20 -18
  28. package/dist/cjs/groupview/groupview.js +44 -41
  29. package/dist/cjs/groupview/groupview.js.map +1 -1
  30. package/dist/cjs/groupview/groupviewPanel.d.ts +2 -2
  31. package/dist/cjs/groupview/groupviewPanel.js.map +1 -1
  32. package/dist/cjs/groupview/tab.d.ts +1 -0
  33. package/dist/cjs/groupview/tab.js +3 -1
  34. package/dist/cjs/groupview/tab.js.map +1 -1
  35. package/dist/cjs/groupview/titlebar/tabsContainer.d.ts +3 -5
  36. package/dist/cjs/groupview/titlebar/tabsContainer.js +3 -5
  37. package/dist/cjs/groupview/titlebar/tabsContainer.js.map +1 -1
  38. package/dist/cjs/groupview/types.d.ts +0 -4
  39. package/dist/cjs/index.d.ts +2 -0
  40. package/dist/cjs/index.js +1 -0
  41. package/dist/cjs/index.js.map +1 -1
  42. package/dist/cjs/paneview/defaultPaneviewHeader.d.ts +3 -0
  43. package/dist/cjs/paneview/defaultPaneviewHeader.js +32 -6
  44. package/dist/cjs/paneview/defaultPaneviewHeader.js.map +1 -1
  45. package/dist/cjs/paneview/draggablePaneviewPanel.d.ts +3 -1
  46. package/dist/cjs/paneview/draggablePaneviewPanel.js +24 -9
  47. package/dist/cjs/paneview/draggablePaneviewPanel.js.map +1 -1
  48. package/dist/cjs/paneview/options.d.ts +2 -0
  49. package/dist/cjs/paneview/paneviewComponent.d.ts +14 -1
  50. package/dist/cjs/paneview/paneviewComponent.js +32 -17
  51. package/dist/cjs/paneview/paneviewComponent.js.map +1 -1
  52. package/dist/cjs/react/deserializer.js +13 -5
  53. package/dist/cjs/react/deserializer.js.map +1 -1
  54. package/dist/cjs/react/dockview/defaultTab.d.ts +4 -0
  55. package/dist/cjs/react/dockview/defaultTab.js +73 -0
  56. package/dist/cjs/react/dockview/defaultTab.js.map +1 -0
  57. package/dist/cjs/react/dockview/dockview.d.ts +5 -3
  58. package/dist/cjs/react/dockview/dockview.js +45 -3
  59. package/dist/cjs/react/dockview/dockview.js.map +1 -1
  60. package/dist/cjs/react/dockview/groupControlsRenderer.d.ts +43 -0
  61. package/dist/cjs/react/dockview/groupControlsRenderer.js +87 -0
  62. package/dist/cjs/react/dockview/groupControlsRenderer.js.map +1 -0
  63. package/dist/cjs/react/dockview/reactContentPart.d.ts +1 -16
  64. package/dist/cjs/react/dockview/reactContentPart.js +2 -18
  65. package/dist/cjs/react/dockview/reactContentPart.js.map +1 -1
  66. package/dist/cjs/react/dockview/reactHeaderPart.d.ts +2 -0
  67. package/dist/cjs/react/dockview/reactHeaderPart.js +4 -0
  68. package/dist/cjs/react/dockview/reactHeaderPart.js.map +1 -1
  69. package/dist/cjs/react/index.d.ts +2 -2
  70. package/dist/cjs/react/index.js +1 -2
  71. package/dist/cjs/react/index.js.map +1 -1
  72. package/dist/cjs/react/paneview/paneview.d.ts +2 -0
  73. package/dist/cjs/react/paneview/paneview.js +9 -0
  74. package/dist/cjs/react/paneview/paneview.js.map +1 -1
  75. package/dist/cjs/react/react.d.ts +1 -0
  76. package/dist/cjs/react/react.js +12 -2
  77. package/dist/cjs/react/react.js.map +1 -1
  78. package/dist/cjs/react/svg.d.ts +3 -0
  79. package/dist/cjs/react/svg.js +36 -0
  80. package/dist/cjs/react/svg.js.map +1 -0
  81. package/dist/cjs/splitview/splitviewComponent.d.ts +2 -0
  82. package/dist/cjs/splitview/splitviewComponent.js +20 -17
  83. package/dist/cjs/splitview/splitviewComponent.js.map +1 -1
  84. package/dist/cjs/svg.d.ts +3 -0
  85. package/dist/cjs/svg.js +44 -0
  86. package/dist/cjs/svg.js.map +1 -0
  87. package/dist/dockview.amd.js +454 -204
  88. package/dist/dockview.amd.min.js +2 -2
  89. package/dist/dockview.amd.min.noStyle.js +2 -2
  90. package/dist/dockview.amd.noStyle.js +453 -203
  91. package/dist/dockview.cjs.js +454 -204
  92. package/dist/dockview.esm.js +449 -198
  93. package/dist/dockview.esm.min.js +2 -2
  94. package/dist/dockview.js +454 -204
  95. package/dist/dockview.min.js +2 -2
  96. package/dist/dockview.min.noStyle.js +2 -2
  97. package/dist/dockview.noStyle.js +453 -203
  98. package/dist/esm/api/component.api.d.ts +8 -3
  99. package/dist/esm/api/component.api.js +16 -4
  100. package/dist/esm/dnd/droptarget.d.ts +1 -2
  101. package/dist/esm/dockview/components/tab/defaultTab.d.ts +1 -0
  102. package/dist/esm/dockview/components/tab/defaultTab.js +5 -2
  103. package/dist/esm/dockview/components/watermark/watermark.js +3 -1
  104. package/dist/esm/dockview/defaultGroupPanelView.d.ts +1 -5
  105. package/dist/esm/dockview/defaultGroupPanelView.js +5 -16
  106. package/dist/esm/dockview/deserializer.d.ts +0 -12
  107. package/dist/esm/dockview/deserializer.js +1 -27
  108. package/dist/esm/dockview/dockviewComponent.d.ts +6 -8
  109. package/dist/esm/dockview/dockviewComponent.js +56 -41
  110. package/dist/esm/dockview/options.d.ts +11 -1
  111. package/dist/esm/gridview/baseComponentGridview.d.ts +4 -2
  112. package/dist/esm/gridview/baseComponentGridview.js +1 -1
  113. package/dist/esm/gridview/gridviewComponent.d.ts +1 -0
  114. package/dist/esm/gridview/gridviewComponent.js +15 -7
  115. package/dist/esm/groupview/groupview.d.ts +20 -18
  116. package/dist/esm/groupview/groupview.js +42 -40
  117. package/dist/esm/groupview/groupviewPanel.d.ts +2 -2
  118. package/dist/esm/groupview/tab.d.ts +1 -0
  119. package/dist/esm/groupview/tab.js +3 -1
  120. package/dist/esm/groupview/titlebar/tabsContainer.d.ts +3 -5
  121. package/dist/esm/groupview/titlebar/tabsContainer.js +3 -5
  122. package/dist/esm/groupview/types.d.ts +0 -4
  123. package/dist/esm/index.d.ts +2 -0
  124. package/dist/esm/index.js +1 -0
  125. package/dist/esm/paneview/defaultPaneviewHeader.d.ts +3 -0
  126. package/dist/esm/paneview/defaultPaneviewHeader.js +32 -6
  127. package/dist/esm/paneview/draggablePaneviewPanel.d.ts +3 -1
  128. package/dist/esm/paneview/draggablePaneviewPanel.js +24 -9
  129. package/dist/esm/paneview/options.d.ts +2 -0
  130. package/dist/esm/paneview/paneviewComponent.d.ts +14 -1
  131. package/dist/esm/paneview/paneviewComponent.js +17 -6
  132. package/dist/esm/react/deserializer.js +13 -5
  133. package/dist/esm/react/dockview/defaultTab.d.ts +4 -0
  134. package/dist/esm/react/dockview/defaultTab.js +34 -0
  135. package/dist/esm/react/dockview/dockview.d.ts +5 -3
  136. package/dist/esm/react/dockview/dockview.js +30 -1
  137. package/dist/esm/react/dockview/groupControlsRenderer.d.ts +43 -0
  138. package/dist/esm/react/dockview/groupControlsRenderer.js +68 -0
  139. package/dist/esm/react/dockview/reactContentPart.d.ts +1 -16
  140. package/dist/esm/react/dockview/reactContentPart.js +2 -14
  141. package/dist/esm/react/dockview/reactHeaderPart.d.ts +2 -0
  142. package/dist/esm/react/dockview/reactHeaderPart.js +4 -0
  143. package/dist/esm/react/index.d.ts +2 -2
  144. package/dist/esm/react/index.js +1 -2
  145. package/dist/esm/react/paneview/paneview.d.ts +2 -0
  146. package/dist/esm/react/paneview/paneview.js +9 -0
  147. package/dist/esm/react/react.d.ts +1 -0
  148. package/dist/esm/react/react.js +12 -2
  149. package/dist/esm/react/svg.d.ts +3 -0
  150. package/dist/esm/react/svg.js +7 -0
  151. package/dist/esm/splitview/splitviewComponent.d.ts +2 -0
  152. package/dist/esm/splitview/splitviewComponent.js +9 -6
  153. package/dist/esm/svg.d.ts +3 -0
  154. package/dist/esm/svg.js +31 -0
  155. package/dist/styles/dockview.css +158 -40
  156. package/package.json +2 -2
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * dockview
3
- * @version 1.4.1
3
+ * @version 1.5.0
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -2298,6 +2298,9 @@
2298
2298
  toJSON() {
2299
2299
  return this.component.toJSON();
2300
2300
  }
2301
+ clear() {
2302
+ this.component.clear();
2303
+ }
2301
2304
  }
2302
2305
  class PaneviewApi {
2303
2306
  constructor(component) {
@@ -2365,6 +2368,9 @@
2365
2368
  toJSON() {
2366
2369
  return this.component.toJSON();
2367
2370
  }
2371
+ clear() {
2372
+ this.component.clear();
2373
+ }
2368
2374
  }
2369
2375
  class GridviewApi {
2370
2376
  constructor(component) {
@@ -2391,13 +2397,13 @@
2391
2397
  get onDidLayoutChange() {
2392
2398
  return this.component.onDidLayoutChange;
2393
2399
  }
2394
- get onDidAddGroup() {
2400
+ get onDidAddPanel() {
2395
2401
  return this.component.onDidAddGroup;
2396
2402
  }
2397
- get onDidRemoveGroup() {
2403
+ get onDidRemovePanel() {
2398
2404
  return this.component.onDidRemoveGroup;
2399
2405
  }
2400
- get onDidActiveGroupChange() {
2406
+ get onDidActivePanelChange() {
2401
2407
  return this.component.onDidActiveGroupChange;
2402
2408
  }
2403
2409
  get onDidLayoutFromJSON() {
@@ -2436,6 +2442,9 @@
2436
2442
  toJSON() {
2437
2443
  return this.component.toJSON();
2438
2444
  }
2445
+ clear() {
2446
+ this.component.clear();
2447
+ }
2439
2448
  }
2440
2449
  class DockviewApi {
2441
2450
  constructor(component) {
@@ -2484,7 +2493,7 @@
2484
2493
  return this.component.onDidRemovePanel;
2485
2494
  }
2486
2495
  get onDidLayoutFromJSON() {
2487
- return this.component.onDidLayoutfromJSON;
2496
+ return this.component.onDidLayoutFromJSON;
2488
2497
  }
2489
2498
  get onDidLayoutChange() {
2490
2499
  return this.component.onDidLayoutChange;
@@ -2546,6 +2555,9 @@
2546
2555
  toJSON() {
2547
2556
  return this.component.toJSON();
2548
2557
  }
2558
+ clear() {
2559
+ this.component.clear();
2560
+ }
2549
2561
  }
2550
2562
 
2551
2563
  class ContentContainer extends CompositeDisposable {
@@ -2619,12 +2631,12 @@
2619
2631
  }
2620
2632
  }
2621
2633
 
2622
- var DockviewDropTargets;
2634
+ exports.DockviewDropTargets = void 0;
2623
2635
  (function (DockviewDropTargets) {
2624
2636
  DockviewDropTargets[DockviewDropTargets["Tab"] = 0] = "Tab";
2625
2637
  DockviewDropTargets[DockviewDropTargets["Panel"] = 1] = "Panel";
2626
2638
  DockviewDropTargets[DockviewDropTargets["TabContainer"] = 2] = "TabContainer";
2627
- })(DockviewDropTargets || (DockviewDropTargets = {}));
2639
+ })(exports.DockviewDropTargets || (exports.DockviewDropTargets = {}));
2628
2640
 
2629
2641
  class DragHandler extends CompositeDisposable {
2630
2642
  constructor(el) {
@@ -2670,6 +2682,7 @@
2670
2682
  constructor(panelId, accessor, group) {
2671
2683
  super();
2672
2684
  this.panelId = panelId;
2685
+ this.accessor = accessor;
2673
2686
  this.group = group;
2674
2687
  this._onChanged = new Emitter();
2675
2688
  this.onChanged = this._onChanged.event;
@@ -2680,6 +2693,7 @@
2680
2693
  this._element.className = 'tab';
2681
2694
  this._element.tabIndex = 0;
2682
2695
  this._element.draggable = true;
2696
+ toggleClass(this.element, 'inactive-tab', true);
2683
2697
  this.addDisposables(new (class Handler extends DragHandler {
2684
2698
  constructor() {
2685
2699
  super(...arguments);
@@ -2719,10 +2733,10 @@
2719
2733
  validOverlays: 'none',
2720
2734
  canDisplayOverlay: (event) => {
2721
2735
  const data = getPanelData();
2722
- if (data) {
2736
+ if (data && this.accessor.id === data.viewId) {
2723
2737
  return this.panelId !== data.panelId;
2724
2738
  }
2725
- return this.group.model.canDisplayOverlay(event, DockviewDropTargets.Tab);
2739
+ return this.group.model.canDisplayOverlay(event, exports.DockviewDropTargets.Tab);
2726
2740
  },
2727
2741
  });
2728
2742
  this.addDisposables(this.droptarget.onDrop((event) => {
@@ -2756,7 +2770,6 @@
2756
2770
  this.group = group;
2757
2771
  this.tabs = [];
2758
2772
  this.selectedIndex = -1;
2759
- this.active = false;
2760
2773
  this._hidden = false;
2761
2774
  this._onDrop = new Emitter();
2762
2775
  this.onDrop = this._onDrop.event;
@@ -2778,11 +2791,11 @@
2778
2791
  canDisplayOverlay: (event) => {
2779
2792
  var _a;
2780
2793
  const data = getPanelData();
2781
- if (data) {
2794
+ if (data && this.accessor.id === data.viewId) {
2782
2795
  // don't show the overlay if the tab being dragged is the last panel of this group
2783
2796
  return ((_a = last(this.tabs)) === null || _a === void 0 ? void 0 : _a.value.panelId) !== data.panelId;
2784
2797
  }
2785
- return group.model.canDisplayOverlay(event, DockviewDropTargets.Panel);
2798
+ return group.model.canDisplayOverlay(event, exports.DockviewDropTargets.Panel);
2786
2799
  },
2787
2800
  });
2788
2801
  this.addDisposables(this.voidDropTarget.onDrop((event) => {
@@ -2860,8 +2873,8 @@
2860
2873
  indexOf(id) {
2861
2874
  return this.tabs.findIndex((tab) => tab.value.panelId === id);
2862
2875
  }
2863
- setActive(isGroupActive) {
2864
- this.active = isGroupActive;
2876
+ setActive(_isGroupActive) {
2877
+ // noop
2865
2878
  }
2866
2879
  addTab(tab, index = this.tabs.length) {
2867
2880
  if (index < 0 || index > this.tabs.length) {
@@ -2922,7 +2935,6 @@
2922
2935
  }));
2923
2936
  const value = { value: tabToAdd, disposable };
2924
2937
  this.addTab(value, index);
2925
- this.activePanel = panel;
2926
2938
  }
2927
2939
  closePanel(panel) {
2928
2940
  this.delete(panel.id);
@@ -2936,12 +2948,6 @@
2936
2948
  }
2937
2949
  }
2938
2950
 
2939
- exports.GroupChangeKind2 = void 0;
2940
- (function (GroupChangeKind2) {
2941
- GroupChangeKind2["ADD_PANEL"] = "ADD_PANEL";
2942
- GroupChangeKind2["REMOVE_PANEL"] = "REMOVE_PANEL";
2943
- GroupChangeKind2["PANEL_ACTIVE"] = "PANEL_ACTIVE";
2944
- })(exports.GroupChangeKind2 || (exports.GroupChangeKind2 = {}));
2945
2951
  class Groupview extends CompositeDisposable {
2946
2952
  constructor(container, accessor, id, options, parent) {
2947
2953
  super();
@@ -2960,12 +2966,15 @@
2960
2966
  this._panels = [];
2961
2967
  this._onMove = new Emitter();
2962
2968
  this.onMove = this._onMove.event;
2963
- this._onDidGroupChange = new Emitter();
2964
- this.onDidGroupChange = this._onDidGroupChange.event;
2965
2969
  this._onDidDrop = new Emitter();
2966
2970
  this.onDidDrop = this._onDidDrop.event;
2971
+ this._onDidAddPanel = new Emitter();
2972
+ this.onDidAddPanel = this._onDidAddPanel.event;
2973
+ this._onDidRemovePanel = new Emitter();
2974
+ this.onDidRemovePanel = this._onDidRemovePanel.event;
2975
+ this._onDidActivePanelChange = new Emitter();
2976
+ this.onDidActivePanelChange = this._onDidActivePanelChange.event;
2967
2977
  this.container.classList.add('groupview');
2968
- this.addDisposables(this._onMove, this._onDidGroupChange, this._onDidChange, this._onDidDrop);
2969
2978
  this.tabsContainer = new TabsContainer(this.accessor, this.parent, {
2970
2979
  tabHeight: options.tabHeight,
2971
2980
  });
@@ -2977,17 +2986,17 @@
2977
2986
  return false;
2978
2987
  }
2979
2988
  const data = getPanelData();
2980
- if (data) {
2989
+ if (data && data.viewId === this.accessor.id) {
2981
2990
  const groupHasOnePanelAndIsActiveDragElement = this._panels.length === 1 && data.groupId === this.id;
2982
2991
  return !groupHasOnePanelAndIsActiveDragElement;
2983
2992
  }
2984
- return this.canDisplayOverlay(event, DockviewDropTargets.Panel);
2993
+ return this.canDisplayOverlay(event, exports.DockviewDropTargets.Panel);
2985
2994
  },
2986
2995
  });
2987
2996
  container.append(this.tabsContainer.element, this.contentContainer.element);
2988
2997
  this.header.hidden = !!options.hideHeader;
2989
2998
  this.locked = !!options.locked;
2990
- this.addDisposables(this._onMove, this._onDidGroupChange, this.tabsContainer.onDrop((event) => {
2999
+ this.addDisposables(this._onMove, this._onDidChange, this._onDidDrop, this._onDidAddPanel, this._onDidRemovePanel, this._onDidActivePanelChange, this.tabsContainer.onDrop((event) => {
2991
3000
  this.handleDropEvent(event.event, exports.Position.Center, event.index);
2992
3001
  }), this.contentContainer.onDidFocus(() => {
2993
3002
  this.accessor.doSetGroupActive(this.parent, true);
@@ -3059,6 +3068,15 @@
3059
3068
  // correctly initialized
3060
3069
  this.setActive(this.isActive, true, true);
3061
3070
  this.updateContainer();
3071
+ if (this.accessor.options.createGroupControlElement) {
3072
+ this._control = this.accessor.options.createGroupControlElement(this.parent);
3073
+ this.addDisposables(this._control);
3074
+ this._control.init({
3075
+ containerApi: new DockviewApi(this.accessor),
3076
+ api: this.parent.api,
3077
+ });
3078
+ this.tabsContainer.setActionElement(this._control.element);
3079
+ }
3062
3080
  }
3063
3081
  indexOf(panel) {
3064
3082
  return this.tabsContainer.indexOf(panel.id);
@@ -3139,16 +3157,21 @@
3139
3157
  options.index > this.panels.length) {
3140
3158
  options.index = this.panels.length;
3141
3159
  }
3142
- const skipSetActive = !!options.skipSetActive;
3160
+ const skipSetPanelActive = !!options.skipSetPanelActive;
3161
+ const skipSetGroupActive = !!options.skipSetGroupActive;
3143
3162
  // ensure the group is updated before we fire any events
3144
3163
  panel.updateParentGroup(this.parent, true);
3145
- if (!skipSetActive && this._activePanel === panel) {
3146
- this.accessor.doSetGroupActive(this.parent);
3164
+ if (this._activePanel === panel) {
3165
+ if (!skipSetGroupActive) {
3166
+ this.accessor.doSetGroupActive(this.parent);
3167
+ }
3147
3168
  return;
3148
3169
  }
3149
- this.doAddPanel(panel, options.index);
3150
- if (!skipSetActive) {
3170
+ this.doAddPanel(panel, options.index, skipSetPanelActive);
3171
+ if (!skipSetPanelActive) {
3151
3172
  this.doSetActivePanel(panel);
3173
+ }
3174
+ if (!skipSetGroupActive) {
3152
3175
  this.accessor.doSetGroupActive(this.parent, !!options.skipFocus);
3153
3176
  }
3154
3177
  this.updateContainer();
@@ -3184,14 +3207,8 @@
3184
3207
  isPanelActive(panel) {
3185
3208
  return this._activePanel === panel;
3186
3209
  }
3187
- updateActions() {
3188
- var _a, _b;
3189
- if (this.isActive && ((_b = (_a = this._activePanel) === null || _a === void 0 ? void 0 : _a.view) === null || _b === void 0 ? void 0 : _b.actions)) {
3190
- this.tabsContainer.setActionElement(this._activePanel.view.actions.element);
3191
- }
3192
- else {
3193
- this.tabsContainer.setActionElement(undefined);
3194
- }
3210
+ updateActions(element) {
3211
+ this.tabsContainer.setActionElement(element);
3195
3212
  }
3196
3213
  setActive(isGroupActive, skipFocus = false, force = false) {
3197
3214
  var _a, _b;
@@ -3247,16 +3264,15 @@
3247
3264
  if (this.mostRecentlyUsed.includes(panel)) {
3248
3265
  this.mostRecentlyUsed.splice(this.mostRecentlyUsed.indexOf(panel), 1);
3249
3266
  }
3250
- this._onDidGroupChange.fire({
3251
- kind: exports.GroupChangeKind2.REMOVE_PANEL,
3252
- panel,
3253
- });
3267
+ this._onDidRemovePanel.fire({ panel });
3254
3268
  }
3255
- doAddPanel(panel, index = this.panels.length) {
3269
+ doAddPanel(panel, index = this.panels.length, skipSetActive = false) {
3256
3270
  const existingPanel = this._panels.indexOf(panel);
3257
3271
  const hasExistingPanel = existingPanel > -1;
3258
3272
  this.tabsContainer.openPanel(panel, index);
3259
- this.contentContainer.openPanel(panel);
3273
+ if (!skipSetActive) {
3274
+ this.contentContainer.openPanel(panel);
3275
+ }
3260
3276
  this.tabsContainer.show();
3261
3277
  this.contentContainer.show();
3262
3278
  if (hasExistingPanel) {
@@ -3265,10 +3281,7 @@
3265
3281
  }
3266
3282
  this.updateMru(panel);
3267
3283
  this.panels.splice(index, 0, panel);
3268
- this._onDidGroupChange.fire({
3269
- kind: exports.GroupChangeKind2.ADD_PANEL,
3270
- panel,
3271
- });
3284
+ this._onDidAddPanel.fire({ panel });
3272
3285
  }
3273
3286
  doSetActivePanel(panel) {
3274
3287
  this._activePanel = panel;
@@ -3276,10 +3289,7 @@
3276
3289
  this.tabsContainer.setActivePanel(panel);
3277
3290
  panel.layout(this._width, this._height);
3278
3291
  this.updateMru(panel);
3279
- this._onDidGroupChange.fire({
3280
- kind: exports.GroupChangeKind2.PANEL_ACTIVE,
3281
- panel,
3282
- });
3292
+ this._onDidActivePanelChange.fire({ panel });
3283
3293
  }
3284
3294
  }
3285
3295
  updateMru(panel) {
@@ -3289,7 +3299,6 @@
3289
3299
  this.mostRecentlyUsed = [panel, ...this.mostRecentlyUsed];
3290
3300
  }
3291
3301
  updateContainer() {
3292
- this.updateActions();
3293
3302
  toggleClass(this.container, 'empty', this.isEmpty);
3294
3303
  this.panels.forEach((panel) => panel.updateParentGroup(this.parent, this.isActive));
3295
3304
  if (this.isEmpty && !this.watermark) {
@@ -3322,7 +3331,12 @@
3322
3331
  canDisplayOverlay(event, target) {
3323
3332
  // custom overlay handler
3324
3333
  if (this.accessor.options.showDndOverlay) {
3325
- return this.accessor.options.showDndOverlay(event, target);
3334
+ return this.accessor.options.showDndOverlay({
3335
+ nativeEvent: event,
3336
+ target,
3337
+ group: this.accessor.getPanel(this.id),
3338
+ getData: getPanelData,
3339
+ });
3326
3340
  }
3327
3341
  return false;
3328
3342
  }
@@ -3370,7 +3384,7 @@
3370
3384
  }
3371
3385
  }
3372
3386
 
3373
- const nextLayoutId = sequentialNumberGenerator();
3387
+ const nextLayoutId$1 = sequentialNumberGenerator();
3374
3388
  function toTarget(direction) {
3375
3389
  switch (direction) {
3376
3390
  case 'left':
@@ -3390,7 +3404,7 @@
3390
3404
  constructor(_element, options) {
3391
3405
  super();
3392
3406
  this._element = _element;
3393
- this._id = nextLayoutId.next();
3407
+ this._id = nextLayoutId$1.next();
3394
3408
  this._groups = new Map();
3395
3409
  this._onDidLayoutChange = new Emitter();
3396
3410
  this.onDidLayoutChange = this._onDidLayoutChange.event;
@@ -3405,7 +3419,7 @@
3405
3419
  this.element.appendChild(this.gridview.element);
3406
3420
  this.layout(0, 0, true); // set some elements height/widths
3407
3421
  this.addDisposables(this.gridview.onDidChange(() => {
3408
- this._onDidLayoutChange.fire();
3422
+ this._bufferOnDidLayoutChange.fire();
3409
3423
  }));
3410
3424
  this.addDisposables(exports.Event.any(this.onDidAddGroup, this.onDidRemoveGroup, this.onDidActiveGroupChange)(() => {
3411
3425
  this._bufferOnDidLayoutChange.fire();
@@ -3850,6 +3864,38 @@
3850
3864
  }
3851
3865
  }
3852
3866
 
3867
+ const createSvgElementFromPath = (params) => {
3868
+ const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
3869
+ svg.setAttributeNS(null, 'height', params.height);
3870
+ svg.setAttributeNS(null, 'width', params.width);
3871
+ svg.setAttributeNS(null, 'viewBox', params.viewbox);
3872
+ svg.setAttributeNS(null, 'aria-hidden', 'false');
3873
+ svg.setAttributeNS(null, 'focusable', 'false');
3874
+ svg.classList.add('dockview-svg');
3875
+ const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
3876
+ path.setAttributeNS(null, 'd', params.path);
3877
+ svg.appendChild(path);
3878
+ return svg;
3879
+ };
3880
+ const createCloseButton = () => createSvgElementFromPath({
3881
+ width: '11',
3882
+ height: '11',
3883
+ viewbox: '0 0 28 28',
3884
+ 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',
3885
+ });
3886
+ const createExpandMoreButton = () => createSvgElementFromPath({
3887
+ width: '11',
3888
+ height: '11',
3889
+ viewbox: '0 0 24 15',
3890
+ path: 'M12 14.15L0 2.15L2.15 0L12 9.9L21.85 0.0499992L24 2.2L12 14.15Z',
3891
+ });
3892
+ const createChevronRightButton = () => createSvgElementFromPath({
3893
+ width: '11',
3894
+ height: '11',
3895
+ viewbox: '0 0 15 25',
3896
+ path: 'M2.15 24.1L0 21.95L9.9 12.05L0 2.15L2.15 0L14.2 12.05L2.15 24.1Z',
3897
+ });
3898
+
3853
3899
  class Watermark extends CompositeDisposable {
3854
3900
  constructor() {
3855
3901
  super();
@@ -3866,8 +3912,9 @@
3866
3912
  const actions = new ActionContainer();
3867
3913
  title.appendChild(emptySpace);
3868
3914
  title.appendChild(actions.element);
3869
- const closeAnchor = document.createElement('a');
3915
+ const closeAnchor = document.createElement('div');
3870
3916
  closeAnchor.className = 'close-action';
3917
+ closeAnchor.appendChild(createCloseButton());
3871
3918
  actions.add(closeAnchor);
3872
3919
  this.addDisposables(addDisposableListener(closeAnchor, 'click', (ev) => {
3873
3920
  var _a;
@@ -3915,34 +3962,6 @@
3915
3962
  }
3916
3963
  }
3917
3964
 
3918
- class DefaultDeserializer {
3919
- constructor(layout, panelDeserializer) {
3920
- this.layout = layout;
3921
- this.panelDeserializer = panelDeserializer;
3922
- }
3923
- fromJSON(node) {
3924
- const data = node.data;
3925
- const children = data.views;
3926
- const active = data.activeView;
3927
- const group = this.layout.createGroup({
3928
- id: data.id,
3929
- locked: !!data.locked,
3930
- hideHeader: !!data.hideHeader,
3931
- });
3932
- for (const child of children) {
3933
- const panel = this.panelDeserializer.createPanel(child, group);
3934
- const isActive = typeof active === 'string' && active === panel.id;
3935
- group.model.openPanel(panel, {
3936
- skipSetActive: !isActive,
3937
- });
3938
- }
3939
- if (!group.activePanel && group.panels.length > 0) {
3940
- group.model.openPanel(group.panels[group.panels.length - 1]);
3941
- }
3942
- return group;
3943
- }
3944
- }
3945
-
3946
3965
  function createComponent(id, componentName, components = {}, frameworkComponents = {}, createFrameworkComponent, fallback) {
3947
3966
  const Component = typeof componentName === 'string'
3948
3967
  ? components[componentName]
@@ -3968,6 +3987,7 @@
3968
3987
  return new Component(id, componentName);
3969
3988
  }
3970
3989
 
3990
+ const DEFAULT_TAB_IDENTIFIER = '__default__tab__';
3971
3991
  class DefaultTab extends CompositeDisposable {
3972
3992
  constructor() {
3973
3993
  super();
@@ -3987,8 +4007,9 @@
3987
4007
  this._list = document.createElement('ul');
3988
4008
  this._list.className = 'tab-list';
3989
4009
  //
3990
- this.action = document.createElement('a');
4010
+ this.action = document.createElement('div');
3991
4011
  this.action.className = 'tab-action';
4012
+ this.action.appendChild(createCloseButton());
3992
4013
  //
3993
4014
  this._element.appendChild(this._content);
3994
4015
  this._element.appendChild(this._actionContainer);
@@ -4004,7 +4025,7 @@
4004
4025
  return this._element;
4005
4026
  }
4006
4027
  get id() {
4007
- return '__DEFAULT_TAB__';
4028
+ return DEFAULT_TAB_IDENTIFIER;
4008
4029
  }
4009
4030
  update(event) {
4010
4031
  this.params = Object.assign(Object.assign({}, this.params), event.params);
@@ -4321,16 +4342,6 @@
4321
4342
  var _a;
4322
4343
  this._content = renderers.content;
4323
4344
  this._tab = (_a = renderers.tab) !== null && _a !== void 0 ? _a : new DefaultTab();
4324
- this._actions =
4325
- renderers.actions ||
4326
- (this.content.actions
4327
- ? {
4328
- element: this.content.actions,
4329
- dispose: () => {
4330
- //
4331
- },
4332
- }
4333
- : undefined);
4334
4345
  }
4335
4346
  get content() {
4336
4347
  return this._content;
@@ -4338,9 +4349,6 @@
4338
4349
  get tab() {
4339
4350
  return this._tab;
4340
4351
  }
4341
- get actions() {
4342
- return this._actions;
4343
- }
4344
4352
  init(params) {
4345
4353
  this.content.init(Object.assign(Object.assign({}, params), { tab: this.tab }));
4346
4354
  this.tab.init(params);
@@ -4358,16 +4366,18 @@
4358
4366
  this.tab.update(event);
4359
4367
  }
4360
4368
  toJSON() {
4369
+ let tab = this.tab instanceof DefaultTab ? undefined : this.tab.toJSON();
4370
+ if (tab && Object.keys(tab).length === 0) {
4371
+ tab = undefined;
4372
+ }
4361
4373
  return {
4362
4374
  content: this.content.toJSON(),
4363
- tab: this.tab instanceof DefaultTab ? undefined : this.tab.toJSON(),
4375
+ tab,
4364
4376
  };
4365
4377
  }
4366
4378
  dispose() {
4367
- var _a;
4368
4379
  this.content.dispose();
4369
4380
  this.tab.dispose();
4370
- (_a = this.actions) === null || _a === void 0 ? void 0 : _a.dispose();
4371
4381
  }
4372
4382
  }
4373
4383
 
@@ -4379,9 +4389,6 @@
4379
4389
  orientation: options.orientation || exports.Orientation.HORIZONTAL,
4380
4390
  styles: options.styles,
4381
4391
  });
4382
- // events
4383
- this._onTabInteractionEvent = new Emitter();
4384
- this.onTabInteractionEvent = this._onTabInteractionEvent.event;
4385
4392
  this._onTabContextMenu = new Emitter();
4386
4393
  this.onTabContextMenu = this._onTabContextMenu.event;
4387
4394
  this._onDidDrop = new Emitter();
@@ -4390,11 +4397,11 @@
4390
4397
  this.onDidRemovePanel = this._onDidRemovePanel.event;
4391
4398
  this._onDidAddPanel = new Emitter();
4392
4399
  this.onDidAddPanel = this._onDidAddPanel.event;
4393
- this._onDidLayoutfromJSON = new Emitter();
4394
- this.onDidLayoutfromJSON = this._onDidLayoutfromJSON.event;
4400
+ this._onDidLayoutFromJSON = new Emitter();
4401
+ this.onDidLayoutFromJSON = this._onDidLayoutFromJSON.event;
4395
4402
  this._onDidActivePanelChange = new Emitter();
4396
4403
  this.onDidActivePanelChange = this._onDidActivePanelChange.event;
4397
- this.addDisposables(this._onTabInteractionEvent, this._onTabContextMenu, this._onDidDrop, exports.Event.any(this.onDidAddPanel, this.onDidRemovePanel, this.onDidActivePanelChange)(() => {
4404
+ this.addDisposables(this._onTabContextMenu, this._onDidDrop, exports.Event.any(this.onDidAddPanel, this.onDidRemovePanel, this.onDidActivePanelChange)(() => {
4398
4405
  this._bufferOnDidLayoutChange.fire();
4399
4406
  }));
4400
4407
  this._options = options;
@@ -4449,7 +4456,7 @@
4449
4456
  }
4450
4457
  updateOptions(options) {
4451
4458
  const hasOrientationChanged = typeof options.orientation === 'string' &&
4452
- this.options.orientation !== options.orientation;
4459
+ this.gridview.orientation !== options.orientation;
4453
4460
  this._options = Object.assign(Object.assign({}, this.options), options);
4454
4461
  if (hasOrientationChanged) {
4455
4462
  this.gridview.orientation = options.orientation;
@@ -4527,12 +4534,7 @@
4527
4534
  };
4528
4535
  }
4529
4536
  fromJSON(data) {
4530
- const groups = Array.from(this._groups.values()).map((_) => _.value);
4531
- for (const group of groups) {
4532
- // remove the group will automatically remove the panels
4533
- this.removeGroup(group, true);
4534
- }
4535
- this.gridview.clear();
4537
+ this.clear();
4536
4538
  if (!this.deserializer) {
4537
4539
  throw new Error('invalid deserializer');
4538
4540
  }
@@ -4543,12 +4545,31 @@
4543
4545
  if (!this.deserializer) {
4544
4546
  throw new Error('no deserializer provided');
4545
4547
  }
4546
- this.gridview.deserialize(grid, new DefaultDeserializer(this, {
4547
- createPanel: (id, group) => {
4548
- const panelData = panels[id];
4549
- return this.deserializer.fromJSON(panelData, group);
4550
- },
4551
- }));
4548
+ this.gridview.deserialize(grid, {
4549
+ fromJSON: (node) => {
4550
+ const { id, locked, hideHeader, views, activeView } = node.data;
4551
+ const group = this.createGroup({
4552
+ id,
4553
+ locked: !!locked,
4554
+ hideHeader: !!hideHeader,
4555
+ });
4556
+ this._onDidAddGroup.fire(group);
4557
+ for (const child of views) {
4558
+ const panel = this.deserializer.fromJSON(panels[child], group);
4559
+ const isActive = typeof activeView === 'string' && activeView === panel.id;
4560
+ group.model.openPanel(panel, {
4561
+ skipSetPanelActive: !isActive,
4562
+ skipSetGroupActive: true
4563
+ });
4564
+ }
4565
+ if (!group.activePanel && group.panels.length > 0) {
4566
+ group.model.openPanel(group.panels[group.panels.length - 1], {
4567
+ skipSetGroupActive: true
4568
+ });
4569
+ }
4570
+ return group;
4571
+ }
4572
+ });
4552
4573
  if (typeof activeGroup === 'string') {
4553
4574
  const panel = this.getPanel(activeGroup);
4554
4575
  if (panel) {
@@ -4556,7 +4577,23 @@
4556
4577
  }
4557
4578
  }
4558
4579
  this.gridview.layout(this.width, this.height);
4559
- this._onDidLayoutfromJSON.fire();
4580
+ this._onDidLayoutFromJSON.fire();
4581
+ }
4582
+ clear() {
4583
+ const groups = Array.from(this._groups.values()).map((_) => _.value);
4584
+ const hasActiveGroup = !!this.activeGroup;
4585
+ const hasActivePanel = !!this.activePanel;
4586
+ for (const group of groups) {
4587
+ // remove the group will automatically remove the panels
4588
+ this.removeGroup(group, true);
4589
+ }
4590
+ if (hasActiveGroup) {
4591
+ this.doSetGroupActive(undefined);
4592
+ }
4593
+ if (hasActivePanel) {
4594
+ this._onDidActivePanelChange.fire(undefined);
4595
+ }
4596
+ this.gridview.clear();
4560
4597
  }
4561
4598
  closeAllGroups() {
4562
4599
  for (const entry of this._groups.entries()) {
@@ -4754,23 +4791,13 @@
4754
4791
  const { groupId, itemId, target, index } = event;
4755
4792
  this.moveGroupOrPanel(view, groupId, itemId, target, index);
4756
4793
  }), view.model.onDidDrop((event) => {
4757
- this._onDidDrop.fire(Object.assign(Object.assign({}, event), { api: this._api }));
4758
- }), view.model.onDidGroupChange((event) => {
4759
- switch (event.kind) {
4760
- case exports.GroupChangeKind2.ADD_PANEL:
4761
- if (event.panel) {
4762
- this._onDidAddPanel.fire(event.panel);
4763
- }
4764
- break;
4765
- case exports.GroupChangeKind2.REMOVE_PANEL:
4766
- if (event.panel) {
4767
- this._onDidRemovePanel.fire(event.panel);
4768
- }
4769
- break;
4770
- case exports.GroupChangeKind2.PANEL_ACTIVE:
4771
- this._onDidActivePanelChange.fire(event.panel);
4772
- break;
4773
- }
4794
+ this._onDidDrop.fire(Object.assign(Object.assign({}, event), { api: this._api, group: view }));
4795
+ }), view.model.onDidAddPanel((event) => {
4796
+ this._onDidAddPanel.fire(event.panel);
4797
+ }), view.model.onDidRemovePanel((event) => {
4798
+ this._onDidRemovePanel.fire(event.panel);
4799
+ }), view.model.onDidActivePanelChange((event) => {
4800
+ this._onDidActivePanelChange.fire(event.panel);
4774
4801
  }));
4775
4802
  this._groups.set(view.id, { value: view, disposable });
4776
4803
  }
@@ -4785,7 +4812,7 @@
4785
4812
  createPanel(options, group) {
4786
4813
  const view = new DefaultGroupPanelView({
4787
4814
  content: this.createContentComponent(options.id, options.component),
4788
- tab: this.createTabComponent(options.id, options.tabComponent),
4815
+ tab: this.createTabComponent(options.id, options.tabComponent || this.options.defaultTabComponent),
4789
4816
  });
4790
4817
  const panel = new DockviewGroupPanel(options.id, this, this._api, group);
4791
4818
  panel.init({
@@ -4818,7 +4845,7 @@
4818
4845
  this._onDidActivePanelChange.dispose();
4819
4846
  this._onDidAddPanel.dispose();
4820
4847
  this._onDidRemovePanel.dispose();
4821
- this._onDidLayoutfromJSON.dispose();
4848
+ this._onDidLayoutFromJSON.dispose();
4822
4849
  }
4823
4850
  }
4824
4851
 
@@ -4856,7 +4883,7 @@
4856
4883
  }
4857
4884
  updateOptions(options) {
4858
4885
  const hasOrientationChanged = typeof options.orientation === 'string' &&
4859
- this.options.orientation !== options.orientation;
4886
+ this.gridview.orientation !== options.orientation;
4860
4887
  this._options = Object.assign(Object.assign({}, this.options), options);
4861
4888
  if (hasOrientationChanged) {
4862
4889
  this.gridview.orientation = options.orientation;
@@ -4892,13 +4919,8 @@
4892
4919
  (_a = this.activeGroup) === null || _a === void 0 ? void 0 : _a.focus();
4893
4920
  }
4894
4921
  fromJSON(serializedGridview) {
4922
+ this.clear();
4895
4923
  const { grid, activePanel } = serializedGridview;
4896
- const groups = Array.from(this._groups.values()); // reassign since group panels will mutate
4897
- for (const group of groups) {
4898
- group.disposable.dispose();
4899
- this.doRemoveGroup(group.value, { skipActive: true });
4900
- }
4901
- this.gridview.clear();
4902
4924
  const queue = [];
4903
4925
  this.gridview.deserialize(grid, {
4904
4926
  fromJSON: (node) => {
@@ -4920,6 +4942,7 @@
4920
4942
  accessor: this,
4921
4943
  isVisible: node.visible,
4922
4944
  }));
4945
+ this._onDidAddGroup.fire(view);
4923
4946
  this.registerPanel(view);
4924
4947
  return view;
4925
4948
  },
@@ -4934,6 +4957,18 @@
4934
4957
  }
4935
4958
  this._onDidLayoutfromJSON.fire();
4936
4959
  }
4960
+ clear() {
4961
+ const hasActiveGroup = this.activeGroup;
4962
+ const groups = Array.from(this._groups.values()); // reassign since group panels will mutate
4963
+ for (const group of groups) {
4964
+ group.disposable.dispose();
4965
+ this.doRemoveGroup(group.value, { skipActive: true });
4966
+ }
4967
+ if (hasActiveGroup) {
4968
+ this.doSetGroupActive(undefined);
4969
+ }
4970
+ this.gridview.clear();
4971
+ }
4937
4972
  movePanel(panel, options) {
4938
4973
  var _a;
4939
4974
  let relativeLocation;
@@ -5224,13 +5259,8 @@
5224
5259
  };
5225
5260
  }
5226
5261
  fromJSON(serializedSplitview) {
5262
+ this.clear();
5227
5263
  const { views, orientation, size, activeView } = serializedSplitview;
5228
- for (const [_, value] of this._panels.entries()) {
5229
- value.disposable.dispose();
5230
- value.value.dispose();
5231
- }
5232
- this._panels.clear();
5233
- this.splitview.dispose();
5234
5264
  const queue = [];
5235
5265
  this.splitview = new Splitview(this.element, {
5236
5266
  orientation,
@@ -5278,6 +5308,14 @@
5278
5308
  }
5279
5309
  this._onDidLayoutfromJSON.fire();
5280
5310
  }
5311
+ clear() {
5312
+ for (const [_, value] of this._panels.entries()) {
5313
+ value.disposable.dispose();
5314
+ value.value.dispose();
5315
+ }
5316
+ this._panels.clear();
5317
+ this.splitview.dispose();
5318
+ }
5281
5319
  dispose() {
5282
5320
  for (const [_, value] of this._panels.entries()) {
5283
5321
  value.disposable.dispose();
@@ -5527,8 +5565,9 @@
5527
5565
  }
5528
5566
 
5529
5567
  class DraggablePaneviewPanel extends PaneviewPanel {
5530
- constructor(id, component, headerComponent, orientation, isExpanded, disableDnd) {
5568
+ constructor(accessor, id, component, headerComponent, orientation, isExpanded, disableDnd) {
5531
5569
  super(id, component, headerComponent, orientation, isExpanded, true);
5570
+ this.accessor = accessor;
5532
5571
  this._onDidDrop = new Emitter();
5533
5572
  this.onDidDrop = this._onDidDrop.event;
5534
5573
  if (!disableDnd) {
@@ -5540,10 +5579,11 @@
5540
5579
  return;
5541
5580
  }
5542
5581
  const id = this.id;
5582
+ const accessorId = this.accessor.id;
5543
5583
  this.header.draggable = true;
5544
5584
  this.handler = new (class PaneDragHandler extends DragHandler {
5545
5585
  getData() {
5546
- LocalSelectionTransfer.getInstance().setData([new PaneTransfer('paneview', id)], PaneTransfer.prototype);
5586
+ LocalSelectionTransfer.getInstance().setData([new PaneTransfer(accessorId, id)], PaneTransfer.prototype);
5547
5587
  return {
5548
5588
  dispose: () => {
5549
5589
  LocalSelectionTransfer.getInstance().clearData(PaneTransfer.prototype);
@@ -5553,12 +5593,22 @@
5553
5593
  })(this.header);
5554
5594
  this.target = new Droptarget(this.element, {
5555
5595
  validOverlays: 'vertical',
5556
- canDisplayOverlay: () => {
5596
+ canDisplayOverlay: (event) => {
5557
5597
  const data = getPaneData();
5558
- if (!data) {
5559
- return true;
5598
+ if (data) {
5599
+ if (data.paneId !== this.id &&
5600
+ data.viewId === this.accessor.id) {
5601
+ return true;
5602
+ }
5560
5603
  }
5561
- return data.paneId !== this.id;
5604
+ if (this.accessor.options.showDndOverlay) {
5605
+ return this.accessor.options.showDndOverlay({
5606
+ nativeEvent: event,
5607
+ getData: getPaneData,
5608
+ panel: this,
5609
+ });
5610
+ }
5611
+ return false;
5562
5612
  },
5563
5613
  });
5564
5614
  this.addDisposables(this._onDidDrop, this.handler, this.target, this.target.onDrop((event) => {
@@ -5567,8 +5617,10 @@
5567
5617
  }
5568
5618
  onDrop(event) {
5569
5619
  const data = getPaneData();
5570
- if (!data) {
5571
- this._onDidDrop.fire(Object.assign(Object.assign({}, event), { panel: this, getData: () => getPaneData() }));
5620
+ if (!data || data.viewId !== this.accessor.id) {
5621
+ // if there is no local drag event for this panel
5622
+ // or if the drag event was creating by another Paneview instance
5623
+ this._onDidDrop.fire(Object.assign(Object.assign({}, event), { panel: this, getData: getPaneData }));
5572
5624
  return;
5573
5625
  }
5574
5626
  const containerApi = this._params
@@ -5576,7 +5628,8 @@
5576
5628
  const panelId = data.paneId;
5577
5629
  const existingPanel = containerApi.getPanel(panelId);
5578
5630
  if (!existingPanel) {
5579
- this._onDidDrop.fire(Object.assign(Object.assign({}, event), { panel: this, getData: () => getPaneData() }));
5631
+ // if the panel doesn't exist
5632
+ this._onDidDrop.fire(Object.assign(Object.assign({}, event), { panel: this, getData: getPaneData }));
5580
5633
  return;
5581
5634
  }
5582
5635
  const allPanels = containerApi.panels;
@@ -5600,15 +5653,18 @@
5600
5653
  class DefaultHeader extends CompositeDisposable {
5601
5654
  constructor() {
5602
5655
  super();
5656
+ this._expandedIcon = createExpandMoreButton();
5657
+ this._collapsedIcon = createChevronRightButton();
5603
5658
  this.disposable = new MutableDisposable();
5604
5659
  this.apiRef = { api: null };
5605
5660
  this._element = document.createElement('div');
5606
5661
  this.element.className = 'default-header';
5607
5662
  this._content = document.createElement('span');
5608
- this._expander = document.createElement('a');
5609
- this.element.appendChild(this._content);
5663
+ this._expander = document.createElement('div');
5664
+ this._expander.className = 'dockview-pane-header-icon';
5610
5665
  this.element.appendChild(this._expander);
5611
- this.addDisposables(addDisposableListener(this._expander, 'click', () => {
5666
+ this.element.appendChild(this._content);
5667
+ this.addDisposables(addDisposableListener(this._element, 'click', () => {
5612
5668
  var _a;
5613
5669
  (_a = this.apiRef.api) === null || _a === void 0 ? void 0 : _a.setExpanded(!this.apiRef.api.isExpanded);
5614
5670
  }));
@@ -5619,11 +5675,32 @@
5619
5675
  init(params) {
5620
5676
  this.apiRef.api = params.api;
5621
5677
  this._content.textContent = params.title;
5622
- this._expander.textContent = params.api.isExpanded ? '<' : '>';
5623
- this.disposable.value = params.api.onDidExpansionChange((e) => {
5624
- this._expander.textContent = e.isExpanded ? '<' : '>';
5678
+ this.updateIcon();
5679
+ this.disposable.value = params.api.onDidExpansionChange(() => {
5680
+ this.updateIcon();
5625
5681
  });
5626
5682
  }
5683
+ updateIcon() {
5684
+ var _a;
5685
+ const isExpanded = !!((_a = this.apiRef.api) === null || _a === void 0 ? void 0 : _a.isExpanded);
5686
+ toggleClass(this._expander, 'collapsed', !isExpanded);
5687
+ if (isExpanded) {
5688
+ if (this._expander.contains(this._collapsedIcon)) {
5689
+ this._collapsedIcon.remove();
5690
+ }
5691
+ if (!this._expander.contains(this._expandedIcon)) {
5692
+ this._expander.appendChild(this._expandedIcon);
5693
+ }
5694
+ }
5695
+ else {
5696
+ if (this._expander.contains(this._expandedIcon)) {
5697
+ this._expandedIcon.remove();
5698
+ }
5699
+ if (!this._expander.contains(this._collapsedIcon)) {
5700
+ this._expander.appendChild(this._collapsedIcon);
5701
+ }
5702
+ }
5703
+ }
5627
5704
  update(_params) {
5628
5705
  //
5629
5706
  }
@@ -5633,9 +5710,10 @@
5633
5710
  }
5634
5711
  }
5635
5712
 
5713
+ const nextLayoutId = sequentialNumberGenerator();
5636
5714
  class PaneFramework extends DraggablePaneviewPanel {
5637
5715
  constructor(options) {
5638
- super(options.id, options.component, options.headerComponent, options.orientation, options.isExpanded, options.disableDnd);
5716
+ super(options.accessor, options.id, options.component, options.headerComponent, options.orientation, options.isExpanded, options.disableDnd);
5639
5717
  this.options = options;
5640
5718
  }
5641
5719
  getBodyComponent() {
@@ -5649,6 +5727,7 @@
5649
5727
  constructor(element, options) {
5650
5728
  super();
5651
5729
  this.element = element;
5730
+ this._id = nextLayoutId.next();
5652
5731
  this._disposable = new MutableDisposable();
5653
5732
  this._viewDisposables = new Map();
5654
5733
  this._onDidLayoutfromJSON = new Emitter();
@@ -5675,6 +5754,9 @@
5675
5754
  });
5676
5755
  this.addDisposables(this._disposable);
5677
5756
  }
5757
+ get id() {
5758
+ return this._id;
5759
+ }
5678
5760
  get panels() {
5679
5761
  return this.paneview.getPanes();
5680
5762
  }
@@ -5739,6 +5821,7 @@
5739
5821
  orientation: exports.Orientation.VERTICAL,
5740
5822
  isExpanded: !!options.isExpanded,
5741
5823
  disableDnd: !!this.options.disableDnd,
5824
+ accessor: this,
5742
5825
  });
5743
5826
  this.doAddPanel(view);
5744
5827
  const size = typeof options.size === 'number' ? options.size : exports.Sizing.Distribute;
@@ -5797,13 +5880,9 @@
5797
5880
  };
5798
5881
  }
5799
5882
  fromJSON(serializedPaneview) {
5883
+ this.clear();
5800
5884
  const { views, size } = serializedPaneview;
5801
5885
  const queue = [];
5802
- for (const [_, value] of this._viewDisposables.entries()) {
5803
- value.dispose();
5804
- }
5805
- this._viewDisposables.clear();
5806
- this.paneview.dispose();
5807
5886
  this.paneview = new Paneview(this.element, {
5808
5887
  orientation: exports.Orientation.VERTICAL,
5809
5888
  descriptor: {
@@ -5837,6 +5916,7 @@
5837
5916
  orientation: exports.Orientation.VERTICAL,
5838
5917
  isExpanded: !!view.expanded,
5839
5918
  disableDnd: !!this.options.disableDnd,
5919
+ accessor: this,
5840
5920
  });
5841
5921
  this.doAddPanel(panel);
5842
5922
  queue.push(() => {
@@ -5862,6 +5942,13 @@
5862
5942
  queue.forEach((f) => f());
5863
5943
  this._onDidLayoutfromJSON.fire();
5864
5944
  }
5945
+ clear() {
5946
+ for (const [_, value] of this._viewDisposables.entries()) {
5947
+ value.dispose();
5948
+ }
5949
+ this._viewDisposables.clear();
5950
+ this.paneview.dispose();
5951
+ }
5865
5952
  doAddPanel(panel) {
5866
5953
  const disposable = panel.onDidDrop((event) => {
5867
5954
  this._onDidDrop.fire(event);
@@ -6029,15 +6116,21 @@
6029
6116
  this.component = component;
6030
6117
  this.parameters = parameters;
6031
6118
  this.context = context;
6119
+ this._initialProps = {};
6032
6120
  this.disposed = false;
6033
6121
  this.createPortal();
6034
6122
  }
6035
6123
  update(props) {
6036
- var _a;
6037
6124
  if (this.disposed) {
6038
6125
  throw new Error('invalid operation: resource is already disposed');
6039
6126
  }
6040
- (_a = this.componentInstance) === null || _a === void 0 ? void 0 : _a.update(props);
6127
+ if (!this.componentInstance) {
6128
+ // if the component is yet to be mounted store the props
6129
+ this._initialProps = Object.assign(Object.assign({}, this._initialProps), props);
6130
+ }
6131
+ else {
6132
+ this.componentInstance.update(props);
6133
+ }
6041
6134
  }
6042
6135
  createPortal() {
6043
6136
  if (this.disposed) {
@@ -6057,6 +6150,10 @@
6057
6150
  componentProps: this.parameters,
6058
6151
  ref: (element) => {
6059
6152
  this.componentInstance = element;
6153
+ if (Object.keys(this._initialProps).length > 0) {
6154
+ this.componentInstance.update(this._initialProps);
6155
+ this._initialProps = {}; // don't keep a reference to the users object once no longer required
6156
+ }
6060
6157
  },
6061
6158
  });
6062
6159
  const node = this.context
@@ -6113,30 +6210,19 @@
6113
6210
  this.onDidBlur = this._onDidBlur.event;
6114
6211
  this._element = document.createElement('div');
6115
6212
  this._element.className = 'dockview-react-part';
6116
- this._actionsElement = document.createElement('div');
6117
- this._actionsElement.className = 'dockview-react-part';
6118
6213
  }
6119
6214
  get element() {
6120
6215
  return this._element;
6121
6216
  }
6122
- get actions() {
6123
- return this._actionsElement;
6124
- }
6125
6217
  focus() {
6126
6218
  // TODO
6127
6219
  }
6128
6220
  init(parameters) {
6129
- const context = {
6130
- api: parameters.api,
6131
- containerApi: parameters.containerApi,
6132
- actionsPortalElement: this._actionsElement,
6133
- tabPortalElement: parameters.tab,
6134
- };
6135
6221
  this.part = new ReactPart(this.element, this.reactPortalStore, this.component, {
6136
6222
  params: parameters.params,
6137
6223
  api: parameters.api,
6138
6224
  containerApi: parameters.containerApi,
6139
- }, context);
6225
+ });
6140
6226
  }
6141
6227
  toJSON() {
6142
6228
  return {
@@ -6154,11 +6240,10 @@
6154
6240
  // noop
6155
6241
  }
6156
6242
  dispose() {
6157
- var _a, _b;
6243
+ var _a;
6158
6244
  this._onDidFocus.dispose();
6159
6245
  this._onDidBlur.dispose();
6160
6246
  (_a = this.part) === null || _a === void 0 ? void 0 : _a.dispose();
6161
- (_b = this.actionsPart) === null || _b === void 0 ? void 0 : _b.dispose();
6162
6247
  }
6163
6248
  }
6164
6249
 
@@ -6188,6 +6273,9 @@
6188
6273
  (_a = this.part) === null || _a === void 0 ? void 0 : _a.update(event.params);
6189
6274
  }
6190
6275
  toJSON() {
6276
+ if (this.id === DEFAULT_TAB_IDENTIFIER) {
6277
+ return {};
6278
+ }
6191
6279
  return {
6192
6280
  id: this.id,
6193
6281
  };
@@ -6209,17 +6297,25 @@
6209
6297
  this.layout = layout;
6210
6298
  }
6211
6299
  fromJSON(panelData, group) {
6212
- var _a, _b, _c;
6300
+ var _a, _b, _c, _d;
6213
6301
  const panelId = panelData.id;
6214
6302
  const params = panelData.params;
6215
6303
  const title = panelData.title;
6216
6304
  const suppressClosable = panelData.suppressClosable;
6217
6305
  const viewData = panelData.view;
6306
+ let tab;
6307
+ if ((_a = viewData.tab) === null || _a === void 0 ? void 0 : _a.id) {
6308
+ tab = createComponent(viewData.tab.id, viewData.tab.id, this.layout.options.tabComponents, this.layout.options.frameworkTabComponents, (_b = this.layout.options.frameworkComponentFactory) === null || _b === void 0 ? void 0 : _b.tab, () => new DefaultTab());
6309
+ }
6310
+ else if (this.layout.options.defaultTabComponent) {
6311
+ tab = createComponent(this.layout.options.defaultTabComponent, this.layout.options.defaultTabComponent, this.layout.options.tabComponents, this.layout.options.frameworkTabComponents, (_c = this.layout.options.frameworkComponentFactory) === null || _c === void 0 ? void 0 : _c.tab, () => new DefaultTab());
6312
+ }
6313
+ else {
6314
+ tab = new DefaultTab();
6315
+ }
6218
6316
  const view = new DefaultGroupPanelView({
6219
- content: createComponent(viewData.content.id, viewData.content.id, this.layout.options.components, this.layout.options.frameworkComponents, (_a = this.layout.options.frameworkComponentFactory) === null || _a === void 0 ? void 0 : _a.content),
6220
- tab: ((_b = viewData.tab) === null || _b === void 0 ? void 0 : _b.id)
6221
- ? createComponent(viewData.tab.id, viewData.tab.id, this.layout.options.tabComponents, this.layout.options.frameworkTabComponents, (_c = this.layout.options.frameworkComponentFactory) === null || _c === void 0 ? void 0 : _c.tab)
6222
- : new DefaultTab(),
6317
+ content: createComponent(viewData.content.id, viewData.content.id, this.layout.options.components, this.layout.options.frameworkComponents, (_d = this.layout.options.frameworkComponentFactory) === null || _d === void 0 ? void 0 : _d.content),
6318
+ tab,
6223
6319
  });
6224
6320
  const panel = new DockviewGroupPanel(panelId, this.layout, new DockviewApi(this.layout), group);
6225
6321
  panel.init({
@@ -6287,6 +6383,80 @@
6287
6383
  }
6288
6384
  }
6289
6385
 
6386
+ class ReactGroupControlsRendererPart {
6387
+ constructor(component, reactPortalStore, _group) {
6388
+ this.component = component;
6389
+ this.reactPortalStore = reactPortalStore;
6390
+ this._group = _group;
6391
+ this.mutableDisposable = new MutableDisposable();
6392
+ this._element = document.createElement('div');
6393
+ this._element.className = 'dockview-react-part';
6394
+ }
6395
+ get element() {
6396
+ return this._element;
6397
+ }
6398
+ get part() {
6399
+ return this._part;
6400
+ }
6401
+ get group() {
6402
+ return this._group;
6403
+ }
6404
+ focus() {
6405
+ // TODO
6406
+ }
6407
+ init(parameters) {
6408
+ this.mutableDisposable.value = new CompositeDisposable(this._group.model.onDidAddPanel(() => {
6409
+ this.updatePanels();
6410
+ }), this._group.model.onDidRemovePanel(() => {
6411
+ this.updatePanels();
6412
+ }), this._group.model.onDidActivePanelChange(() => {
6413
+ this.updateActivePanel();
6414
+ }), parameters.api.onDidActiveChange(() => {
6415
+ this.updateGroupActive();
6416
+ }));
6417
+ this._part = new ReactPart(this.element, this.reactPortalStore, this.component, {
6418
+ api: parameters.api,
6419
+ containerApi: parameters.containerApi,
6420
+ panels: this._group.model.panels,
6421
+ activePanel: this._group.model.activePanel,
6422
+ isGroupActive: this._group.api.isActive,
6423
+ });
6424
+ }
6425
+ update(event) {
6426
+ var _a;
6427
+ (_a = this._part) === null || _a === void 0 ? void 0 : _a.update(event.params);
6428
+ }
6429
+ dispose() {
6430
+ var _a;
6431
+ this.mutableDisposable.dispose();
6432
+ (_a = this._part) === null || _a === void 0 ? void 0 : _a.dispose();
6433
+ }
6434
+ updatePanels() {
6435
+ this.update({ params: { panels: this._group.model.panels } });
6436
+ }
6437
+ updateActivePanel() {
6438
+ this.update({
6439
+ params: {
6440
+ activePanel: this._group.model.activePanel,
6441
+ },
6442
+ });
6443
+ }
6444
+ updateGroupActive() {
6445
+ this.update({
6446
+ params: {
6447
+ isGroupActive: this._group.api.isActive,
6448
+ },
6449
+ });
6450
+ }
6451
+ }
6452
+
6453
+ function createGroupControlElement(component, store) {
6454
+ return component
6455
+ ? (groupPanel) => {
6456
+ return new ReactGroupControlsRendererPart(component, store, groupPanel);
6457
+ }
6458
+ : undefined;
6459
+ }
6290
6460
  const DockviewReact = React__namespace.forwardRef((props, ref) => {
6291
6461
  const domRef = React__namespace.useRef(null);
6292
6462
  const dockviewRef = React__namespace.useRef();
@@ -6336,12 +6506,15 @@
6336
6506
  const dockview = new DockviewComponent(element, {
6337
6507
  frameworkComponentFactory: factory,
6338
6508
  frameworkComponents: props.components,
6339
- frameworkTabComponents: props.tabComponents,
6509
+ frameworkTabComponents: Object.assign(Object.assign({}, (props.tabComponents || {})), { [DEFAULT_TAB_IDENTIFIER]: props.defaultTabComponent }),
6340
6510
  tabHeight: props.tabHeight,
6341
6511
  watermarkFrameworkComponent: props.watermarkComponent,
6512
+ defaultTabComponent: DEFAULT_TAB_IDENTIFIER,
6342
6513
  styles: props.hideBorders
6343
6514
  ? { separatorBorder: 'transparent' }
6344
6515
  : undefined,
6516
+ showDndOverlay: props.showDndOverlay,
6517
+ createGroupControlElement: createGroupControlElement(props.groupControlComponent, { addPortal }),
6345
6518
  });
6346
6519
  (_a = domRef.current) === null || _a === void 0 ? void 0 : _a.appendChild(dockview.element);
6347
6520
  dockview.deserializer = new ReactPanelDeserialzier(dockview);
@@ -6418,10 +6591,79 @@
6418
6591
  disposable.dispose();
6419
6592
  };
6420
6593
  }, [props.onTabContextMenu]);
6594
+ React__namespace.useEffect(() => {
6595
+ if (!dockviewRef.current) {
6596
+ return;
6597
+ }
6598
+ dockviewRef.current.updateOptions({
6599
+ defaultTabComponent: DEFAULT_TAB_IDENTIFIER,
6600
+ frameworkTabComponents: Object.assign(Object.assign({}, (props.tabComponents || {})), { [DEFAULT_TAB_IDENTIFIER]: props.defaultTabComponent }),
6601
+ });
6602
+ }, [props.defaultTabComponent]);
6603
+ React__namespace.useEffect(() => {
6604
+ if (!dockviewRef.current) {
6605
+ return;
6606
+ }
6607
+ dockviewRef.current.updateOptions({
6608
+ createGroupControlElement: createGroupControlElement(props.groupControlComponent, { addPortal }),
6609
+ });
6610
+ }, [props.groupControlComponent]);
6421
6611
  return (React__namespace.createElement("div", { className: props.className, style: { height: '100%', width: '100%' }, ref: domRef }, portals));
6422
6612
  });
6423
6613
  DockviewReact.displayName = 'DockviewComponent';
6424
6614
 
6615
+ /******************************************************************************
6616
+ Copyright (c) Microsoft Corporation.
6617
+
6618
+ Permission to use, copy, modify, and/or distribute this software for any
6619
+ purpose with or without fee is hereby granted.
6620
+
6621
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
6622
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
6623
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
6624
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
6625
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
6626
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
6627
+ PERFORMANCE OF THIS SOFTWARE.
6628
+ ***************************************************************************** */
6629
+
6630
+ function __rest(s, e) {
6631
+ var t = {};
6632
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
6633
+ t[p] = s[p];
6634
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6635
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
6636
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
6637
+ t[p[i]] = s[p[i]];
6638
+ }
6639
+ return t;
6640
+ }
6641
+
6642
+ const CloseButton = () => (React__namespace.createElement("svg", { height: "11", width: "11", viewBox: "0 0 28 28", "aria-hidden": 'false', focusable: false, className: "dockview-svg" },
6643
+ React__namespace.createElement("path", { d: "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" })));
6644
+
6645
+ const DockviewDefaultTab = (_a) => {
6646
+ var { api, containerApi: _containerApi, params: _params } = _a, rest = __rest(_a, ["api", "containerApi", "params"]);
6647
+ const onClose = React__namespace.useCallback((event) => {
6648
+ event.stopPropagation();
6649
+ api.close();
6650
+ }, [api]);
6651
+ const onClick = React__namespace.useCallback((event) => {
6652
+ api.setActive();
6653
+ if (rest.onClick) {
6654
+ rest.onClick(event);
6655
+ }
6656
+ }, [api, rest.onClick]);
6657
+ const iconClassname = React__namespace.useMemo(() => {
6658
+ const cn = ['dockview-react-tab-action'];
6659
+ return cn.join(',');
6660
+ }, [api.suppressClosable]);
6661
+ return (React__namespace.createElement("div", Object.assign({}, rest, { onClick: onClick, className: "dockview-react-tab" }),
6662
+ React__namespace.createElement("span", { className: "dockview-react-tab-title" }, api.title),
6663
+ React__namespace.createElement("div", { className: iconClassname, onClick: onClose },
6664
+ React__namespace.createElement(CloseButton, null))));
6665
+ };
6666
+
6425
6667
  class ReactPanelView extends SplitviewPanel {
6426
6668
  constructor(id, component, reactComponent, reactPortalStore) {
6427
6669
  super(id, component);
@@ -6651,6 +6893,7 @@
6651
6893
  createComponent,
6652
6894
  },
6653
6895
  },
6896
+ showDndOverlay: props.showDndOverlay,
6654
6897
  });
6655
6898
  const api = new PaneviewApi(paneview);
6656
6899
  const { clientWidth, clientHeight } = domRef.current;
@@ -6695,6 +6938,14 @@
6695
6938
  disposable.dispose();
6696
6939
  };
6697
6940
  }, [props.onDidDrop]);
6941
+ React__namespace.useEffect(() => {
6942
+ if (!paneviewRef.current) {
6943
+ return;
6944
+ }
6945
+ paneviewRef.current.updateOptions({
6946
+ showDndOverlay: props.showDndOverlay,
6947
+ });
6948
+ }, [props.showDndOverlay]);
6698
6949
  return (React__namespace.createElement("div", { className: props.className, style: { height: '100%', width: '100%' }, ref: domRef }, portals));
6699
6950
  });
6700
6951
  PaneviewReact.displayName = 'PaneviewComponent';
@@ -6703,6 +6954,7 @@
6703
6954
  exports.ContentContainer = ContentContainer;
6704
6955
  exports.DockviewApi = DockviewApi;
6705
6956
  exports.DockviewComponent = DockviewComponent;
6957
+ exports.DockviewDefaultTab = DockviewDefaultTab;
6706
6958
  exports.DockviewReact = DockviewReact;
6707
6959
  exports.Gridview = Gridview;
6708
6960
  exports.GridviewApi = GridviewApi;
@@ -6719,8 +6971,6 @@
6719
6971
  exports.PaneviewComponent = PaneviewComponent;
6720
6972
  exports.PaneviewPanel = PaneviewPanel;
6721
6973
  exports.PaneviewReact = PaneviewReact;
6722
- exports.ReactPanelContentPart = ReactPanelContentPart;
6723
- exports.ReactPanelHeaderPart = ReactPanelHeaderPart;
6724
6974
  exports.ReactPart = ReactPart;
6725
6975
  exports.ReactPartContext = ReactPartContext;
6726
6976
  exports.Splitview = Splitview;