dockview-core 1.12.0 → 1.13.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 (73) hide show
  1. package/dist/cjs/api/component.api.d.ts +2 -1
  2. package/dist/cjs/api/component.api.js +7 -0
  3. package/dist/cjs/api/dockviewGroupPanelApi.d.ts +5 -1
  4. package/dist/cjs/api/dockviewGroupPanelApi.js +19 -1
  5. package/dist/cjs/dnd/droptarget.d.ts +1 -1
  6. package/dist/cjs/dnd/droptarget.js +4 -10
  7. package/dist/cjs/dockview/components/panel/content.js +0 -8
  8. package/dist/cjs/dockview/dockviewComponent.d.ts +6 -4
  9. package/dist/cjs/dockview/dockviewComponent.js +73 -68
  10. package/dist/cjs/dockview/dockviewGroupPanelModel.d.ts +3 -0
  11. package/dist/cjs/dockview/dockviewGroupPanelModel.js +18 -19
  12. package/dist/cjs/dockview/dockviewPanelModel.js +21 -24
  13. package/dist/cjs/dockview/framework.d.ts +38 -0
  14. package/dist/cjs/dockview/framework.js +2 -0
  15. package/dist/cjs/dockview/options.d.ts +68 -46
  16. package/dist/cjs/dockview/options.js +43 -1
  17. package/dist/cjs/dockview/types.d.ts +4 -10
  18. package/dist/cjs/events.d.ts +13 -2
  19. package/dist/cjs/events.js +44 -12
  20. package/dist/cjs/framwork.d.ts +4 -0
  21. package/dist/cjs/framwork.js +2 -0
  22. package/dist/cjs/gridview/baseComponentGridview.d.ts +3 -4
  23. package/dist/cjs/gridview/baseComponentGridview.js +3 -7
  24. package/dist/cjs/index.d.ts +2 -1
  25. package/dist/cjs/index.js +1 -1
  26. package/dist/dockview-core.amd.js +2121 -2040
  27. package/dist/dockview-core.amd.js.map +1 -1
  28. package/dist/dockview-core.amd.min.js +2 -2
  29. package/dist/dockview-core.amd.min.js.map +1 -1
  30. package/dist/dockview-core.amd.min.noStyle.js +2 -2
  31. package/dist/dockview-core.amd.min.noStyle.js.map +1 -1
  32. package/dist/dockview-core.amd.noStyle.js +2121 -2040
  33. package/dist/dockview-core.amd.noStyle.js.map +1 -1
  34. package/dist/dockview-core.cjs.js +2121 -2040
  35. package/dist/dockview-core.cjs.js.map +1 -1
  36. package/dist/dockview-core.esm.js +2120 -2041
  37. package/dist/dockview-core.esm.js.map +1 -1
  38. package/dist/dockview-core.esm.min.js +2 -2
  39. package/dist/dockview-core.esm.min.js.map +1 -1
  40. package/dist/dockview-core.js +2121 -2040
  41. package/dist/dockview-core.js.map +1 -1
  42. package/dist/dockview-core.min.js +2 -2
  43. package/dist/dockview-core.min.js.map +1 -1
  44. package/dist/dockview-core.min.noStyle.js +2 -2
  45. package/dist/dockview-core.min.noStyle.js.map +1 -1
  46. package/dist/dockview-core.noStyle.js +2121 -2040
  47. package/dist/dockview-core.noStyle.js.map +1 -1
  48. package/dist/esm/api/component.api.d.ts +2 -1
  49. package/dist/esm/api/component.api.js +3 -0
  50. package/dist/esm/api/dockviewGroupPanelApi.d.ts +5 -1
  51. package/dist/esm/api/dockviewGroupPanelApi.js +18 -1
  52. package/dist/esm/dnd/droptarget.d.ts +1 -1
  53. package/dist/esm/dnd/droptarget.js +4 -10
  54. package/dist/esm/dockview/components/panel/content.js +0 -8
  55. package/dist/esm/dockview/dockviewComponent.d.ts +6 -4
  56. package/dist/esm/dockview/dockviewComponent.js +72 -69
  57. package/dist/esm/dockview/dockviewGroupPanelModel.d.ts +3 -0
  58. package/dist/esm/dockview/dockviewGroupPanelModel.js +18 -19
  59. package/dist/esm/dockview/dockviewPanelModel.js +21 -13
  60. package/dist/esm/dockview/framework.d.ts +38 -0
  61. package/dist/esm/dockview/framework.js +1 -0
  62. package/dist/esm/dockview/options.d.ts +68 -46
  63. package/dist/esm/dockview/options.js +36 -0
  64. package/dist/esm/dockview/types.d.ts +4 -10
  65. package/dist/esm/events.d.ts +13 -2
  66. package/dist/esm/events.js +37 -6
  67. package/dist/esm/framwork.d.ts +4 -0
  68. package/dist/esm/framwork.js +1 -0
  69. package/dist/esm/gridview/baseComponentGridview.d.ts +3 -4
  70. package/dist/esm/gridview/baseComponentGridview.js +4 -8
  71. package/dist/esm/index.d.ts +2 -1
  72. package/dist/esm/index.js +1 -1
  73. package/package.json +2 -2
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * dockview-core
3
- * @version 1.12.0
3
+ * @version 1.13.1
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -254,18 +254,49 @@
254
254
  },
255
255
  };
256
256
  }
257
- class TickDelayedEvent {
257
+ /**
258
+ *
259
+ * Event Emitter that fires events from a Microtask callback, only one event will fire per event-loop cycle.
260
+ *
261
+ * It's kind of like using an `asapScheduler` in RxJs with additional logic to only fire once per event-loop cycle.
262
+ * This implementation exists to avoid external dependencies.
263
+ *
264
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/queueMicrotask
265
+ * @see https://rxjs.dev/api/index/const/asapScheduler
266
+ */
267
+ class AsapEvent {
258
268
  constructor() {
259
269
  this._onFired = new Emitter();
260
- this.onEvent = this._onFired.event;
270
+ this._currentFireCount = 0;
271
+ this._queued = false;
272
+ this.onEvent = (e) => {
273
+ /**
274
+ * when the event is first subscribed to take note of the current fire count
275
+ */
276
+ const fireCountAtTimeOfEventSubscription = this._currentFireCount;
277
+ return this._onFired.event(() => {
278
+ /**
279
+ * if the current fire count is greater than the fire count at event subscription
280
+ * then the event has been fired since we subscribed and it's ok to "on_next" the event.
281
+ *
282
+ * if the count is not greater then what we are recieving is an event from the microtask
283
+ * queue that was triggered before we actually subscribed and therfore we should ignore it.
284
+ */
285
+ if (this._currentFireCount > fireCountAtTimeOfEventSubscription) {
286
+ e();
287
+ }
288
+ });
289
+ };
261
290
  }
262
291
  fire() {
263
- if (this.timer) {
264
- clearTimeout(this.timer);
292
+ this._currentFireCount++;
293
+ if (this._queued) {
294
+ return;
265
295
  }
266
- this.timer = setTimeout(() => {
296
+ this._queued = true;
297
+ queueMicrotask(() => {
298
+ this._queued = false;
267
299
  this._onFired.fire();
268
- clearTimeout(this.timer);
269
300
  });
270
301
  }
271
302
  dispose() {
@@ -2472,143 +2503,394 @@
2472
2503
  }
2473
2504
  }
2474
2505
 
2475
- class SplitviewApi {
2476
- /**
2477
- * The minimum size the component can reach where size is measured in the direction of orientation provided.
2478
- */
2479
- get minimumSize() {
2480
- return this.component.minimumSize;
2506
+ class Resizable extends CompositeDisposable {
2507
+ get element() {
2508
+ return this._element;
2481
2509
  }
2482
- /**
2483
- * The maximum size the component can reach where size is measured in the direction of orientation provided.
2484
- */
2485
- get maximumSize() {
2486
- return this.component.maximumSize;
2510
+ get disableResizing() {
2511
+ return this._disableResizing;
2487
2512
  }
2488
- /**
2489
- * Width of the component.
2490
- */
2491
- get width() {
2492
- return this.component.width;
2513
+ set disableResizing(value) {
2514
+ this._disableResizing = value;
2493
2515
  }
2494
- /**
2495
- * Height of the component.
2496
- */
2497
- get height() {
2498
- return this.component.height;
2516
+ constructor(parentElement, disableResizing = false) {
2517
+ super();
2518
+ this._disableResizing = disableResizing;
2519
+ this._element = parentElement;
2520
+ this.addDisposables(watchElementResize(this._element, (entry) => {
2521
+ if (this.isDisposed) {
2522
+ /**
2523
+ * resize is delayed through requestAnimationFrame so there is a small chance
2524
+ * the component has already been disposed of
2525
+ */
2526
+ return;
2527
+ }
2528
+ if (this.disableResizing) {
2529
+ return;
2530
+ }
2531
+ if (!this._element.offsetParent) {
2532
+ /**
2533
+ * offsetParent === null is equivalent to display: none being set on the element or one
2534
+ * of it's parents. In the display: none case the size will become (0, 0) which we do
2535
+ * not want to propagate.
2536
+ *
2537
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetParent
2538
+ *
2539
+ * You could use checkVisibility() but at the time of writing it's not supported across
2540
+ * all Browsers
2541
+ *
2542
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility
2543
+ */
2544
+ return;
2545
+ }
2546
+ if (!isInDocument(this._element)) {
2547
+ /**
2548
+ * since the event is dispatched through requestAnimationFrame there is a small chance
2549
+ * the component is no longer attached to the DOM, if that is the case the dimensions
2550
+ * are mostly likely all zero and meaningless. we should skip this case.
2551
+ */
2552
+ return;
2553
+ }
2554
+ const { width, height } = entry.contentRect;
2555
+ this.layout(width, height);
2556
+ }));
2499
2557
  }
2500
- /**
2501
- * The current number of panels.
2502
- */
2503
- get length() {
2504
- return this.component.length;
2558
+ }
2559
+
2560
+ const nextLayoutId$1 = sequentialNumberGenerator();
2561
+ function toTarget(direction) {
2562
+ switch (direction) {
2563
+ case 'left':
2564
+ return 'left';
2565
+ case 'right':
2566
+ return 'right';
2567
+ case 'above':
2568
+ return 'top';
2569
+ case 'below':
2570
+ return 'bottom';
2571
+ case 'within':
2572
+ default:
2573
+ return 'center';
2505
2574
  }
2506
- /**
2507
- * The current orientation of the component.
2508
- */
2509
- get orientation() {
2510
- return this.component.orientation;
2575
+ }
2576
+ class BaseGrid extends Resizable {
2577
+ get id() {
2578
+ return this._id;
2511
2579
  }
2512
- /**
2513
- * The list of current panels.
2514
- */
2515
- get panels() {
2516
- return this.component.panels;
2580
+ get size() {
2581
+ return this._groups.size;
2517
2582
  }
2518
- /**
2519
- * Invoked after a layout is loaded through the `fromJSON` method.
2520
- */
2521
- get onDidLayoutFromJSON() {
2522
- return this.component.onDidLayoutFromJSON;
2583
+ get groups() {
2584
+ return Array.from(this._groups.values()).map((_) => _.value);
2523
2585
  }
2524
- /**
2525
- * Invoked whenever any aspect of the layout changes.
2526
- * If listening to this event it may be worth debouncing ouputs.
2527
- */
2528
- get onDidLayoutChange() {
2529
- return this.component.onDidLayoutChange;
2586
+ get width() {
2587
+ return this.gridview.width;
2530
2588
  }
2531
- /**
2532
- * Invoked when a view is added.
2533
- */
2534
- get onDidAddView() {
2535
- return this.component.onDidAddView;
2589
+ get height() {
2590
+ return this.gridview.height;
2536
2591
  }
2537
- /**
2538
- * Invoked when a view is removed.
2539
- */
2540
- get onDidRemoveView() {
2541
- return this.component.onDidRemoveView;
2592
+ get minimumHeight() {
2593
+ return this.gridview.minimumHeight;
2542
2594
  }
2543
- constructor(component) {
2544
- this.component = component;
2595
+ get maximumHeight() {
2596
+ return this.gridview.maximumHeight;
2545
2597
  }
2546
- /**
2547
- * Update configuratable options.
2548
- */
2549
- updateOptions(options) {
2550
- this.component.updateOptions(options);
2598
+ get minimumWidth() {
2599
+ return this.gridview.minimumWidth;
2551
2600
  }
2552
- /**
2553
- * Removes an existing panel and optionally provide a `Sizing` method
2554
- * for the subsequent resize.
2555
- */
2556
- removePanel(panel, sizing) {
2557
- this.component.removePanel(panel, sizing);
2601
+ get maximumWidth() {
2602
+ return this.gridview.maximumWidth;
2558
2603
  }
2559
- /**
2560
- * Focus the component.
2561
- */
2562
- focus() {
2563
- this.component.focus();
2604
+ get activeGroup() {
2605
+ return this._activeGroup;
2564
2606
  }
2565
- /**
2566
- * Get the reference to a panel given it's `string` id.
2567
- */
2568
- getPanel(id) {
2569
- return this.component.getPanel(id);
2607
+ get locked() {
2608
+ return this.gridview.locked;
2570
2609
  }
2571
- /**
2572
- * Layout the panel with a width and height.
2573
- */
2574
- layout(width, height) {
2575
- return this.component.layout(width, height);
2610
+ set locked(value) {
2611
+ this.gridview.locked = value;
2576
2612
  }
2577
- /**
2578
- * Add a new panel and return the created instance.
2579
- */
2580
- addPanel(options) {
2581
- return this.component.addPanel(options);
2613
+ constructor(options) {
2614
+ super(document.createElement('div'), options.disableAutoResizing);
2615
+ this._id = nextLayoutId$1.next();
2616
+ this._groups = new Map();
2617
+ this._onDidRemove = new Emitter();
2618
+ this.onDidRemove = this._onDidRemove.event;
2619
+ this._onDidAdd = new Emitter();
2620
+ this.onDidAdd = this._onDidAdd.event;
2621
+ this._onDidActiveChange = new Emitter();
2622
+ this.onDidActiveChange = this._onDidActiveChange.event;
2623
+ this._bufferOnDidLayoutChange = new AsapEvent();
2624
+ this.onDidLayoutChange = this._bufferOnDidLayoutChange.onEvent;
2625
+ this.element.style.height = '100%';
2626
+ this.element.style.width = '100%';
2627
+ options.parentElement.appendChild(this.element);
2628
+ this.gridview = new Gridview(!!options.proportionalLayout, options.styles, options.orientation);
2629
+ this.gridview.locked = !!options.locked;
2630
+ this.element.appendChild(this.gridview.element);
2631
+ this.layout(0, 0, true); // set some elements height/widths
2632
+ this.addDisposables(Disposable.from(() => {
2633
+ var _a;
2634
+ (_a = this.element.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(this.element);
2635
+ }), this.gridview.onDidChange(() => {
2636
+ this._bufferOnDidLayoutChange.fire();
2637
+ }), exports.DockviewEvent.any(this.onDidAdd, this.onDidRemove, this.onDidActiveChange)(() => {
2638
+ this._bufferOnDidLayoutChange.fire();
2639
+ }), this._bufferOnDidLayoutChange);
2582
2640
  }
2583
- /**
2584
- * Move a panel given it's current and desired index.
2585
- */
2586
- movePanel(from, to) {
2587
- this.component.movePanel(from, to);
2641
+ setVisible(panel, visible) {
2642
+ this.gridview.setViewVisible(getGridLocation(panel.element), visible);
2643
+ this._bufferOnDidLayoutChange.fire();
2588
2644
  }
2589
- /**
2590
- * Deserialize a layout to built a splitivew.
2591
- */
2592
- fromJSON(data) {
2593
- this.component.fromJSON(data);
2645
+ isVisible(panel) {
2646
+ return this.gridview.isViewVisible(getGridLocation(panel.element));
2594
2647
  }
2595
- /** Serialize a layout */
2596
- toJSON() {
2597
- return this.component.toJSON();
2648
+ maximizeGroup(panel) {
2649
+ this.gridview.maximizeView(panel);
2650
+ this.doSetGroupActive(panel);
2598
2651
  }
2599
- /**
2600
- * Remove all panels and clear the component.
2601
- */
2602
- clear() {
2603
- this.component.clear();
2652
+ isMaximizedGroup(panel) {
2653
+ return this.gridview.maximizedView() === panel;
2604
2654
  }
2605
- }
2606
- class PaneviewApi {
2607
- /**
2608
- * The minimum size the component can reach where size is measured in the direction of orientation provided.
2609
- */
2610
- get minimumSize() {
2611
- return this.component.minimumSize;
2655
+ exitMaximizedGroup() {
2656
+ this.gridview.exitMaximizedView();
2657
+ }
2658
+ hasMaximizedGroup() {
2659
+ return this.gridview.hasMaximizedView();
2660
+ }
2661
+ get onDidMaximizedGroupChange() {
2662
+ return this.gridview.onDidMaximizedNodeChange;
2663
+ }
2664
+ doAddGroup(group, location = [0], size) {
2665
+ this.gridview.addView(group, size !== null && size !== void 0 ? size : exports.Sizing.Distribute, location);
2666
+ this._onDidAdd.fire(group);
2667
+ }
2668
+ doRemoveGroup(group, options) {
2669
+ if (!this._groups.has(group.id)) {
2670
+ throw new Error('invalid operation');
2671
+ }
2672
+ const item = this._groups.get(group.id);
2673
+ const view = this.gridview.remove(group, exports.Sizing.Distribute);
2674
+ if (item && !(options === null || options === void 0 ? void 0 : options.skipDispose)) {
2675
+ item.disposable.dispose();
2676
+ item.value.dispose();
2677
+ this._groups.delete(group.id);
2678
+ this._onDidRemove.fire(group);
2679
+ }
2680
+ if (!(options === null || options === void 0 ? void 0 : options.skipActive) && this._activeGroup === group) {
2681
+ const groups = Array.from(this._groups.values());
2682
+ this.doSetGroupActive(groups.length > 0 ? groups[0].value : undefined);
2683
+ }
2684
+ return view;
2685
+ }
2686
+ getPanel(id) {
2687
+ var _a;
2688
+ return (_a = this._groups.get(id)) === null || _a === void 0 ? void 0 : _a.value;
2689
+ }
2690
+ doSetGroupActive(group) {
2691
+ if (this._activeGroup === group) {
2692
+ return;
2693
+ }
2694
+ if (this._activeGroup) {
2695
+ this._activeGroup.setActive(false);
2696
+ }
2697
+ if (group) {
2698
+ group.setActive(true);
2699
+ }
2700
+ this._activeGroup = group;
2701
+ this._onDidActiveChange.fire(group);
2702
+ }
2703
+ removeGroup(group) {
2704
+ this.doRemoveGroup(group);
2705
+ }
2706
+ moveToNext(options) {
2707
+ var _a;
2708
+ if (!options) {
2709
+ options = {};
2710
+ }
2711
+ if (!options.group) {
2712
+ if (!this.activeGroup) {
2713
+ return;
2714
+ }
2715
+ options.group = this.activeGroup;
2716
+ }
2717
+ const location = getGridLocation(options.group.element);
2718
+ const next = (_a = this.gridview.next(location)) === null || _a === void 0 ? void 0 : _a.view;
2719
+ this.doSetGroupActive(next);
2720
+ }
2721
+ moveToPrevious(options) {
2722
+ var _a;
2723
+ if (!options) {
2724
+ options = {};
2725
+ }
2726
+ if (!options.group) {
2727
+ if (!this.activeGroup) {
2728
+ return;
2729
+ }
2730
+ options.group = this.activeGroup;
2731
+ }
2732
+ const location = getGridLocation(options.group.element);
2733
+ const next = (_a = this.gridview.previous(location)) === null || _a === void 0 ? void 0 : _a.view;
2734
+ this.doSetGroupActive(next);
2735
+ }
2736
+ layout(width, height, forceResize) {
2737
+ const different = forceResize !== null && forceResize !== void 0 ? forceResize : (width !== this.width || height !== this.height);
2738
+ if (!different) {
2739
+ return;
2740
+ }
2741
+ this.gridview.element.style.height = `${height}px`;
2742
+ this.gridview.element.style.width = `${width}px`;
2743
+ this.gridview.layout(width, height);
2744
+ }
2745
+ dispose() {
2746
+ this._onDidActiveChange.dispose();
2747
+ this._onDidAdd.dispose();
2748
+ this._onDidRemove.dispose();
2749
+ for (const group of this.groups) {
2750
+ group.dispose();
2751
+ }
2752
+ this.gridview.dispose();
2753
+ super.dispose();
2754
+ }
2755
+ }
2756
+
2757
+ class SplitviewApi {
2758
+ /**
2759
+ * The minimum size the component can reach where size is measured in the direction of orientation provided.
2760
+ */
2761
+ get minimumSize() {
2762
+ return this.component.minimumSize;
2763
+ }
2764
+ /**
2765
+ * The maximum size the component can reach where size is measured in the direction of orientation provided.
2766
+ */
2767
+ get maximumSize() {
2768
+ return this.component.maximumSize;
2769
+ }
2770
+ /**
2771
+ * Width of the component.
2772
+ */
2773
+ get width() {
2774
+ return this.component.width;
2775
+ }
2776
+ /**
2777
+ * Height of the component.
2778
+ */
2779
+ get height() {
2780
+ return this.component.height;
2781
+ }
2782
+ /**
2783
+ * The current number of panels.
2784
+ */
2785
+ get length() {
2786
+ return this.component.length;
2787
+ }
2788
+ /**
2789
+ * The current orientation of the component.
2790
+ */
2791
+ get orientation() {
2792
+ return this.component.orientation;
2793
+ }
2794
+ /**
2795
+ * The list of current panels.
2796
+ */
2797
+ get panels() {
2798
+ return this.component.panels;
2799
+ }
2800
+ /**
2801
+ * Invoked after a layout is loaded through the `fromJSON` method.
2802
+ */
2803
+ get onDidLayoutFromJSON() {
2804
+ return this.component.onDidLayoutFromJSON;
2805
+ }
2806
+ /**
2807
+ * Invoked whenever any aspect of the layout changes.
2808
+ * If listening to this event it may be worth debouncing ouputs.
2809
+ */
2810
+ get onDidLayoutChange() {
2811
+ return this.component.onDidLayoutChange;
2812
+ }
2813
+ /**
2814
+ * Invoked when a view is added.
2815
+ */
2816
+ get onDidAddView() {
2817
+ return this.component.onDidAddView;
2818
+ }
2819
+ /**
2820
+ * Invoked when a view is removed.
2821
+ */
2822
+ get onDidRemoveView() {
2823
+ return this.component.onDidRemoveView;
2824
+ }
2825
+ constructor(component) {
2826
+ this.component = component;
2827
+ }
2828
+ /**
2829
+ * Update configuratable options.
2830
+ */
2831
+ updateOptions(options) {
2832
+ this.component.updateOptions(options);
2833
+ }
2834
+ /**
2835
+ * Removes an existing panel and optionally provide a `Sizing` method
2836
+ * for the subsequent resize.
2837
+ */
2838
+ removePanel(panel, sizing) {
2839
+ this.component.removePanel(panel, sizing);
2840
+ }
2841
+ /**
2842
+ * Focus the component.
2843
+ */
2844
+ focus() {
2845
+ this.component.focus();
2846
+ }
2847
+ /**
2848
+ * Get the reference to a panel given it's `string` id.
2849
+ */
2850
+ getPanel(id) {
2851
+ return this.component.getPanel(id);
2852
+ }
2853
+ /**
2854
+ * Layout the panel with a width and height.
2855
+ */
2856
+ layout(width, height) {
2857
+ return this.component.layout(width, height);
2858
+ }
2859
+ /**
2860
+ * Add a new panel and return the created instance.
2861
+ */
2862
+ addPanel(options) {
2863
+ return this.component.addPanel(options);
2864
+ }
2865
+ /**
2866
+ * Move a panel given it's current and desired index.
2867
+ */
2868
+ movePanel(from, to) {
2869
+ this.component.movePanel(from, to);
2870
+ }
2871
+ /**
2872
+ * Deserialize a layout to built a splitivew.
2873
+ */
2874
+ fromJSON(data) {
2875
+ this.component.fromJSON(data);
2876
+ }
2877
+ /** Serialize a layout */
2878
+ toJSON() {
2879
+ return this.component.toJSON();
2880
+ }
2881
+ /**
2882
+ * Remove all panels and clear the component.
2883
+ */
2884
+ clear() {
2885
+ this.component.clear();
2886
+ }
2887
+ }
2888
+ class PaneviewApi {
2889
+ /**
2890
+ * The minimum size the component can reach where size is measured in the direction of orientation provided.
2891
+ */
2892
+ get minimumSize() {
2893
+ return this.component.minimumSize;
2612
2894
  }
2613
2895
  /**
2614
2896
  * The maximum size the component can reach where size is measured in the direction of orientation provided.
@@ -3014,6 +3296,9 @@
3014
3296
  get onWillDragPanel() {
3015
3297
  return this.component.onWillDragPanel;
3016
3298
  }
3299
+ get onUnhandledDragOverEvent() {
3300
+ return this.component.onUnhandledDragOverEvent;
3301
+ }
3017
3302
  /**
3018
3303
  * All panel objects.
3019
3304
  */
@@ -3151,17 +3436,78 @@
3151
3436
  }
3152
3437
  }
3153
3438
 
3154
- class DragAndDropObserver extends CompositeDisposable {
3155
- constructor(element, callbacks) {
3439
+ class DragHandler extends CompositeDisposable {
3440
+ constructor(el) {
3156
3441
  super();
3157
- this.element = element;
3158
- this.callbacks = callbacks;
3159
- this.target = null;
3160
- this.registerListeners();
3442
+ this.el = el;
3443
+ this.dataDisposable = new MutableDisposable();
3444
+ this.pointerEventsDisposable = new MutableDisposable();
3445
+ this._onDragStart = new Emitter();
3446
+ this.onDragStart = this._onDragStart.event;
3447
+ this.addDisposables(this._onDragStart, this.dataDisposable, this.pointerEventsDisposable);
3448
+ this.configure();
3161
3449
  }
3162
- onDragEnter(e) {
3163
- this.target = e.target;
3164
- this.callbacks.onDragEnter(e);
3450
+ isCancelled(_event) {
3451
+ return false;
3452
+ }
3453
+ configure() {
3454
+ this.addDisposables(this._onDragStart, addDisposableListener(this.el, 'dragstart', (event) => {
3455
+ if (event.defaultPrevented || this.isCancelled(event)) {
3456
+ event.preventDefault();
3457
+ return;
3458
+ }
3459
+ const iframes = [
3460
+ ...getElementsByTagName('iframe'),
3461
+ ...getElementsByTagName('webview'),
3462
+ ];
3463
+ this.pointerEventsDisposable.value = {
3464
+ dispose: () => {
3465
+ for (const iframe of iframes) {
3466
+ iframe.style.pointerEvents = 'auto';
3467
+ }
3468
+ },
3469
+ };
3470
+ for (const iframe of iframes) {
3471
+ iframe.style.pointerEvents = 'none';
3472
+ }
3473
+ this.el.classList.add('dv-dragged');
3474
+ setTimeout(() => this.el.classList.remove('dv-dragged'), 0);
3475
+ this.dataDisposable.value = this.getData(event);
3476
+ this._onDragStart.fire(event);
3477
+ if (event.dataTransfer) {
3478
+ event.dataTransfer.effectAllowed = 'move';
3479
+ const hasData = event.dataTransfer.items.length > 0;
3480
+ if (!hasData) {
3481
+ /**
3482
+ * Although this is not used by dockview many third party dnd libraries will check
3483
+ * dataTransfer.types to determine valid drag events.
3484
+ *
3485
+ * For example: in react-dnd if dataTransfer.types is not set then the dragStart event will be cancelled
3486
+ * through .preventDefault(). Since this is applied globally to all drag events this would break dockviews
3487
+ * dnd logic. You can see the code at
3488
+ * https://github.com/react-dnd/react-dnd/blob/main/packages/backend-html5/src/HTML5BackendImpl.ts#L542
3489
+ */
3490
+ event.dataTransfer.setData('text/plain', '__dockview_internal_drag_event__');
3491
+ }
3492
+ }
3493
+ }), addDisposableListener(this.el, 'dragend', () => {
3494
+ this.pointerEventsDisposable.dispose();
3495
+ this.dataDisposable.dispose();
3496
+ }));
3497
+ }
3498
+ }
3499
+
3500
+ class DragAndDropObserver extends CompositeDisposable {
3501
+ constructor(element, callbacks) {
3502
+ super();
3503
+ this.element = element;
3504
+ this.callbacks = callbacks;
3505
+ this.target = null;
3506
+ this.registerListeners();
3507
+ }
3508
+ onDragEnter(e) {
3509
+ this.target = e.target;
3510
+ this.callbacks.onDragEnter(e);
3165
3511
  }
3166
3512
  onDragOver(e) {
3167
3513
  e.preventDefault(); // needed so that the drop event fires (https://stackoverflow.com/questions/21339924/drop-event-not-firing-in-chrome)
@@ -3295,6 +3641,10 @@
3295
3641
  this.removeDropTarget();
3296
3642
  return;
3297
3643
  }
3644
+ if (!this.options.canDisplayOverlay(e, quadrant)) {
3645
+ this.removeDropTarget();
3646
+ return;
3647
+ }
3298
3648
  const willShowOverlayEvent = new WillShowOverlayEvent({
3299
3649
  nativeEvent: e,
3300
3650
  position: quadrant,
@@ -3308,16 +3658,6 @@
3308
3658
  this.removeDropTarget();
3309
3659
  return;
3310
3660
  }
3311
- if (typeof this.options.canDisplayOverlay === 'boolean') {
3312
- if (!this.options.canDisplayOverlay) {
3313
- this.removeDropTarget();
3314
- return;
3315
- }
3316
- }
3317
- else if (!this.options.canDisplayOverlay(e, quadrant)) {
3318
- this.removeDropTarget();
3319
- return;
3320
- }
3321
3661
  this.markAsUsed(e);
3322
3662
  if (!this.targetElement) {
3323
3663
  this.targetElement = document.createElement('div');
@@ -3508,2023 +3848,1758 @@
3508
3848
  return 'center';
3509
3849
  }
3510
3850
 
3511
- class ContentContainer extends CompositeDisposable {
3512
- get element() {
3513
- return this._element;
3514
- }
3515
- constructor(accessor, group) {
3851
+ class WillFocusEvent extends DockviewEvent {
3852
+ constructor() {
3516
3853
  super();
3517
- this.accessor = accessor;
3518
- this.group = group;
3519
- this.disposable = new MutableDisposable();
3520
- this._onDidFocus = new Emitter();
3521
- this.onDidFocus = this._onDidFocus.event;
3522
- this._onDidBlur = new Emitter();
3523
- this.onDidBlur = this._onDidBlur.event;
3524
- this._element = document.createElement('div');
3525
- this._element.className = 'content-container';
3526
- this._element.tabIndex = -1;
3527
- this.addDisposables(this._onDidFocus, this._onDidBlur);
3528
- this.dropTarget = new Droptarget(this.element, {
3529
- acceptedTargetZones: ['top', 'bottom', 'left', 'right', 'center'],
3530
- canDisplayOverlay: (event, position) => {
3531
- if (this.group.locked === 'no-drop-target' ||
3532
- (this.group.locked && position === 'center')) {
3533
- return false;
3534
- }
3535
- const data = getPanelData();
3536
- if (!data &&
3537
- event.shiftKey &&
3538
- this.group.location.type !== 'floating') {
3539
- return false;
3540
- }
3541
- if (data && data.viewId === this.accessor.id) {
3542
- if (data.groupId === this.group.id) {
3543
- if (position === 'center') {
3544
- // don't allow to drop on self for center position
3545
- return false;
3546
- }
3547
- if (data.panelId === null) {
3548
- // don't allow group move to drop anywhere on self
3549
- return false;
3550
- }
3551
- }
3552
- const groupHasOnePanelAndIsActiveDragElement = this.group.panels.length === 1 &&
3553
- data.groupId === this.group.id;
3554
- return !groupHasOnePanelAndIsActiveDragElement;
3555
- }
3556
- return this.group.canDisplayOverlay(event, position, 'content');
3557
- },
3558
- });
3559
- this.addDisposables(this.dropTarget);
3560
3854
  }
3561
- show() {
3562
- this.element.style.display = '';
3855
+ }
3856
+ /**
3857
+ * A core api implementation that should be used across all panel-like objects
3858
+ */
3859
+ class PanelApiImpl extends CompositeDisposable {
3860
+ get isFocused() {
3861
+ return this._isFocused;
3563
3862
  }
3564
- hide() {
3565
- this.element.style.display = 'none';
3863
+ get isActive() {
3864
+ return this._isActive;
3566
3865
  }
3567
- renderPanel(panel, options = { asActive: true }) {
3568
- const doRender = options.asActive ||
3569
- (this.panel && this.group.isPanelActive(this.panel));
3570
- if (this.panel &&
3571
- this.panel.view.content.element.parentElement === this._element) {
3572
- /**
3573
- * If the currently attached panel is mounted directly to the content then remove it
3574
- */
3575
- this._element.removeChild(this.panel.view.content.element);
3576
- }
3577
- this.panel = panel;
3578
- let container;
3579
- switch (panel.api.renderer) {
3580
- case 'onlyWhenVisible':
3581
- this.group.renderContainer.detatch(panel);
3582
- if (this.panel) {
3583
- if (doRender) {
3584
- this._element.appendChild(this.panel.view.content.element);
3585
- }
3586
- }
3587
- container = this._element;
3588
- break;
3589
- case 'always':
3590
- if (panel.view.content.element.parentElement === this._element) {
3591
- this._element.removeChild(panel.view.content.element);
3592
- }
3593
- container = this.group.renderContainer.attach({
3594
- panel,
3595
- referenceContainer: this,
3596
- });
3597
- break;
3598
- }
3599
- if (doRender) {
3600
- const _onDidFocus = panel.view.content.onDidFocus;
3601
- const _onDidBlur = panel.view.content.onDidBlur;
3602
- const focusTracker = trackFocus(container);
3603
- const disposable = new CompositeDisposable();
3604
- disposable.addDisposables(focusTracker, focusTracker.onDidFocus(() => this._onDidFocus.fire()), focusTracker.onDidBlur(() => this._onDidBlur.fire()));
3605
- if (_onDidFocus) {
3606
- disposable.addDisposables(_onDidFocus(() => this._onDidFocus.fire()));
3607
- }
3608
- if (_onDidBlur) {
3609
- disposable.addDisposables(_onDidBlur(() => this._onDidBlur.fire()));
3610
- }
3611
- this.disposable.value = disposable;
3612
- }
3866
+ get isVisible() {
3867
+ return this._isVisible;
3613
3868
  }
3614
- openPanel(panel) {
3615
- if (this.panel === panel) {
3616
- return;
3617
- }
3618
- this.renderPanel(panel);
3869
+ get width() {
3870
+ return this._width;
3619
3871
  }
3620
- layout(_width, _height) {
3621
- // noop
3872
+ get height() {
3873
+ return this._height;
3622
3874
  }
3623
- closePanel() {
3624
- var _a;
3625
- if (this.panel) {
3626
- if (this.panel.api.renderer === 'onlyWhenVisible') {
3627
- (_a = this.panel.view.content.element.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(this.panel.view.content.element);
3628
- }
3629
- }
3630
- this.panel = undefined;
3875
+ constructor(id, component) {
3876
+ super();
3877
+ this.id = id;
3878
+ this.component = component;
3879
+ this._isFocused = false;
3880
+ this._isActive = false;
3881
+ this._isVisible = true;
3882
+ this._width = 0;
3883
+ this._height = 0;
3884
+ this._parameters = {};
3885
+ this.panelUpdatesDisposable = new MutableDisposable();
3886
+ this._onDidDimensionChange = new Emitter();
3887
+ this.onDidDimensionsChange = this._onDidDimensionChange.event;
3888
+ this._onDidChangeFocus = new Emitter();
3889
+ this.onDidFocusChange = this._onDidChangeFocus.event;
3890
+ //
3891
+ this._onWillFocus = new Emitter();
3892
+ this.onWillFocus = this._onWillFocus.event;
3893
+ //
3894
+ this._onDidVisibilityChange = new Emitter();
3895
+ this.onDidVisibilityChange = this._onDidVisibilityChange.event;
3896
+ this._onWillVisibilityChange = new Emitter();
3897
+ this.onWillVisibilityChange = this._onWillVisibilityChange.event;
3898
+ this._onDidActiveChange = new Emitter();
3899
+ this.onDidActiveChange = this._onDidActiveChange.event;
3900
+ this._onActiveChange = new Emitter();
3901
+ this.onActiveChange = this._onActiveChange.event;
3902
+ this._onDidParametersChange = new Emitter();
3903
+ this.onDidParametersChange = this._onDidParametersChange.event;
3904
+ this.addDisposables(this.onDidFocusChange((event) => {
3905
+ this._isFocused = event.isFocused;
3906
+ }), this.onDidActiveChange((event) => {
3907
+ this._isActive = event.isActive;
3908
+ }), this.onDidVisibilityChange((event) => {
3909
+ this._isVisible = event.isVisible;
3910
+ }), this.onDidDimensionsChange((event) => {
3911
+ this._width = event.width;
3912
+ this._height = event.height;
3913
+ }), this.panelUpdatesDisposable, this._onDidDimensionChange, this._onDidChangeFocus, this._onDidVisibilityChange, this._onDidActiveChange, this._onWillFocus, this._onActiveChange, this._onWillFocus, this._onWillVisibilityChange, this._onDidParametersChange);
3631
3914
  }
3632
- dispose() {
3633
- this.disposable.dispose();
3634
- super.dispose();
3915
+ getParameters() {
3916
+ return this._parameters;
3917
+ }
3918
+ initialize(panel) {
3919
+ this.panelUpdatesDisposable.value = this._onDidParametersChange.event((parameters) => {
3920
+ this._parameters = parameters;
3921
+ panel.update({
3922
+ params: parameters,
3923
+ });
3924
+ });
3925
+ }
3926
+ setVisible(isVisible) {
3927
+ this._onWillVisibilityChange.fire({ isVisible });
3928
+ }
3929
+ setActive() {
3930
+ this._onActiveChange.fire();
3931
+ }
3932
+ updateParameters(parameters) {
3933
+ this._onDidParametersChange.fire(parameters);
3635
3934
  }
3636
3935
  }
3637
3936
 
3638
- class DragHandler extends CompositeDisposable {
3639
- constructor(el) {
3640
- super();
3641
- this.el = el;
3642
- this.dataDisposable = new MutableDisposable();
3643
- this.pointerEventsDisposable = new MutableDisposable();
3644
- this._onDragStart = new Emitter();
3645
- this.onDragStart = this._onDragStart.event;
3646
- this.addDisposables(this._onDragStart, this.dataDisposable, this.pointerEventsDisposable);
3647
- this.configure();
3937
+ class SplitviewPanelApiImpl extends PanelApiImpl {
3938
+ //
3939
+ constructor(id, component) {
3940
+ super(id, component);
3941
+ this._onDidConstraintsChangeInternal = new Emitter();
3942
+ this.onDidConstraintsChangeInternal = this._onDidConstraintsChangeInternal.event;
3943
+ //
3944
+ this._onDidConstraintsChange = new Emitter({
3945
+ replay: true,
3946
+ });
3947
+ this.onDidConstraintsChange = this._onDidConstraintsChange.event;
3948
+ //
3949
+ this._onDidSizeChange = new Emitter();
3950
+ this.onDidSizeChange = this._onDidSizeChange.event;
3951
+ this.addDisposables(this._onDidConstraintsChangeInternal, this._onDidConstraintsChange, this._onDidSizeChange);
3648
3952
  }
3649
- isCancelled(_event) {
3650
- return false;
3953
+ setConstraints(value) {
3954
+ this._onDidConstraintsChangeInternal.fire(value);
3651
3955
  }
3652
- configure() {
3653
- this.addDisposables(this._onDragStart, addDisposableListener(this.el, 'dragstart', (event) => {
3654
- if (event.defaultPrevented || this.isCancelled(event)) {
3655
- event.preventDefault();
3656
- return;
3657
- }
3658
- const iframes = [
3659
- ...getElementsByTagName('iframe'),
3660
- ...getElementsByTagName('webview'),
3661
- ];
3662
- this.pointerEventsDisposable.value = {
3663
- dispose: () => {
3664
- for (const iframe of iframes) {
3665
- iframe.style.pointerEvents = 'auto';
3666
- }
3667
- },
3668
- };
3669
- for (const iframe of iframes) {
3670
- iframe.style.pointerEvents = 'none';
3671
- }
3672
- this.el.classList.add('dv-dragged');
3673
- setTimeout(() => this.el.classList.remove('dv-dragged'), 0);
3674
- this.dataDisposable.value = this.getData(event);
3675
- this._onDragStart.fire(event);
3676
- if (event.dataTransfer) {
3677
- event.dataTransfer.effectAllowed = 'move';
3678
- const hasData = event.dataTransfer.items.length > 0;
3679
- if (!hasData) {
3680
- /**
3681
- * Although this is not used by dockview many third party dnd libraries will check
3682
- * dataTransfer.types to determine valid drag events.
3683
- *
3684
- * For example: in react-dnd if dataTransfer.types is not set then the dragStart event will be cancelled
3685
- * through .preventDefault(). Since this is applied globally to all drag events this would break dockviews
3686
- * dnd logic. You can see the code at
3687
- * https://github.com/react-dnd/react-dnd/blob/main/packages/backend-html5/src/HTML5BackendImpl.ts#L542
3688
- */
3689
- event.dataTransfer.setData('text/plain', '__dockview_internal_drag_event__');
3690
- }
3691
- }
3692
- }), addDisposableListener(this.el, 'dragend', () => {
3693
- this.pointerEventsDisposable.dispose();
3694
- this.dataDisposable.dispose();
3695
- }));
3956
+ setSize(event) {
3957
+ this._onDidSizeChange.fire(event);
3696
3958
  }
3697
3959
  }
3698
3960
 
3699
- class TabDragHandler extends DragHandler {
3700
- constructor(element, accessor, group, panel) {
3701
- super(element);
3702
- this.accessor = accessor;
3703
- this.group = group;
3704
- this.panel = panel;
3705
- this.panelTransfer = LocalSelectionTransfer.getInstance();
3961
+ class PaneviewPanelApiImpl extends SplitviewPanelApiImpl {
3962
+ set pane(pane) {
3963
+ this._pane = pane;
3706
3964
  }
3707
- getData(event) {
3708
- this.panelTransfer.setData([new PanelTransfer(this.accessor.id, this.group.id, this.panel.id)], PanelTransfer.prototype);
3709
- return {
3710
- dispose: () => {
3711
- this.panelTransfer.clearData(PanelTransfer.prototype);
3712
- },
3713
- };
3965
+ constructor(id, component) {
3966
+ super(id, component);
3967
+ this._onDidExpansionChange = new Emitter({
3968
+ replay: true,
3969
+ });
3970
+ this.onDidExpansionChange = this._onDidExpansionChange.event;
3971
+ this._onMouseEnter = new Emitter({});
3972
+ this.onMouseEnter = this._onMouseEnter.event;
3973
+ this._onMouseLeave = new Emitter({});
3974
+ this.onMouseLeave = this._onMouseLeave.event;
3975
+ this.addDisposables(this._onDidExpansionChange, this._onMouseEnter, this._onMouseLeave);
3976
+ }
3977
+ setExpanded(isExpanded) {
3978
+ var _a;
3979
+ (_a = this._pane) === null || _a === void 0 ? void 0 : _a.setExpanded(isExpanded);
3980
+ }
3981
+ get isExpanded() {
3982
+ var _a;
3983
+ return !!((_a = this._pane) === null || _a === void 0 ? void 0 : _a.isExpanded());
3714
3984
  }
3715
3985
  }
3716
- class Tab extends CompositeDisposable {
3986
+
3987
+ class BasePanelView extends CompositeDisposable {
3717
3988
  get element() {
3718
3989
  return this._element;
3719
3990
  }
3720
- constructor(panel, accessor, group) {
3991
+ get width() {
3992
+ return this._width;
3993
+ }
3994
+ get height() {
3995
+ return this._height;
3996
+ }
3997
+ get params() {
3998
+ var _a;
3999
+ return (_a = this._params) === null || _a === void 0 ? void 0 : _a.params;
4000
+ }
4001
+ constructor(id, component, api) {
3721
4002
  super();
3722
- this.panel = panel;
3723
- this.accessor = accessor;
3724
- this.group = group;
3725
- this.content = undefined;
3726
- this._onChanged = new Emitter();
3727
- this.onChanged = this._onChanged.event;
3728
- this._onDropped = new Emitter();
3729
- this.onDrop = this._onDropped.event;
3730
- this._onDragStart = new Emitter();
3731
- this.onDragStart = this._onDragStart.event;
4003
+ this.id = id;
4004
+ this.component = component;
4005
+ this.api = api;
4006
+ this._height = 0;
4007
+ this._width = 0;
3732
4008
  this._element = document.createElement('div');
3733
- this._element.className = 'tab';
3734
- this._element.tabIndex = 0;
3735
- this._element.draggable = true;
3736
- toggleClass(this.element, 'inactive-tab', true);
3737
- const dragHandler = new TabDragHandler(this._element, this.accessor, this.group, this.panel);
3738
- this.dropTarget = new Droptarget(this._element, {
3739
- acceptedTargetZones: ['center'],
3740
- canDisplayOverlay: (event, position) => {
3741
- if (this.group.locked) {
3742
- return false;
3743
- }
3744
- const data = getPanelData();
3745
- if (data && this.accessor.id === data.viewId) {
3746
- if (data.panelId === null &&
3747
- data.groupId === this.group.id) {
3748
- // don't allow group move to drop on self
3749
- return false;
3750
- }
3751
- return this.panel.id !== data.panelId;
3752
- }
3753
- return this.group.model.canDisplayOverlay(event, position, 'tab');
3754
- },
3755
- });
3756
- this.onWillShowOverlay = this.dropTarget.onWillShowOverlay;
3757
- this.addDisposables(this._onChanged, this._onDropped, this._onDragStart, dragHandler.onDragStart((event) => {
3758
- this._onDragStart.fire(event);
3759
- }), dragHandler, addDisposableListener(this._element, 'mousedown', (event) => {
3760
- if (event.defaultPrevented) {
3761
- return;
4009
+ this._element.tabIndex = -1;
4010
+ this._element.style.outline = 'none';
4011
+ this._element.style.height = '100%';
4012
+ this._element.style.width = '100%';
4013
+ this._element.style.overflow = 'hidden';
4014
+ const focusTracker = trackFocus(this._element);
4015
+ this.addDisposables(this.api, focusTracker.onDidFocus(() => {
4016
+ this.api._onDidChangeFocus.fire({ isFocused: true });
4017
+ }), focusTracker.onDidBlur(() => {
4018
+ this.api._onDidChangeFocus.fire({ isFocused: false });
4019
+ }), focusTracker);
4020
+ }
4021
+ focus() {
4022
+ const event = new WillFocusEvent();
4023
+ this.api._onWillFocus.fire(event);
4024
+ if (event.defaultPrevented) {
4025
+ return;
4026
+ }
4027
+ this._element.focus();
4028
+ }
4029
+ layout(width, height) {
4030
+ this._width = width;
4031
+ this._height = height;
4032
+ this.api._onDidDimensionChange.fire({ width, height });
4033
+ if (this.part) {
4034
+ if (this._params) {
4035
+ this.part.update(this._params.params);
3762
4036
  }
3763
- this._onChanged.fire(event);
3764
- }), this.dropTarget.onDrop((event) => {
3765
- this._onDropped.fire(event);
3766
- }), this.dropTarget);
4037
+ }
3767
4038
  }
3768
- setActive(isActive) {
3769
- toggleClass(this.element, 'active-tab', isActive);
3770
- toggleClass(this.element, 'inactive-tab', !isActive);
4039
+ init(parameters) {
4040
+ this._params = parameters;
4041
+ this.part = this.getComponent();
3771
4042
  }
3772
- setContent(part) {
3773
- if (this.content) {
3774
- this._element.removeChild(this.content.element);
4043
+ update(event) {
4044
+ var _a, _b;
4045
+ // merge the new parameters with the existing parameters
4046
+ this._params = Object.assign(Object.assign({}, this._params), { params: Object.assign(Object.assign({}, (_a = this._params) === null || _a === void 0 ? void 0 : _a.params), event.params) });
4047
+ /**
4048
+ * delete new keys that have a value of undefined,
4049
+ * allow values of null
4050
+ */
4051
+ for (const key of Object.keys(event.params)) {
4052
+ if (event.params[key] === undefined) {
4053
+ delete this._params.params[key];
4054
+ }
3775
4055
  }
3776
- this.content = part;
3777
- this._element.appendChild(this.content.element);
4056
+ // update the view with the updated props
4057
+ (_b = this.part) === null || _b === void 0 ? void 0 : _b.update({ params: this._params.params });
4058
+ }
4059
+ toJSON() {
4060
+ var _a, _b;
4061
+ const params = (_b = (_a = this._params) === null || _a === void 0 ? void 0 : _a.params) !== null && _b !== void 0 ? _b : {};
4062
+ return {
4063
+ id: this.id,
4064
+ component: this.component,
4065
+ params: Object.keys(params).length > 0 ? params : undefined,
4066
+ };
3778
4067
  }
3779
4068
  dispose() {
4069
+ var _a;
4070
+ this.api.dispose();
4071
+ (_a = this.part) === null || _a === void 0 ? void 0 : _a.dispose();
3780
4072
  super.dispose();
3781
4073
  }
3782
4074
  }
3783
4075
 
3784
- function addGhostImage(dataTransfer, ghostElement) {
3785
- // class dockview provides to force ghost image to be drawn on a different layer and prevent weird rendering issues
3786
- addClasses(ghostElement, 'dv-dragged');
3787
- document.body.appendChild(ghostElement);
3788
- dataTransfer.setDragImage(ghostElement, 0, 0);
3789
- setTimeout(() => {
3790
- removeClasses(ghostElement, 'dv-dragged');
3791
- ghostElement.remove();
3792
- }, 0);
3793
- }
3794
-
3795
- class GroupDragHandler extends DragHandler {
3796
- constructor(element, accessor, group) {
3797
- super(element);
3798
- this.accessor = accessor;
3799
- this.group = group;
3800
- this.panelTransfer = LocalSelectionTransfer.getInstance();
3801
- this.addDisposables(addDisposableListener(element, 'mousedown', (e) => {
3802
- if (e.shiftKey) {
3803
- /**
3804
- * You cannot call e.preventDefault() because that will prevent drag events from firing
3805
- * but we also need to stop any group overlay drag events from occuring
3806
- * Use a custom event marker that can be checked by the overlay drag events
3807
- */
3808
- quasiPreventDefault(e);
3809
- }
3810
- }, true));
4076
+ class PaneviewPanel extends BasePanelView {
4077
+ set orientation(value) {
4078
+ this._orientation = value;
3811
4079
  }
3812
- isCancelled(_event) {
3813
- if (this.group.api.location.type === 'floating' && !_event.shiftKey) {
3814
- return true;
3815
- }
3816
- return false;
4080
+ get orientation() {
4081
+ return this._orientation;
3817
4082
  }
3818
- getData(dragEvent) {
3819
- const dataTransfer = dragEvent.dataTransfer;
3820
- this.panelTransfer.setData([new PanelTransfer(this.accessor.id, this.group.id, null)], PanelTransfer.prototype);
3821
- const style = window.getComputedStyle(this.el);
3822
- const bgColor = style.getPropertyValue('--dv-activegroup-visiblepanel-tab-background-color');
3823
- const color = style.getPropertyValue('--dv-activegroup-visiblepanel-tab-color');
3824
- if (dataTransfer) {
3825
- const ghostElement = document.createElement('div');
3826
- ghostElement.style.backgroundColor = bgColor;
3827
- ghostElement.style.color = color;
3828
- ghostElement.style.padding = '2px 8px';
3829
- ghostElement.style.height = '24px';
3830
- ghostElement.style.fontSize = '11px';
3831
- ghostElement.style.lineHeight = '20px';
3832
- ghostElement.style.borderRadius = '12px';
3833
- ghostElement.style.position = 'absolute';
3834
- ghostElement.textContent = `Multiple Panels (${this.group.size})`;
3835
- addGhostImage(dataTransfer, ghostElement);
3836
- }
3837
- return {
3838
- dispose: () => {
3839
- this.panelTransfer.clearData(PanelTransfer.prototype);
3840
- },
3841
- };
4083
+ get minimumSize() {
4084
+ const headerSize = this.headerSize;
4085
+ const expanded = this.isExpanded();
4086
+ const minimumBodySize = expanded ? this._minimumBodySize : 0;
4087
+ return headerSize + minimumBodySize;
3842
4088
  }
3843
- }
3844
-
3845
- class VoidContainer extends CompositeDisposable {
3846
- get element() {
3847
- return this._element;
4089
+ get maximumSize() {
4090
+ const headerSize = this.headerSize;
4091
+ const expanded = this.isExpanded();
4092
+ const maximumBodySize = expanded ? this._maximumBodySize : 0;
4093
+ return headerSize + maximumBodySize;
3848
4094
  }
3849
- constructor(accessor, group) {
3850
- super();
3851
- this.accessor = accessor;
3852
- this.group = group;
3853
- this._onDrop = new Emitter();
3854
- this.onDrop = this._onDrop.event;
3855
- this._onDragStart = new Emitter();
3856
- this.onDragStart = this._onDragStart.event;
3857
- this._element = document.createElement('div');
3858
- this._element.className = 'void-container';
3859
- this._element.tabIndex = 0;
3860
- this._element.draggable = true;
3861
- this.addDisposables(this._onDrop, this._onDragStart, addDisposableListener(this._element, 'click', () => {
3862
- this.accessor.doSetGroupActive(this.group);
3863
- }));
3864
- const handler = new GroupDragHandler(this._element, accessor, group);
3865
- this.dropTraget = new Droptarget(this._element, {
3866
- acceptedTargetZones: ['center'],
3867
- canDisplayOverlay: (event, position) => {
3868
- var _a;
3869
- const data = getPanelData();
3870
- if (data && this.accessor.id === data.viewId) {
3871
- if (data.panelId === null &&
3872
- data.groupId === this.group.id) {
3873
- // don't allow group move to drop on self
3874
- return false;
3875
- }
3876
- // don't show the overlay if the tab being dragged is the last panel of this group
3877
- return ((_a = last(this.group.panels)) === null || _a === void 0 ? void 0 : _a.id) !== data.panelId;
3878
- }
3879
- return group.model.canDisplayOverlay(event, position, 'header_space');
3880
- },
3881
- });
3882
- this.onWillShowOverlay = this.dropTraget.onWillShowOverlay;
3883
- this.addDisposables(handler, handler.onDragStart((event) => {
3884
- this._onDragStart.fire(event);
3885
- }), this.dropTraget.onDrop((event) => {
3886
- this._onDrop.fire(event);
3887
- }), this.dropTraget);
4095
+ get size() {
4096
+ return this._size;
3888
4097
  }
3889
- }
3890
-
3891
- class TabsContainer extends CompositeDisposable {
3892
- get panels() {
3893
- return this.tabs.map((_) => _.value.panel.id);
4098
+ get orthogonalSize() {
4099
+ return this._orthogonalSize;
3894
4100
  }
3895
- get size() {
3896
- return this.tabs.length;
4101
+ set orthogonalSize(size) {
4102
+ this._orthogonalSize = size;
3897
4103
  }
3898
- get hidden() {
3899
- return this._hidden;
4104
+ get minimumBodySize() {
4105
+ return this._minimumBodySize;
3900
4106
  }
3901
- set hidden(value) {
3902
- this._hidden = value;
3903
- this.element.style.display = value ? 'none' : '';
4107
+ set minimumBodySize(value) {
4108
+ this._minimumBodySize = typeof value === 'number' ? value : 0;
3904
4109
  }
3905
- show() {
3906
- if (!this.hidden) {
3907
- this.element.style.display = '';
3908
- }
4110
+ get maximumBodySize() {
4111
+ return this._maximumBodySize;
3909
4112
  }
3910
- hide() {
3911
- this._element.style.display = 'none';
4113
+ set maximumBodySize(value) {
4114
+ this._maximumBodySize =
4115
+ typeof value === 'number' ? value : Number.POSITIVE_INFINITY;
3912
4116
  }
3913
- setRightActionsElement(element) {
3914
- if (this.rightActions === element) {
4117
+ get headerVisible() {
4118
+ return this._headerVisible;
4119
+ }
4120
+ set headerVisible(value) {
4121
+ this._headerVisible = value;
4122
+ this.header.style.display = value ? '' : 'none';
4123
+ }
4124
+ constructor(id, component, headerComponent, orientation, isExpanded, isHeaderVisible) {
4125
+ super(id, component, new PaneviewPanelApiImpl(id, component));
4126
+ this.headerComponent = headerComponent;
4127
+ this._onDidChangeExpansionState = new Emitter({ replay: true });
4128
+ this.onDidChangeExpansionState = this._onDidChangeExpansionState.event;
4129
+ this._onDidChange = new Emitter();
4130
+ this.onDidChange = this._onDidChange.event;
4131
+ this.headerSize = 22;
4132
+ this._orthogonalSize = 0;
4133
+ this._size = 0;
4134
+ this._minimumBodySize = 100;
4135
+ this._maximumBodySize = Number.POSITIVE_INFINITY;
4136
+ this._isExpanded = false;
4137
+ this.expandedSize = 0;
4138
+ this.api.pane = this; // TODO cannot use 'this' before 'super'
4139
+ this.api.initialize(this);
4140
+ this._isExpanded = isExpanded;
4141
+ this._headerVisible = isHeaderVisible;
4142
+ this._onDidChangeExpansionState.fire(this.isExpanded()); // initialize value
4143
+ this._orientation = orientation;
4144
+ this.element.classList.add('pane');
4145
+ this.addDisposables(this.api.onWillVisibilityChange((event) => {
4146
+ const { isVisible } = event;
4147
+ const { accessor } = this._params;
4148
+ accessor.setVisible(this, isVisible);
4149
+ }), this.api.onDidSizeChange((event) => {
4150
+ this._onDidChange.fire({ size: event.size });
4151
+ }), addDisposableListener(this.element, 'mouseenter', (ev) => {
4152
+ this.api._onMouseEnter.fire(ev);
4153
+ }), addDisposableListener(this.element, 'mouseleave', (ev) => {
4154
+ this.api._onMouseLeave.fire(ev);
4155
+ }));
4156
+ this.addDisposables(this._onDidChangeExpansionState, this.onDidChangeExpansionState((isPanelExpanded) => {
4157
+ this.api._onDidExpansionChange.fire({
4158
+ isExpanded: isPanelExpanded,
4159
+ });
4160
+ }), this.api.onDidFocusChange((e) => {
4161
+ if (!this.header) {
4162
+ return;
4163
+ }
4164
+ if (e.isFocused) {
4165
+ addClasses(this.header, 'focused');
4166
+ }
4167
+ else {
4168
+ removeClasses(this.header, 'focused');
4169
+ }
4170
+ }));
4171
+ this.renderOnce();
4172
+ }
4173
+ setVisible(isVisible) {
4174
+ this.api._onDidVisibilityChange.fire({ isVisible });
4175
+ }
4176
+ setActive(isActive) {
4177
+ this.api._onDidActiveChange.fire({ isActive });
4178
+ }
4179
+ isExpanded() {
4180
+ return this._isExpanded;
4181
+ }
4182
+ setExpanded(expanded) {
4183
+ if (this._isExpanded === expanded) {
3915
4184
  return;
3916
4185
  }
3917
- if (this.rightActions) {
3918
- this.rightActions.remove();
3919
- this.rightActions = undefined;
4186
+ this._isExpanded = expanded;
4187
+ if (expanded) {
4188
+ if (this.animationTimer) {
4189
+ clearTimeout(this.animationTimer);
4190
+ }
4191
+ if (this.body) {
4192
+ this.element.appendChild(this.body);
4193
+ }
3920
4194
  }
3921
- if (element) {
3922
- this.rightActionsContainer.appendChild(element);
3923
- this.rightActions = element;
4195
+ else {
4196
+ this.animationTimer = setTimeout(() => {
4197
+ var _a;
4198
+ (_a = this.body) === null || _a === void 0 ? void 0 : _a.remove();
4199
+ }, 200);
3924
4200
  }
4201
+ this._onDidChange.fire(expanded ? { size: this.width } : {});
4202
+ this._onDidChangeExpansionState.fire(expanded);
3925
4203
  }
3926
- setLeftActionsElement(element) {
3927
- if (this.leftActions === element) {
3928
- return;
3929
- }
3930
- if (this.leftActions) {
3931
- this.leftActions.remove();
3932
- this.leftActions = undefined;
3933
- }
3934
- if (element) {
3935
- this.leftActionsContainer.appendChild(element);
3936
- this.leftActions = element;
4204
+ layout(size, orthogonalSize) {
4205
+ this._size = size;
4206
+ this._orthogonalSize = orthogonalSize;
4207
+ const [width, height] = this.orientation === exports.Orientation.HORIZONTAL
4208
+ ? [size, orthogonalSize]
4209
+ : [orthogonalSize, size];
4210
+ if (this.isExpanded()) {
4211
+ this.expandedSize = width;
3937
4212
  }
4213
+ super.layout(width, height);
3938
4214
  }
3939
- setPrefixActionsElement(element) {
3940
- if (this.preActions === element) {
3941
- return;
4215
+ init(parameters) {
4216
+ var _a, _b;
4217
+ super.init(parameters);
4218
+ if (typeof parameters.minimumBodySize === 'number') {
4219
+ this.minimumBodySize = parameters.minimumBodySize;
3942
4220
  }
3943
- if (this.preActions) {
3944
- this.preActions.remove();
3945
- this.preActions = undefined;
4221
+ if (typeof parameters.maximumBodySize === 'number') {
4222
+ this.maximumBodySize = parameters.maximumBodySize;
3946
4223
  }
3947
- if (element) {
3948
- this.preActionsContainer.appendChild(element);
3949
- this.preActions = element;
4224
+ this.bodyPart = this.getBodyComponent();
4225
+ this.headerPart = this.getHeaderComponent();
4226
+ this.bodyPart.init(Object.assign(Object.assign({}, parameters), { api: this.api }));
4227
+ this.headerPart.init(Object.assign(Object.assign({}, parameters), { api: this.api }));
4228
+ (_a = this.body) === null || _a === void 0 ? void 0 : _a.append(this.bodyPart.element);
4229
+ (_b = this.header) === null || _b === void 0 ? void 0 : _b.append(this.headerPart.element);
4230
+ if (typeof parameters.isExpanded === 'boolean') {
4231
+ this.setExpanded(parameters.isExpanded);
3950
4232
  }
3951
4233
  }
3952
- get element() {
3953
- return this._element;
4234
+ toJSON() {
4235
+ const params = this._params;
4236
+ return Object.assign(Object.assign({}, super.toJSON()), { headerComponent: this.headerComponent, title: params.title });
3954
4237
  }
3955
- isActive(tab) {
3956
- return (this.selectedIndex > -1 &&
3957
- this.tabs[this.selectedIndex].value === tab);
4238
+ renderOnce() {
4239
+ this.header = document.createElement('div');
4240
+ this.header.tabIndex = 0;
4241
+ this.header.className = 'pane-header';
4242
+ this.header.style.height = `${this.headerSize}px`;
4243
+ this.header.style.lineHeight = `${this.headerSize}px`;
4244
+ this.header.style.minHeight = `${this.headerSize}px`;
4245
+ this.header.style.maxHeight = `${this.headerSize}px`;
4246
+ this.element.appendChild(this.header);
4247
+ this.body = document.createElement('div');
4248
+ this.body.className = 'pane-body';
4249
+ this.element.appendChild(this.body);
3958
4250
  }
3959
- indexOf(id) {
3960
- return this.tabs.findIndex((tab) => tab.value.panel.id === id);
4251
+ // TODO slightly hacky by-pass of the component to create a body and header component
4252
+ getComponent() {
4253
+ return {
4254
+ update: (params) => {
4255
+ var _a, _b;
4256
+ (_a = this.bodyPart) === null || _a === void 0 ? void 0 : _a.update({ params });
4257
+ (_b = this.headerPart) === null || _b === void 0 ? void 0 : _b.update({ params });
4258
+ },
4259
+ dispose: () => {
4260
+ var _a, _b;
4261
+ (_a = this.bodyPart) === null || _a === void 0 ? void 0 : _a.dispose();
4262
+ (_b = this.headerPart) === null || _b === void 0 ? void 0 : _b.dispose();
4263
+ },
4264
+ };
3961
4265
  }
3962
- constructor(accessor, group) {
3963
- super();
4266
+ }
4267
+
4268
+ class DraggablePaneviewPanel extends PaneviewPanel {
4269
+ constructor(accessor, id, component, headerComponent, orientation, isExpanded, disableDnd) {
4270
+ super(id, component, headerComponent, orientation, isExpanded, true);
3964
4271
  this.accessor = accessor;
3965
- this.group = group;
3966
- this.tabs = [];
3967
- this.selectedIndex = -1;
3968
- this._hidden = false;
3969
- this._onDrop = new Emitter();
3970
- this.onDrop = this._onDrop.event;
3971
- this._onTabDragStart = new Emitter();
3972
- this.onTabDragStart = this._onTabDragStart.event;
3973
- this._onGroupDragStart = new Emitter();
3974
- this.onGroupDragStart = this._onGroupDragStart.event;
3975
- this._onWillShowOverlay = new Emitter();
3976
- this.onWillShowOverlay = this._onWillShowOverlay.event;
3977
- this._element = document.createElement('div');
3978
- this._element.className = 'tabs-and-actions-container';
3979
- toggleClass(this._element, 'dv-full-width-single-tab', this.accessor.options.singleTabMode === 'fullwidth');
3980
- this.rightActionsContainer = document.createElement('div');
3981
- this.rightActionsContainer.className = 'right-actions-container';
3982
- this.leftActionsContainer = document.createElement('div');
3983
- this.leftActionsContainer.className = 'left-actions-container';
3984
- this.preActionsContainer = document.createElement('div');
3985
- this.preActionsContainer.className = 'pre-actions-container';
3986
- this.tabContainer = document.createElement('div');
3987
- this.tabContainer.className = 'tabs-container';
3988
- this.voidContainer = new VoidContainer(this.accessor, this.group);
3989
- this._element.appendChild(this.preActionsContainer);
3990
- this._element.appendChild(this.tabContainer);
3991
- this._element.appendChild(this.leftActionsContainer);
3992
- this._element.appendChild(this.voidContainer.element);
3993
- this._element.appendChild(this.rightActionsContainer);
3994
- this.addDisposables(this.accessor.onDidAddPanel((e) => {
3995
- if (e.api.group === this.group) {
3996
- toggleClass(this._element, 'dv-single-tab', this.size === 1);
3997
- }
3998
- }), this.accessor.onDidRemovePanel((e) => {
3999
- if (e.api.group === this.group) {
4000
- toggleClass(this._element, 'dv-single-tab', this.size === 1);
4001
- }
4002
- }), this._onWillShowOverlay, this._onDrop, this._onTabDragStart, this._onGroupDragStart, this.voidContainer, this.voidContainer.onDragStart((event) => {
4003
- this._onGroupDragStart.fire({
4004
- nativeEvent: event,
4005
- group: this.group,
4006
- });
4007
- }), this.voidContainer.onDrop((event) => {
4008
- this._onDrop.fire({
4009
- event: event.nativeEvent,
4010
- index: this.tabs.length,
4011
- });
4012
- }), this.voidContainer.onWillShowOverlay((event) => {
4013
- this._onWillShowOverlay.fire(new WillShowOverlayLocationEvent(event, {
4014
- kind: 'header_space',
4015
- panel: this.group.activePanel,
4016
- api: this.accessor.api,
4017
- group: this.group,
4018
- getData: getPanelData,
4019
- }));
4020
- }), addDisposableListener(this.voidContainer.element, 'mousedown', (event) => {
4021
- const isFloatingGroupsEnabled = !this.accessor.options.disableFloatingGroups;
4022
- if (isFloatingGroupsEnabled &&
4023
- event.shiftKey &&
4024
- this.group.api.location.type !== 'floating') {
4025
- event.preventDefault();
4026
- const { top, left } = this.element.getBoundingClientRect();
4027
- const { top: rootTop, left: rootLeft } = this.accessor.element.getBoundingClientRect();
4028
- this.accessor.addFloatingGroup(this.group, {
4029
- x: left - rootLeft + 20,
4030
- y: top - rootTop + 20,
4031
- }, { inDragMode: true });
4032
- }
4033
- }), addDisposableListener(this.tabContainer, 'mousedown', (event) => {
4034
- if (event.defaultPrevented) {
4035
- return;
4036
- }
4037
- const isLeftClick = event.button === 0;
4038
- if (isLeftClick) {
4039
- this.accessor.doSetGroupActive(this.group);
4040
- }
4041
- }));
4042
- }
4043
- setActive(_isGroupActive) {
4044
- // noop
4045
- }
4046
- addTab(tab, index = this.tabs.length) {
4047
- if (index < 0 || index > this.tabs.length) {
4048
- throw new Error('invalid location');
4049
- }
4050
- this.tabContainer.insertBefore(tab.value.element, this.tabContainer.children[index]);
4051
- this.tabs = [
4052
- ...this.tabs.slice(0, index),
4053
- tab,
4054
- ...this.tabs.slice(index),
4055
- ];
4056
- if (this.selectedIndex < 0) {
4057
- this.selectedIndex = index;
4272
+ this._onDidDrop = new Emitter();
4273
+ this.onDidDrop = this._onDidDrop.event;
4274
+ if (!disableDnd) {
4275
+ this.initDragFeatures();
4058
4276
  }
4059
4277
  }
4060
- delete(id) {
4061
- const index = this.tabs.findIndex((tab) => tab.value.panel.id === id);
4062
- const tabToRemove = this.tabs.splice(index, 1)[0];
4063
- const { value, disposable } = tabToRemove;
4064
- disposable.dispose();
4065
- value.dispose();
4066
- value.element.remove();
4067
- }
4068
- setActivePanel(panel) {
4069
- this.tabs.forEach((tab) => {
4070
- const isActivePanel = panel.id === tab.value.panel.id;
4071
- tab.value.setActive(isActivePanel);
4278
+ initDragFeatures() {
4279
+ if (!this.header) {
4280
+ return;
4281
+ }
4282
+ const id = this.id;
4283
+ const accessorId = this.accessor.id;
4284
+ this.header.draggable = true;
4285
+ this.handler = new (class PaneDragHandler extends DragHandler {
4286
+ getData() {
4287
+ LocalSelectionTransfer.getInstance().setData([new PaneTransfer(accessorId, id)], PaneTransfer.prototype);
4288
+ return {
4289
+ dispose: () => {
4290
+ LocalSelectionTransfer.getInstance().clearData(PaneTransfer.prototype);
4291
+ },
4292
+ };
4293
+ }
4294
+ })(this.header);
4295
+ this.target = new Droptarget(this.element, {
4296
+ acceptedTargetZones: ['top', 'bottom'],
4297
+ overlayModel: {
4298
+ activationSize: { type: 'percentage', value: 50 },
4299
+ },
4300
+ canDisplayOverlay: (event) => {
4301
+ const data = getPaneData();
4302
+ if (data) {
4303
+ if (data.paneId !== this.id &&
4304
+ data.viewId === this.accessor.id) {
4305
+ return true;
4306
+ }
4307
+ }
4308
+ if (this.accessor.options.showDndOverlay) {
4309
+ return this.accessor.options.showDndOverlay({
4310
+ nativeEvent: event,
4311
+ getData: getPaneData,
4312
+ panel: this,
4313
+ });
4314
+ }
4315
+ return false;
4316
+ },
4072
4317
  });
4318
+ this.addDisposables(this._onDidDrop, this.handler, this.target, this.target.onDrop((event) => {
4319
+ this.onDrop(event);
4320
+ }));
4073
4321
  }
4074
- openPanel(panel, index = this.tabs.length) {
4075
- var _a;
4076
- if (this.tabs.find((tab) => tab.value.panel.id === panel.id)) {
4322
+ onDrop(event) {
4323
+ const data = getPaneData();
4324
+ if (!data || data.viewId !== this.accessor.id) {
4325
+ // if there is no local drag event for this panel
4326
+ // or if the drag event was creating by another Paneview instance
4327
+ this._onDidDrop.fire(Object.assign(Object.assign({}, event), { panel: this, api: new PaneviewApi(this.accessor), getData: getPaneData }));
4077
4328
  return;
4078
4329
  }
4079
- const tab = new Tab(panel, this.accessor, this.group);
4080
- if (!((_a = panel.view) === null || _a === void 0 ? void 0 : _a.tab)) {
4081
- throw new Error('invalid header component');
4330
+ const containerApi = this._params
4331
+ .containerApi;
4332
+ const panelId = data.paneId;
4333
+ const existingPanel = containerApi.getPanel(panelId);
4334
+ if (!existingPanel) {
4335
+ // if the panel doesn't exist
4336
+ this._onDidDrop.fire(Object.assign(Object.assign({}, event), { panel: this, getData: getPaneData, api: new PaneviewApi(this.accessor) }));
4337
+ return;
4082
4338
  }
4083
- tab.setContent(panel.view.tab);
4084
- const disposable = new CompositeDisposable(tab.onDragStart((event) => {
4085
- this._onTabDragStart.fire({ nativeEvent: event, panel });
4086
- }), tab.onChanged((event) => {
4087
- const isFloatingGroupsEnabled = !this.accessor.options.disableFloatingGroups;
4088
- const isFloatingWithOnePanel = this.group.api.location.type === 'floating' &&
4089
- this.size === 1;
4090
- if (isFloatingGroupsEnabled &&
4091
- !isFloatingWithOnePanel &&
4092
- event.shiftKey) {
4093
- event.preventDefault();
4094
- const panel = this.accessor.getGroupPanel(tab.panel.id);
4095
- const { top, left } = tab.element.getBoundingClientRect();
4096
- const { top: rootTop, left: rootLeft } = this.accessor.element.getBoundingClientRect();
4097
- this.accessor.addFloatingGroup(panel, {
4098
- x: left - rootLeft,
4099
- y: top - rootTop,
4100
- }, { inDragMode: true });
4101
- return;
4102
- }
4103
- const isLeftClick = event.button === 0;
4104
- if (!isLeftClick || event.defaultPrevented) {
4105
- return;
4339
+ const allPanels = containerApi.panels;
4340
+ const fromIndex = allPanels.indexOf(existingPanel);
4341
+ let toIndex = containerApi.panels.indexOf(this);
4342
+ if (event.position === 'left' || event.position === 'top') {
4343
+ toIndex = Math.max(0, toIndex - 1);
4344
+ }
4345
+ if (event.position === 'right' || event.position === 'bottom') {
4346
+ if (fromIndex > toIndex) {
4347
+ toIndex++;
4106
4348
  }
4107
- if (this.group.activePanel !== panel) {
4108
- this.group.model.openPanel(panel);
4109
- }
4110
- }), tab.onDrop((event) => {
4111
- this._onDrop.fire({
4112
- event: event.nativeEvent,
4113
- index: this.tabs.findIndex((x) => x.value === tab),
4114
- });
4115
- }), tab.onWillShowOverlay((event) => {
4116
- this._onWillShowOverlay.fire(new WillShowOverlayLocationEvent(event, {
4117
- kind: 'tab',
4118
- panel: this.group.activePanel,
4119
- api: this.accessor.api,
4120
- group: this.group,
4121
- getData: getPanelData,
4122
- }));
4123
- }));
4124
- const value = { value: tab, disposable };
4125
- this.addTab(value, index);
4126
- }
4127
- closePanel(panel) {
4128
- this.delete(panel.id);
4129
- }
4130
- dispose() {
4131
- super.dispose();
4132
- for (const { value, disposable } of this.tabs) {
4133
- disposable.dispose();
4134
- value.dispose();
4349
+ toIndex = Math.min(allPanels.length - 1, toIndex);
4135
4350
  }
4136
- this.tabs = [];
4351
+ containerApi.movePanel(fromIndex, toIndex);
4137
4352
  }
4138
4353
  }
4139
4354
 
4140
- class DockviewDidDropEvent extends DockviewEvent {
4141
- get nativeEvent() {
4142
- return this.options.nativeEvent;
4143
- }
4144
- get position() {
4145
- return this.options.position;
4146
- }
4147
- get panel() {
4148
- return this.options.panel;
4149
- }
4150
- get group() {
4151
- return this.options.group;
4152
- }
4153
- get api() {
4154
- return this.options.api;
4155
- }
4156
- constructor(options) {
4157
- super();
4158
- this.options = options;
4159
- }
4160
- getData() {
4161
- return this.options.getData();
4162
- }
4163
- }
4164
- class DockviewWillDropEvent extends DockviewDidDropEvent {
4165
- get kind() {
4166
- return this._kind;
4167
- }
4168
- constructor(options) {
4169
- super(options);
4170
- this._kind = options.kind;
4171
- }
4172
- }
4173
- class WillShowOverlayLocationEvent {
4174
- get kind() {
4175
- return this.options.kind;
4176
- }
4177
- get nativeEvent() {
4178
- return this.event.nativeEvent;
4179
- }
4180
- get position() {
4181
- return this.event.position;
4182
- }
4183
- get defaultPrevented() {
4184
- return this.event.defaultPrevented;
4185
- }
4186
- get panel() {
4187
- return this.options.panel;
4188
- }
4189
- get api() {
4190
- return this.options.api;
4191
- }
4192
- get group() {
4193
- return this.options.group;
4194
- }
4195
- preventDefault() {
4196
- this.event.preventDefault();
4197
- }
4198
- getData() {
4199
- return this.options.getData();
4200
- }
4201
- constructor(event, options) {
4202
- this.event = event;
4203
- this.options = options;
4204
- }
4205
- }
4206
- class DockviewGroupPanelModel extends CompositeDisposable {
4355
+ class ContentContainer extends CompositeDisposable {
4207
4356
  get element() {
4208
- throw new Error('not supported');
4209
- }
4210
- get activePanel() {
4211
- return this._activePanel;
4212
- }
4213
- get locked() {
4214
- return this._locked;
4215
- }
4216
- set locked(value) {
4217
- this._locked = value;
4218
- toggleClass(this.container, 'locked-groupview', value === 'no-drop-target' || value);
4219
- }
4220
- get isActive() {
4221
- return this._isGroupActive;
4222
- }
4223
- get panels() {
4224
- return this._panels;
4225
- }
4226
- get size() {
4227
- return this._panels.length;
4228
- }
4229
- get isEmpty() {
4230
- return this._panels.length === 0;
4231
- }
4232
- get hasWatermark() {
4233
- return !!(this.watermark && this.container.contains(this.watermark.element));
4234
- }
4235
- get header() {
4236
- return this.tabsContainer;
4237
- }
4238
- get isContentFocused() {
4239
- if (!document.activeElement) {
4240
- return false;
4241
- }
4242
- return isAncestor(document.activeElement, this.contentContainer.element);
4243
- }
4244
- get location() {
4245
- return this._location;
4246
- }
4247
- set location(value) {
4248
- this._location = value;
4249
- toggleClass(this.container, 'dv-groupview-floating', false);
4250
- toggleClass(this.container, 'dv-groupview-popout', false);
4251
- switch (value.type) {
4252
- case 'grid':
4253
- this.contentContainer.dropTarget.setTargetZones([
4254
- 'top',
4255
- 'bottom',
4256
- 'left',
4257
- 'right',
4258
- 'center',
4259
- ]);
4260
- break;
4261
- case 'floating':
4262
- this.contentContainer.dropTarget.setTargetZones(['center']);
4263
- this.contentContainer.dropTarget.setTargetZones(value
4264
- ? ['center']
4265
- : ['top', 'bottom', 'left', 'right', 'center']);
4266
- toggleClass(this.container, 'dv-groupview-floating', true);
4267
- break;
4268
- case 'popout':
4269
- this.contentContainer.dropTarget.setTargetZones(['center']);
4270
- toggleClass(this.container, 'dv-groupview-popout', true);
4271
- break;
4272
- }
4273
- this.groupPanel.api._onDidLocationChange.fire({
4274
- location: this.location,
4275
- });
4357
+ return this._element;
4276
4358
  }
4277
- constructor(container, accessor, id, options, groupPanel) {
4278
- var _a;
4359
+ constructor(accessor, group) {
4279
4360
  super();
4280
- this.container = container;
4281
4361
  this.accessor = accessor;
4282
- this.id = id;
4283
- this.options = options;
4284
- this.groupPanel = groupPanel;
4285
- this._isGroupActive = false;
4286
- this._locked = false;
4287
- this._location = { type: 'grid' };
4288
- this.mostRecentlyUsed = [];
4289
- this._onDidChange = new Emitter();
4290
- this.onDidChange = this._onDidChange.event;
4291
- this._width = 0;
4292
- this._height = 0;
4293
- this._panels = [];
4294
- this._panelDisposables = new Map();
4295
- this._onMove = new Emitter();
4296
- this.onMove = this._onMove.event;
4297
- this._onDidDrop = new Emitter();
4298
- this.onDidDrop = this._onDidDrop.event;
4299
- this._onWillDrop = new Emitter();
4300
- this.onWillDrop = this._onWillDrop.event;
4301
- this._onWillShowOverlay = new Emitter();
4302
- this.onWillShowOverlay = this._onWillShowOverlay.event;
4303
- this._onTabDragStart = new Emitter();
4304
- this.onTabDragStart = this._onTabDragStart.event;
4305
- this._onGroupDragStart = new Emitter();
4306
- this.onGroupDragStart = this._onGroupDragStart.event;
4307
- this._onDidAddPanel = new Emitter();
4308
- this.onDidAddPanel = this._onDidAddPanel.event;
4309
- this._onDidPanelTitleChange = new Emitter();
4310
- this.onDidPanelTitleChange = this._onDidPanelTitleChange.event;
4311
- this._onDidPanelParametersChange = new Emitter();
4312
- this.onDidPanelParametersChange = this._onDidPanelParametersChange.event;
4313
- this._onDidRemovePanel = new Emitter();
4314
- this.onDidRemovePanel = this._onDidRemovePanel.event;
4315
- this._onDidActivePanelChange = new Emitter();
4316
- this.onDidActivePanelChange = this._onDidActivePanelChange.event;
4317
- this._overwriteRenderContainer = null;
4318
- toggleClass(this.container, 'groupview', true);
4319
- this._api = new DockviewApi(this.accessor);
4320
- this.tabsContainer = new TabsContainer(this.accessor, this.groupPanel);
4321
- this.contentContainer = new ContentContainer(this.accessor, this);
4322
- container.append(this.tabsContainer.element, this.contentContainer.element);
4323
- this.header.hidden = !!options.hideHeader;
4324
- this.locked = (_a = options.locked) !== null && _a !== void 0 ? _a : false;
4325
- this.addDisposables(this._onTabDragStart, this._onGroupDragStart, this._onWillShowOverlay, this.tabsContainer.onTabDragStart((event) => {
4326
- this._onTabDragStart.fire(event);
4327
- }), this.tabsContainer.onGroupDragStart((event) => {
4328
- this._onGroupDragStart.fire(event);
4329
- }), this.tabsContainer.onDrop((event) => {
4330
- this.handleDropEvent('header', event.event, 'center', event.index);
4331
- }), this.contentContainer.onDidFocus(() => {
4332
- this.accessor.doSetGroupActive(this.groupPanel);
4333
- }), this.contentContainer.onDidBlur(() => {
4334
- // noop
4335
- }), this.contentContainer.dropTarget.onDrop((event) => {
4336
- this.handleDropEvent('content', event.nativeEvent, event.position);
4337
- }), this.tabsContainer.onWillShowOverlay((event) => {
4338
- this._onWillShowOverlay.fire(event);
4339
- }), this.contentContainer.dropTarget.onWillShowOverlay((event) => {
4340
- this._onWillShowOverlay.fire(new WillShowOverlayLocationEvent(event, {
4341
- kind: 'content',
4342
- panel: this.activePanel,
4343
- api: this._api,
4344
- group: this.groupPanel,
4345
- getData: getPanelData,
4346
- }));
4347
- }), this._onMove, this._onDidChange, this._onDidDrop, this._onWillDrop, this._onDidAddPanel, this._onDidRemovePanel, this._onDidActivePanelChange);
4348
- }
4349
- focusContent() {
4350
- this.contentContainer.element.focus();
4351
- }
4352
- set renderContainer(value) {
4353
- this.panels.forEach((panel) => {
4354
- this.renderContainer.detatch(panel);
4355
- });
4356
- this._overwriteRenderContainer = value;
4357
- this.panels.forEach((panel) => {
4358
- this.rerender(panel);
4359
- });
4360
- }
4361
- get renderContainer() {
4362
- var _a;
4363
- return ((_a = this._overwriteRenderContainer) !== null && _a !== void 0 ? _a : this.accessor.overlayRenderContainer);
4364
- }
4365
- initialize() {
4366
- if (this.options.panels) {
4367
- this.options.panels.forEach((panel) => {
4368
- this.doAddPanel(panel);
4369
- });
4370
- }
4371
- if (this.options.activePanel) {
4372
- this.openPanel(this.options.activePanel);
4373
- }
4374
- // must be run after the constructor otherwise this.parent may not be
4375
- // correctly initialized
4376
- this.setActive(this.isActive, true);
4377
- this.updateContainer();
4378
- if (this.accessor.options.createRightHeaderActionsElement) {
4379
- this._rightHeaderActions =
4380
- this.accessor.options.createRightHeaderActionsElement(this.groupPanel);
4381
- this.addDisposables(this._rightHeaderActions);
4382
- this._rightHeaderActions.init({
4383
- containerApi: this._api,
4384
- api: this.groupPanel.api,
4385
- });
4386
- this.tabsContainer.setRightActionsElement(this._rightHeaderActions.element);
4387
- }
4388
- if (this.accessor.options.createLeftHeaderActionsElement) {
4389
- this._leftHeaderActions =
4390
- this.accessor.options.createLeftHeaderActionsElement(this.groupPanel);
4391
- this.addDisposables(this._leftHeaderActions);
4392
- this._leftHeaderActions.init({
4393
- containerApi: this._api,
4394
- api: this.groupPanel.api,
4395
- });
4396
- this.tabsContainer.setLeftActionsElement(this._leftHeaderActions.element);
4397
- }
4398
- if (this.accessor.options.createPrefixHeaderActionsElement) {
4399
- this._prefixHeaderActions =
4400
- this.accessor.options.createPrefixHeaderActionsElement(this.groupPanel);
4401
- this.addDisposables(this._prefixHeaderActions);
4402
- this._prefixHeaderActions.init({
4403
- containerApi: this._api,
4404
- api: this.groupPanel.api,
4405
- });
4406
- this.tabsContainer.setPrefixActionsElement(this._prefixHeaderActions.element);
4407
- }
4408
- }
4409
- rerender(panel) {
4410
- this.contentContainer.renderPanel(panel, { asActive: false });
4411
- }
4412
- indexOf(panel) {
4413
- return this.tabsContainer.indexOf(panel.id);
4414
- }
4415
- toJSON() {
4416
- var _a;
4417
- const result = {
4418
- views: this.tabsContainer.panels,
4419
- activeView: (_a = this._activePanel) === null || _a === void 0 ? void 0 : _a.id,
4420
- id: this.id,
4421
- };
4422
- if (this.locked !== false) {
4423
- result.locked = this.locked;
4424
- }
4425
- if (this.header.hidden) {
4426
- result.hideHeader = true;
4427
- }
4428
- return result;
4362
+ this.group = group;
4363
+ this.disposable = new MutableDisposable();
4364
+ this._onDidFocus = new Emitter();
4365
+ this.onDidFocus = this._onDidFocus.event;
4366
+ this._onDidBlur = new Emitter();
4367
+ this.onDidBlur = this._onDidBlur.event;
4368
+ this._element = document.createElement('div');
4369
+ this._element.className = 'content-container';
4370
+ this._element.tabIndex = -1;
4371
+ this.addDisposables(this._onDidFocus, this._onDidBlur);
4372
+ this.dropTarget = new Droptarget(this.element, {
4373
+ acceptedTargetZones: ['top', 'bottom', 'left', 'right', 'center'],
4374
+ canDisplayOverlay: (event, position) => {
4375
+ if (this.group.locked === 'no-drop-target' ||
4376
+ (this.group.locked && position === 'center')) {
4377
+ return false;
4378
+ }
4379
+ const data = getPanelData();
4380
+ if (!data &&
4381
+ event.shiftKey &&
4382
+ this.group.location.type !== 'floating') {
4383
+ return false;
4384
+ }
4385
+ if (data && data.viewId === this.accessor.id) {
4386
+ if (data.groupId === this.group.id) {
4387
+ if (position === 'center') {
4388
+ // don't allow to drop on self for center position
4389
+ return false;
4390
+ }
4391
+ if (data.panelId === null) {
4392
+ // don't allow group move to drop anywhere on self
4393
+ return false;
4394
+ }
4395
+ }
4396
+ const groupHasOnePanelAndIsActiveDragElement = this.group.panels.length === 1 &&
4397
+ data.groupId === this.group.id;
4398
+ return !groupHasOnePanelAndIsActiveDragElement;
4399
+ }
4400
+ return this.group.canDisplayOverlay(event, position, 'content');
4401
+ },
4402
+ });
4403
+ this.addDisposables(this.dropTarget);
4429
4404
  }
4430
- moveToNext(options) {
4431
- if (!options) {
4432
- options = {};
4433
- }
4434
- if (!options.panel) {
4435
- options.panel = this.activePanel;
4436
- }
4437
- const index = options.panel ? this.panels.indexOf(options.panel) : -1;
4438
- let normalizedIndex;
4439
- if (index < this.panels.length - 1) {
4440
- normalizedIndex = index + 1;
4405
+ show() {
4406
+ this.element.style.display = '';
4407
+ }
4408
+ hide() {
4409
+ this.element.style.display = 'none';
4410
+ }
4411
+ renderPanel(panel, options = { asActive: true }) {
4412
+ const doRender = options.asActive ||
4413
+ (this.panel && this.group.isPanelActive(this.panel));
4414
+ if (this.panel &&
4415
+ this.panel.view.content.element.parentElement === this._element) {
4416
+ /**
4417
+ * If the currently attached panel is mounted directly to the content then remove it
4418
+ */
4419
+ this._element.removeChild(this.panel.view.content.element);
4441
4420
  }
4442
- else if (!options.suppressRoll) {
4443
- normalizedIndex = 0;
4421
+ this.panel = panel;
4422
+ let container;
4423
+ switch (panel.api.renderer) {
4424
+ case 'onlyWhenVisible':
4425
+ this.group.renderContainer.detatch(panel);
4426
+ if (this.panel) {
4427
+ if (doRender) {
4428
+ this._element.appendChild(this.panel.view.content.element);
4429
+ }
4430
+ }
4431
+ container = this._element;
4432
+ break;
4433
+ case 'always':
4434
+ if (panel.view.content.element.parentElement === this._element) {
4435
+ this._element.removeChild(panel.view.content.element);
4436
+ }
4437
+ container = this.group.renderContainer.attach({
4438
+ panel,
4439
+ referenceContainer: this,
4440
+ });
4441
+ break;
4444
4442
  }
4445
- else {
4446
- return;
4443
+ if (doRender) {
4444
+ const focusTracker = trackFocus(container);
4445
+ const disposable = new CompositeDisposable();
4446
+ disposable.addDisposables(focusTracker, focusTracker.onDidFocus(() => this._onDidFocus.fire()), focusTracker.onDidBlur(() => this._onDidBlur.fire()));
4447
+ this.disposable.value = disposable;
4447
4448
  }
4448
- this.openPanel(this.panels[normalizedIndex]);
4449
4449
  }
4450
- moveToPrevious(options) {
4451
- if (!options) {
4452
- options = {};
4453
- }
4454
- if (!options.panel) {
4455
- options.panel = this.activePanel;
4456
- }
4457
- if (!options.panel) {
4450
+ openPanel(panel) {
4451
+ if (this.panel === panel) {
4458
4452
  return;
4459
4453
  }
4460
- const index = this.panels.indexOf(options.panel);
4461
- let normalizedIndex;
4462
- if (index > 0) {
4463
- normalizedIndex = index - 1;
4464
- }
4465
- else if (!options.suppressRoll) {
4466
- normalizedIndex = this.panels.length - 1;
4467
- }
4468
- else {
4469
- return;
4454
+ this.renderPanel(panel);
4455
+ }
4456
+ layout(_width, _height) {
4457
+ // noop
4458
+ }
4459
+ closePanel() {
4460
+ var _a;
4461
+ if (this.panel) {
4462
+ if (this.panel.api.renderer === 'onlyWhenVisible') {
4463
+ (_a = this.panel.view.content.element.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(this.panel.view.content.element);
4464
+ }
4470
4465
  }
4471
- this.openPanel(this.panels[normalizedIndex]);
4466
+ this.panel = undefined;
4472
4467
  }
4473
- containsPanel(panel) {
4474
- return this.panels.includes(panel);
4468
+ dispose() {
4469
+ this.disposable.dispose();
4470
+ super.dispose();
4475
4471
  }
4476
- init(_params) {
4477
- //noop
4472
+ }
4473
+
4474
+ class TabDragHandler extends DragHandler {
4475
+ constructor(element, accessor, group, panel) {
4476
+ super(element);
4477
+ this.accessor = accessor;
4478
+ this.group = group;
4479
+ this.panel = panel;
4480
+ this.panelTransfer = LocalSelectionTransfer.getInstance();
4478
4481
  }
4479
- update(_params) {
4480
- //noop
4482
+ getData(event) {
4483
+ this.panelTransfer.setData([new PanelTransfer(this.accessor.id, this.group.id, this.panel.id)], PanelTransfer.prototype);
4484
+ return {
4485
+ dispose: () => {
4486
+ this.panelTransfer.clearData(PanelTransfer.prototype);
4487
+ },
4488
+ };
4481
4489
  }
4482
- focus() {
4483
- var _a;
4484
- (_a = this._activePanel) === null || _a === void 0 ? void 0 : _a.focus();
4490
+ }
4491
+ class Tab extends CompositeDisposable {
4492
+ get element() {
4493
+ return this._element;
4485
4494
  }
4486
- openPanel(panel, options = {}) {
4487
- /**
4488
- * set the panel group
4489
- * add the panel
4490
- * check if group active
4491
- * check if panel active
4492
- */
4493
- if (typeof options.index !== 'number' ||
4494
- options.index > this.panels.length) {
4495
- options.index = this.panels.length;
4496
- }
4497
- const skipSetActive = !!options.skipSetActive;
4498
- // ensure the group is updated before we fire any events
4499
- panel.updateParentGroup(this.groupPanel, {
4500
- skipSetActive: options.skipSetActive,
4501
- });
4502
- this.doAddPanel(panel, options.index, {
4503
- skipSetActive: skipSetActive,
4495
+ constructor(panel, accessor, group) {
4496
+ super();
4497
+ this.panel = panel;
4498
+ this.accessor = accessor;
4499
+ this.group = group;
4500
+ this.content = undefined;
4501
+ this._onChanged = new Emitter();
4502
+ this.onChanged = this._onChanged.event;
4503
+ this._onDropped = new Emitter();
4504
+ this.onDrop = this._onDropped.event;
4505
+ this._onDragStart = new Emitter();
4506
+ this.onDragStart = this._onDragStart.event;
4507
+ this._element = document.createElement('div');
4508
+ this._element.className = 'tab';
4509
+ this._element.tabIndex = 0;
4510
+ this._element.draggable = true;
4511
+ toggleClass(this.element, 'inactive-tab', true);
4512
+ const dragHandler = new TabDragHandler(this._element, this.accessor, this.group, this.panel);
4513
+ this.dropTarget = new Droptarget(this._element, {
4514
+ acceptedTargetZones: ['center'],
4515
+ canDisplayOverlay: (event, position) => {
4516
+ if (this.group.locked) {
4517
+ return false;
4518
+ }
4519
+ const data = getPanelData();
4520
+ if (data && this.accessor.id === data.viewId) {
4521
+ if (data.panelId === null &&
4522
+ data.groupId === this.group.id) {
4523
+ // don't allow group move to drop on self
4524
+ return false;
4525
+ }
4526
+ return this.panel.id !== data.panelId;
4527
+ }
4528
+ return this.group.model.canDisplayOverlay(event, position, 'tab');
4529
+ },
4504
4530
  });
4505
- if (this._activePanel === panel) {
4506
- this.contentContainer.renderPanel(panel, { asActive: true });
4507
- return;
4508
- }
4509
- if (!skipSetActive) {
4510
- this.doSetActivePanel(panel);
4511
- }
4512
- if (!options.skipSetGroupActive) {
4513
- this.accessor.doSetGroupActive(this.groupPanel);
4514
- }
4515
- if (!options.skipSetActive) {
4516
- this.updateContainer();
4517
- }
4531
+ this.onWillShowOverlay = this.dropTarget.onWillShowOverlay;
4532
+ this.addDisposables(this._onChanged, this._onDropped, this._onDragStart, dragHandler.onDragStart((event) => {
4533
+ this._onDragStart.fire(event);
4534
+ }), dragHandler, addDisposableListener(this._element, 'mousedown', (event) => {
4535
+ if (event.defaultPrevented) {
4536
+ return;
4537
+ }
4538
+ this._onChanged.fire(event);
4539
+ }), this.dropTarget.onDrop((event) => {
4540
+ this._onDropped.fire(event);
4541
+ }), this.dropTarget);
4518
4542
  }
4519
- removePanel(groupItemOrId, options = {
4520
- skipSetActive: false,
4521
- }) {
4522
- const id = typeof groupItemOrId === 'string'
4523
- ? groupItemOrId
4524
- : groupItemOrId.id;
4525
- const panelToRemove = this._panels.find((panel) => panel.id === id);
4526
- if (!panelToRemove) {
4527
- throw new Error('invalid operation');
4543
+ setActive(isActive) {
4544
+ toggleClass(this.element, 'active-tab', isActive);
4545
+ toggleClass(this.element, 'inactive-tab', !isActive);
4546
+ }
4547
+ setContent(part) {
4548
+ if (this.content) {
4549
+ this._element.removeChild(this.content.element);
4528
4550
  }
4529
- return this._removePanel(panelToRemove, options);
4551
+ this.content = part;
4552
+ this._element.appendChild(this.content.element);
4530
4553
  }
4531
- closeAllPanels() {
4532
- if (this.panels.length > 0) {
4533
- // take a copy since we will be edting the array as we iterate through
4534
- const arrPanelCpy = [...this.panels];
4535
- for (const panel of arrPanelCpy) {
4536
- this.doClose(panel);
4554
+ dispose() {
4555
+ super.dispose();
4556
+ }
4557
+ }
4558
+
4559
+ function addGhostImage(dataTransfer, ghostElement) {
4560
+ // class dockview provides to force ghost image to be drawn on a different layer and prevent weird rendering issues
4561
+ addClasses(ghostElement, 'dv-dragged');
4562
+ document.body.appendChild(ghostElement);
4563
+ dataTransfer.setDragImage(ghostElement, 0, 0);
4564
+ setTimeout(() => {
4565
+ removeClasses(ghostElement, 'dv-dragged');
4566
+ ghostElement.remove();
4567
+ }, 0);
4568
+ }
4569
+
4570
+ class GroupDragHandler extends DragHandler {
4571
+ constructor(element, accessor, group) {
4572
+ super(element);
4573
+ this.accessor = accessor;
4574
+ this.group = group;
4575
+ this.panelTransfer = LocalSelectionTransfer.getInstance();
4576
+ this.addDisposables(addDisposableListener(element, 'mousedown', (e) => {
4577
+ if (e.shiftKey) {
4578
+ /**
4579
+ * You cannot call e.preventDefault() because that will prevent drag events from firing
4580
+ * but we also need to stop any group overlay drag events from occuring
4581
+ * Use a custom event marker that can be checked by the overlay drag events
4582
+ */
4583
+ quasiPreventDefault(e);
4537
4584
  }
4585
+ }, true));
4586
+ }
4587
+ isCancelled(_event) {
4588
+ if (this.group.api.location.type === 'floating' && !_event.shiftKey) {
4589
+ return true;
4538
4590
  }
4539
- else {
4540
- this.accessor.removeGroup(this.groupPanel);
4541
- }
4591
+ return false;
4542
4592
  }
4543
- closePanel(panel) {
4544
- this.doClose(panel);
4593
+ getData(dragEvent) {
4594
+ const dataTransfer = dragEvent.dataTransfer;
4595
+ this.panelTransfer.setData([new PanelTransfer(this.accessor.id, this.group.id, null)], PanelTransfer.prototype);
4596
+ const style = window.getComputedStyle(this.el);
4597
+ const bgColor = style.getPropertyValue('--dv-activegroup-visiblepanel-tab-background-color');
4598
+ const color = style.getPropertyValue('--dv-activegroup-visiblepanel-tab-color');
4599
+ if (dataTransfer) {
4600
+ const ghostElement = document.createElement('div');
4601
+ ghostElement.style.backgroundColor = bgColor;
4602
+ ghostElement.style.color = color;
4603
+ ghostElement.style.padding = '2px 8px';
4604
+ ghostElement.style.height = '24px';
4605
+ ghostElement.style.fontSize = '11px';
4606
+ ghostElement.style.lineHeight = '20px';
4607
+ ghostElement.style.borderRadius = '12px';
4608
+ ghostElement.style.position = 'absolute';
4609
+ ghostElement.textContent = `Multiple Panels (${this.group.size})`;
4610
+ addGhostImage(dataTransfer, ghostElement);
4611
+ }
4612
+ return {
4613
+ dispose: () => {
4614
+ this.panelTransfer.clearData(PanelTransfer.prototype);
4615
+ },
4616
+ };
4545
4617
  }
4546
- doClose(panel) {
4547
- this.accessor.removePanel(panel);
4618
+ }
4619
+
4620
+ class VoidContainer extends CompositeDisposable {
4621
+ get element() {
4622
+ return this._element;
4548
4623
  }
4549
- isPanelActive(panel) {
4550
- return this._activePanel === panel;
4624
+ constructor(accessor, group) {
4625
+ super();
4626
+ this.accessor = accessor;
4627
+ this.group = group;
4628
+ this._onDrop = new Emitter();
4629
+ this.onDrop = this._onDrop.event;
4630
+ this._onDragStart = new Emitter();
4631
+ this.onDragStart = this._onDragStart.event;
4632
+ this._element = document.createElement('div');
4633
+ this._element.className = 'void-container';
4634
+ this._element.tabIndex = 0;
4635
+ this._element.draggable = true;
4636
+ this.addDisposables(this._onDrop, this._onDragStart, addDisposableListener(this._element, 'click', () => {
4637
+ this.accessor.doSetGroupActive(this.group);
4638
+ }));
4639
+ const handler = new GroupDragHandler(this._element, accessor, group);
4640
+ this.dropTraget = new Droptarget(this._element, {
4641
+ acceptedTargetZones: ['center'],
4642
+ canDisplayOverlay: (event, position) => {
4643
+ var _a;
4644
+ const data = getPanelData();
4645
+ if (data && this.accessor.id === data.viewId) {
4646
+ if (data.panelId === null &&
4647
+ data.groupId === this.group.id) {
4648
+ // don't allow group move to drop on self
4649
+ return false;
4650
+ }
4651
+ // don't show the overlay if the tab being dragged is the last panel of this group
4652
+ return ((_a = last(this.group.panels)) === null || _a === void 0 ? void 0 : _a.id) !== data.panelId;
4653
+ }
4654
+ return group.model.canDisplayOverlay(event, position, 'header_space');
4655
+ },
4656
+ });
4657
+ this.onWillShowOverlay = this.dropTraget.onWillShowOverlay;
4658
+ this.addDisposables(handler, handler.onDragStart((event) => {
4659
+ this._onDragStart.fire(event);
4660
+ }), this.dropTraget.onDrop((event) => {
4661
+ this._onDrop.fire(event);
4662
+ }), this.dropTraget);
4551
4663
  }
4552
- updateActions(element) {
4553
- this.tabsContainer.setRightActionsElement(element);
4664
+ }
4665
+
4666
+ class TabsContainer extends CompositeDisposable {
4667
+ get panels() {
4668
+ return this.tabs.map((_) => _.value.panel.id);
4554
4669
  }
4555
- setActive(isGroupActive, force = false) {
4556
- if (!force && this.isActive === isGroupActive) {
4557
- return;
4558
- }
4559
- this._isGroupActive = isGroupActive;
4560
- toggleClass(this.container, 'active-group', isGroupActive);
4561
- toggleClass(this.container, 'inactive-group', !isGroupActive);
4562
- this.tabsContainer.setActive(this.isActive);
4563
- if (!this._activePanel && this.panels.length > 0) {
4564
- this.doSetActivePanel(this.panels[0]);
4565
- }
4566
- this.updateContainer();
4670
+ get size() {
4671
+ return this.tabs.length;
4567
4672
  }
4568
- layout(width, height) {
4569
- var _a;
4570
- this._width = width;
4571
- this._height = height;
4572
- this.contentContainer.layout(this._width, this._height);
4573
- if ((_a = this._activePanel) === null || _a === void 0 ? void 0 : _a.layout) {
4574
- this._activePanel.layout(this._width, this._height);
4575
- }
4673
+ get hidden() {
4674
+ return this._hidden;
4576
4675
  }
4577
- _removePanel(panel, options) {
4578
- const isActivePanel = this._activePanel === panel;
4579
- this.doRemovePanel(panel);
4580
- if (isActivePanel && this.panels.length > 0) {
4581
- const nextPanel = this.mostRecentlyUsed[0];
4582
- this.openPanel(nextPanel, {
4583
- skipSetActive: options.skipSetActive,
4584
- skipSetGroupActive: options.skipSetActiveGroup,
4585
- });
4586
- }
4587
- if (this._activePanel && this.panels.length === 0) {
4588
- this.doSetActivePanel(undefined);
4589
- }
4590
- if (!options.skipSetActive) {
4591
- this.updateContainer();
4592
- }
4593
- return panel;
4676
+ set hidden(value) {
4677
+ this._hidden = value;
4678
+ this.element.style.display = value ? 'none' : '';
4594
4679
  }
4595
- doRemovePanel(panel) {
4596
- const index = this.panels.indexOf(panel);
4597
- if (this._activePanel === panel) {
4598
- this.contentContainer.closePanel();
4599
- }
4600
- this.tabsContainer.delete(panel.id);
4601
- this._panels.splice(index, 1);
4602
- if (this.mostRecentlyUsed.includes(panel)) {
4603
- this.mostRecentlyUsed.splice(this.mostRecentlyUsed.indexOf(panel), 1);
4604
- }
4605
- const disposable = this._panelDisposables.get(panel.id);
4606
- if (disposable) {
4607
- disposable.dispose();
4608
- this._panelDisposables.delete(panel.id);
4680
+ show() {
4681
+ if (!this.hidden) {
4682
+ this.element.style.display = '';
4609
4683
  }
4610
- this._onDidRemovePanel.fire({ panel });
4611
4684
  }
4612
- doAddPanel(panel, index = this.panels.length, options = { skipSetActive: false }) {
4613
- const existingPanel = this._panels.indexOf(panel);
4614
- const hasExistingPanel = existingPanel > -1;
4615
- this.tabsContainer.show();
4616
- this.contentContainer.show();
4617
- this.tabsContainer.openPanel(panel, index);
4618
- if (!options.skipSetActive) {
4619
- this.contentContainer.openPanel(panel);
4620
- }
4621
- if (hasExistingPanel) {
4622
- // TODO - need to ensure ordering hasn't changed and if it has need to re-order this.panels
4623
- return;
4624
- }
4625
- this.updateMru(panel);
4626
- this.panels.splice(index, 0, panel);
4627
- this._panelDisposables.set(panel.id, new CompositeDisposable(panel.api.onDidTitleChange((event) => this._onDidPanelTitleChange.fire(event)), panel.api.onDidParametersChange((event) => this._onDidPanelParametersChange.fire(event))));
4628
- this._onDidAddPanel.fire({ panel });
4685
+ hide() {
4686
+ this._element.style.display = 'none';
4629
4687
  }
4630
- doSetActivePanel(panel) {
4631
- if (this._activePanel === panel) {
4688
+ setRightActionsElement(element) {
4689
+ if (this.rightActions === element) {
4632
4690
  return;
4633
4691
  }
4634
- this._activePanel = panel;
4635
- if (panel) {
4636
- this.tabsContainer.setActivePanel(panel);
4637
- panel.layout(this._width, this._height);
4638
- this.updateMru(panel);
4639
- this._onDidActivePanelChange.fire({
4640
- panel,
4641
- });
4642
- }
4643
- }
4644
- updateMru(panel) {
4645
- if (this.mostRecentlyUsed.includes(panel)) {
4646
- this.mostRecentlyUsed.splice(this.mostRecentlyUsed.indexOf(panel), 1);
4647
- }
4648
- this.mostRecentlyUsed = [panel, ...this.mostRecentlyUsed];
4649
- }
4650
- updateContainer() {
4651
- var _a, _b;
4652
- toggleClass(this.container, 'empty', this.isEmpty);
4653
- this.panels.forEach((panel) => panel.runEvents());
4654
- if (this.isEmpty && !this.watermark) {
4655
- const watermark = this.accessor.createWatermarkComponent();
4656
- watermark.init({
4657
- containerApi: this._api,
4658
- group: this.groupPanel,
4659
- });
4660
- this.watermark = watermark;
4661
- addDisposableListener(this.watermark.element, 'click', () => {
4662
- if (!this.isActive) {
4663
- this.accessor.doSetGroupActive(this.groupPanel);
4664
- }
4665
- });
4666
- this.tabsContainer.hide();
4667
- this.contentContainer.element.appendChild(this.watermark.element);
4668
- this.watermark.updateParentGroup(this.groupPanel, true);
4669
- }
4670
- if (!this.isEmpty && this.watermark) {
4671
- this.watermark.element.remove();
4672
- (_b = (_a = this.watermark).dispose) === null || _b === void 0 ? void 0 : _b.call(_a);
4673
- this.watermark = undefined;
4674
- this.tabsContainer.show();
4692
+ if (this.rightActions) {
4693
+ this.rightActions.remove();
4694
+ this.rightActions = undefined;
4675
4695
  }
4676
- }
4677
- canDisplayOverlay(event, position, target) {
4678
- // custom overlay handler
4679
- if (this.accessor.options.showDndOverlay) {
4680
- return this.accessor.options.showDndOverlay({
4681
- nativeEvent: event,
4682
- target,
4683
- group: this.accessor.getPanel(this.id),
4684
- position,
4685
- getData: getPanelData,
4686
- });
4696
+ if (element) {
4697
+ this.rightActionsContainer.appendChild(element);
4698
+ this.rightActions = element;
4687
4699
  }
4688
- return false;
4689
4700
  }
4690
- handleDropEvent(type, event, position, index) {
4691
- if (this.locked === 'no-drop-target') {
4692
- return;
4693
- }
4694
- function getKind() {
4695
- switch (type) {
4696
- case 'header':
4697
- return typeof index === 'number' ? 'tab' : 'header_space';
4698
- case 'content':
4699
- return 'content';
4700
- }
4701
- }
4702
- const panel = typeof index === 'number' ? this.panels[index] : undefined;
4703
- const willDropEvent = new DockviewWillDropEvent({
4704
- nativeEvent: event,
4705
- position,
4706
- panel,
4707
- getData: () => getPanelData(),
4708
- kind: getKind(),
4709
- group: this.groupPanel,
4710
- api: this._api,
4711
- });
4712
- this._onWillDrop.fire(willDropEvent);
4713
- if (willDropEvent.defaultPrevented) {
4701
+ setLeftActionsElement(element) {
4702
+ if (this.leftActions === element) {
4714
4703
  return;
4715
4704
  }
4716
- const data = getPanelData();
4717
- if (data && data.viewId === this.accessor.id) {
4718
- if (data.panelId === null) {
4719
- // this is a group move dnd event
4720
- const { groupId } = data;
4721
- this._onMove.fire({
4722
- target: position,
4723
- groupId: groupId,
4724
- index,
4725
- });
4726
- return;
4727
- }
4728
- const fromSameGroup = this.tabsContainer.indexOf(data.panelId) !== -1;
4729
- if (fromSameGroup && this.tabsContainer.size === 1) {
4730
- return;
4731
- }
4732
- const { groupId, panelId } = data;
4733
- const isSameGroup = this.id === groupId;
4734
- if (isSameGroup && !position) {
4735
- const oldIndex = this.tabsContainer.indexOf(panelId);
4736
- if (oldIndex === index) {
4737
- return;
4738
- }
4739
- }
4740
- this._onMove.fire({
4741
- target: position,
4742
- groupId: data.groupId,
4743
- itemId: data.panelId,
4744
- index,
4745
- });
4705
+ if (this.leftActions) {
4706
+ this.leftActions.remove();
4707
+ this.leftActions = undefined;
4746
4708
  }
4747
- else {
4748
- this._onDidDrop.fire(new DockviewDidDropEvent({
4749
- nativeEvent: event,
4750
- position,
4751
- panel,
4752
- getData: () => getPanelData(),
4753
- group: this.groupPanel,
4754
- api: this._api,
4755
- }));
4709
+ if (element) {
4710
+ this.leftActionsContainer.appendChild(element);
4711
+ this.leftActions = element;
4756
4712
  }
4757
4713
  }
4758
- dispose() {
4759
- var _a, _b, _c;
4760
- super.dispose();
4761
- (_a = this.watermark) === null || _a === void 0 ? void 0 : _a.element.remove();
4762
- (_c = (_b = this.watermark) === null || _b === void 0 ? void 0 : _b.dispose) === null || _c === void 0 ? void 0 : _c.call(_b);
4763
- this.watermark = undefined;
4764
- for (const panel of this.panels) {
4765
- panel.dispose();
4714
+ setPrefixActionsElement(element) {
4715
+ if (this.preActions === element) {
4716
+ return;
4717
+ }
4718
+ if (this.preActions) {
4719
+ this.preActions.remove();
4720
+ this.preActions = undefined;
4721
+ }
4722
+ if (element) {
4723
+ this.preActionsContainer.appendChild(element);
4724
+ this.preActions = element;
4766
4725
  }
4767
- this.tabsContainer.dispose();
4768
- this.contentContainer.dispose();
4769
4726
  }
4770
- }
4771
-
4772
- class Resizable extends CompositeDisposable {
4773
4727
  get element() {
4774
4728
  return this._element;
4775
4729
  }
4776
- get disableResizing() {
4777
- return this._disableResizing;
4730
+ isActive(tab) {
4731
+ return (this.selectedIndex > -1 &&
4732
+ this.tabs[this.selectedIndex].value === tab);
4778
4733
  }
4779
- set disableResizing(value) {
4780
- this._disableResizing = value;
4734
+ indexOf(id) {
4735
+ return this.tabs.findIndex((tab) => tab.value.panel.id === id);
4781
4736
  }
4782
- constructor(parentElement, disableResizing = false) {
4737
+ constructor(accessor, group) {
4783
4738
  super();
4784
- this._disableResizing = disableResizing;
4785
- this._element = parentElement;
4786
- this.addDisposables(watchElementResize(this._element, (entry) => {
4787
- if (this.isDisposed) {
4788
- /**
4789
- * resize is delayed through requestAnimationFrame so there is a small chance
4790
- * the component has already been disposed of
4791
- */
4792
- return;
4739
+ this.accessor = accessor;
4740
+ this.group = group;
4741
+ this.tabs = [];
4742
+ this.selectedIndex = -1;
4743
+ this._hidden = false;
4744
+ this._onDrop = new Emitter();
4745
+ this.onDrop = this._onDrop.event;
4746
+ this._onTabDragStart = new Emitter();
4747
+ this.onTabDragStart = this._onTabDragStart.event;
4748
+ this._onGroupDragStart = new Emitter();
4749
+ this.onGroupDragStart = this._onGroupDragStart.event;
4750
+ this._onWillShowOverlay = new Emitter();
4751
+ this.onWillShowOverlay = this._onWillShowOverlay.event;
4752
+ this._element = document.createElement('div');
4753
+ this._element.className = 'tabs-and-actions-container';
4754
+ toggleClass(this._element, 'dv-full-width-single-tab', this.accessor.options.singleTabMode === 'fullwidth');
4755
+ this.rightActionsContainer = document.createElement('div');
4756
+ this.rightActionsContainer.className = 'right-actions-container';
4757
+ this.leftActionsContainer = document.createElement('div');
4758
+ this.leftActionsContainer.className = 'left-actions-container';
4759
+ this.preActionsContainer = document.createElement('div');
4760
+ this.preActionsContainer.className = 'pre-actions-container';
4761
+ this.tabContainer = document.createElement('div');
4762
+ this.tabContainer.className = 'tabs-container';
4763
+ this.voidContainer = new VoidContainer(this.accessor, this.group);
4764
+ this._element.appendChild(this.preActionsContainer);
4765
+ this._element.appendChild(this.tabContainer);
4766
+ this._element.appendChild(this.leftActionsContainer);
4767
+ this._element.appendChild(this.voidContainer.element);
4768
+ this._element.appendChild(this.rightActionsContainer);
4769
+ this.addDisposables(this.accessor.onDidAddPanel((e) => {
4770
+ if (e.api.group === this.group) {
4771
+ toggleClass(this._element, 'dv-single-tab', this.size === 1);
4793
4772
  }
4794
- if (this.disableResizing) {
4773
+ }), this.accessor.onDidRemovePanel((e) => {
4774
+ if (e.api.group === this.group) {
4775
+ toggleClass(this._element, 'dv-single-tab', this.size === 1);
4776
+ }
4777
+ }), this._onWillShowOverlay, this._onDrop, this._onTabDragStart, this._onGroupDragStart, this.voidContainer, this.voidContainer.onDragStart((event) => {
4778
+ this._onGroupDragStart.fire({
4779
+ nativeEvent: event,
4780
+ group: this.group,
4781
+ });
4782
+ }), this.voidContainer.onDrop((event) => {
4783
+ this._onDrop.fire({
4784
+ event: event.nativeEvent,
4785
+ index: this.tabs.length,
4786
+ });
4787
+ }), this.voidContainer.onWillShowOverlay((event) => {
4788
+ this._onWillShowOverlay.fire(new WillShowOverlayLocationEvent(event, {
4789
+ kind: 'header_space',
4790
+ panel: this.group.activePanel,
4791
+ api: this.accessor.api,
4792
+ group: this.group,
4793
+ getData: getPanelData,
4794
+ }));
4795
+ }), addDisposableListener(this.voidContainer.element, 'mousedown', (event) => {
4796
+ const isFloatingGroupsEnabled = !this.accessor.options.disableFloatingGroups;
4797
+ if (isFloatingGroupsEnabled &&
4798
+ event.shiftKey &&
4799
+ this.group.api.location.type !== 'floating') {
4800
+ event.preventDefault();
4801
+ const { top, left } = this.element.getBoundingClientRect();
4802
+ const { top: rootTop, left: rootLeft } = this.accessor.element.getBoundingClientRect();
4803
+ this.accessor.addFloatingGroup(this.group, {
4804
+ x: left - rootLeft + 20,
4805
+ y: top - rootTop + 20,
4806
+ }, { inDragMode: true });
4807
+ }
4808
+ }), addDisposableListener(this.tabContainer, 'mousedown', (event) => {
4809
+ if (event.defaultPrevented) {
4795
4810
  return;
4796
4811
  }
4797
- if (!this._element.offsetParent) {
4798
- /**
4799
- * offsetParent === null is equivalent to display: none being set on the element or one
4800
- * of it's parents. In the display: none case the size will become (0, 0) which we do
4801
- * not want to propagate.
4802
- *
4803
- * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetParent
4804
- *
4805
- * You could use checkVisibility() but at the time of writing it's not supported across
4806
- * all Browsers
4807
- *
4808
- * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility
4809
- */
4812
+ const isLeftClick = event.button === 0;
4813
+ if (isLeftClick) {
4814
+ this.accessor.doSetGroupActive(this.group);
4815
+ }
4816
+ }));
4817
+ }
4818
+ setActive(_isGroupActive) {
4819
+ // noop
4820
+ }
4821
+ addTab(tab, index = this.tabs.length) {
4822
+ if (index < 0 || index > this.tabs.length) {
4823
+ throw new Error('invalid location');
4824
+ }
4825
+ this.tabContainer.insertBefore(tab.value.element, this.tabContainer.children[index]);
4826
+ this.tabs = [
4827
+ ...this.tabs.slice(0, index),
4828
+ tab,
4829
+ ...this.tabs.slice(index),
4830
+ ];
4831
+ if (this.selectedIndex < 0) {
4832
+ this.selectedIndex = index;
4833
+ }
4834
+ }
4835
+ delete(id) {
4836
+ const index = this.tabs.findIndex((tab) => tab.value.panel.id === id);
4837
+ const tabToRemove = this.tabs.splice(index, 1)[0];
4838
+ const { value, disposable } = tabToRemove;
4839
+ disposable.dispose();
4840
+ value.dispose();
4841
+ value.element.remove();
4842
+ }
4843
+ setActivePanel(panel) {
4844
+ this.tabs.forEach((tab) => {
4845
+ const isActivePanel = panel.id === tab.value.panel.id;
4846
+ tab.value.setActive(isActivePanel);
4847
+ });
4848
+ }
4849
+ openPanel(panel, index = this.tabs.length) {
4850
+ var _a;
4851
+ if (this.tabs.find((tab) => tab.value.panel.id === panel.id)) {
4852
+ return;
4853
+ }
4854
+ const tab = new Tab(panel, this.accessor, this.group);
4855
+ if (!((_a = panel.view) === null || _a === void 0 ? void 0 : _a.tab)) {
4856
+ throw new Error('invalid header component');
4857
+ }
4858
+ tab.setContent(panel.view.tab);
4859
+ const disposable = new CompositeDisposable(tab.onDragStart((event) => {
4860
+ this._onTabDragStart.fire({ nativeEvent: event, panel });
4861
+ }), tab.onChanged((event) => {
4862
+ const isFloatingGroupsEnabled = !this.accessor.options.disableFloatingGroups;
4863
+ const isFloatingWithOnePanel = this.group.api.location.type === 'floating' &&
4864
+ this.size === 1;
4865
+ if (isFloatingGroupsEnabled &&
4866
+ !isFloatingWithOnePanel &&
4867
+ event.shiftKey) {
4868
+ event.preventDefault();
4869
+ const panel = this.accessor.getGroupPanel(tab.panel.id);
4870
+ const { top, left } = tab.element.getBoundingClientRect();
4871
+ const { top: rootTop, left: rootLeft } = this.accessor.element.getBoundingClientRect();
4872
+ this.accessor.addFloatingGroup(panel, {
4873
+ x: left - rootLeft,
4874
+ y: top - rootTop,
4875
+ }, { inDragMode: true });
4810
4876
  return;
4811
4877
  }
4812
- if (!isInDocument(this._element)) {
4813
- /**
4814
- * since the event is dispatched through requestAnimationFrame there is a small chance
4815
- * the component is no longer attached to the DOM, if that is the case the dimensions
4816
- * are mostly likely all zero and meaningless. we should skip this case.
4817
- */
4878
+ const isLeftClick = event.button === 0;
4879
+ if (!isLeftClick || event.defaultPrevented) {
4818
4880
  return;
4819
4881
  }
4820
- const { width, height } = entry.contentRect;
4821
- this.layout(width, height);
4882
+ if (this.group.activePanel !== panel) {
4883
+ this.group.model.openPanel(panel);
4884
+ }
4885
+ }), tab.onDrop((event) => {
4886
+ this._onDrop.fire({
4887
+ event: event.nativeEvent,
4888
+ index: this.tabs.findIndex((x) => x.value === tab),
4889
+ });
4890
+ }), tab.onWillShowOverlay((event) => {
4891
+ this._onWillShowOverlay.fire(new WillShowOverlayLocationEvent(event, {
4892
+ kind: 'tab',
4893
+ panel: this.group.activePanel,
4894
+ api: this.accessor.api,
4895
+ group: this.group,
4896
+ getData: getPanelData,
4897
+ }));
4822
4898
  }));
4899
+ const value = { value: tab, disposable };
4900
+ this.addTab(value, index);
4823
4901
  }
4824
- }
4825
-
4826
- const nextLayoutId$1 = sequentialNumberGenerator();
4827
- function toTarget(direction) {
4828
- switch (direction) {
4829
- case 'left':
4830
- return 'left';
4831
- case 'right':
4832
- return 'right';
4833
- case 'above':
4834
- return 'top';
4835
- case 'below':
4836
- return 'bottom';
4837
- case 'within':
4838
- default:
4839
- return 'center';
4902
+ closePanel(panel) {
4903
+ this.delete(panel.id);
4904
+ }
4905
+ dispose() {
4906
+ super.dispose();
4907
+ for (const { value, disposable } of this.tabs) {
4908
+ disposable.dispose();
4909
+ value.dispose();
4910
+ }
4911
+ this.tabs = [];
4840
4912
  }
4841
4913
  }
4842
- class BaseGrid extends Resizable {
4843
- get id() {
4844
- return this._id;
4914
+
4915
+ class DockviewUnhandledDragOverEvent {
4916
+ get isAccepted() {
4917
+ return this._isAccepted;
4845
4918
  }
4846
- get size() {
4847
- return this._groups.size;
4919
+ constructor(nativeEvent, target, position, getData, group) {
4920
+ this.nativeEvent = nativeEvent;
4921
+ this.target = target;
4922
+ this.position = position;
4923
+ this.getData = getData;
4924
+ this.group = group;
4925
+ this._isAccepted = false;
4848
4926
  }
4849
- get groups() {
4850
- return Array.from(this._groups.values()).map((_) => _.value);
4927
+ accept() {
4928
+ this._isAccepted = true;
4851
4929
  }
4852
- get width() {
4853
- return this.gridview.width;
4930
+ }
4931
+ const PROPERTY_KEYS = (() => {
4932
+ /**
4933
+ * by readong the keys from an empty value object TypeScript will error
4934
+ * when we add or remove new properties to `DockviewOptions`
4935
+ */
4936
+ const properties = {
4937
+ disableAutoResizing: undefined,
4938
+ hideBorders: undefined,
4939
+ singleTabMode: undefined,
4940
+ disableFloatingGroups: undefined,
4941
+ floatingGroupBounds: undefined,
4942
+ popoutUrl: undefined,
4943
+ defaultRenderer: undefined,
4944
+ debug: undefined,
4945
+ rootOverlayModel: undefined,
4946
+ locked: undefined,
4947
+ disableDnd: undefined,
4948
+ };
4949
+ return Object.keys(properties);
4950
+ })();
4951
+ function isPanelOptionsWithPanel(data) {
4952
+ if (data.referencePanel) {
4953
+ return true;
4854
4954
  }
4855
- get height() {
4856
- return this.gridview.height;
4955
+ return false;
4956
+ }
4957
+ function isPanelOptionsWithGroup(data) {
4958
+ if (data.referenceGroup) {
4959
+ return true;
4857
4960
  }
4858
- get minimumHeight() {
4859
- return this.gridview.minimumHeight;
4961
+ return false;
4962
+ }
4963
+ function isGroupOptionsWithPanel(data) {
4964
+ if (data.referencePanel) {
4965
+ return true;
4860
4966
  }
4861
- get maximumHeight() {
4862
- return this.gridview.maximumHeight;
4967
+ return false;
4968
+ }
4969
+ function isGroupOptionsWithGroup(data) {
4970
+ if (data.referenceGroup) {
4971
+ return true;
4863
4972
  }
4864
- get minimumWidth() {
4865
- return this.gridview.minimumWidth;
4973
+ return false;
4974
+ }
4975
+
4976
+ class DockviewDidDropEvent extends DockviewEvent {
4977
+ get nativeEvent() {
4978
+ return this.options.nativeEvent;
4866
4979
  }
4867
- get maximumWidth() {
4868
- return this.gridview.maximumWidth;
4980
+ get position() {
4981
+ return this.options.position;
4869
4982
  }
4870
- get activeGroup() {
4871
- return this._activeGroup;
4983
+ get panel() {
4984
+ return this.options.panel;
4872
4985
  }
4873
- get locked() {
4874
- return this.gridview.locked;
4986
+ get group() {
4987
+ return this.options.group;
4875
4988
  }
4876
- set locked(value) {
4877
- this.gridview.locked = value;
4989
+ get api() {
4990
+ return this.options.api;
4878
4991
  }
4879
4992
  constructor(options) {
4880
- super(document.createElement('div'), options.disableAutoResizing);
4881
- this._id = nextLayoutId$1.next();
4882
- this._groups = new Map();
4883
- this._onDidLayoutChange = new Emitter();
4884
- this.onDidLayoutChange = this._onDidLayoutChange.event;
4885
- this._onDidRemove = new Emitter();
4886
- this.onDidRemove = this._onDidRemove.event;
4887
- this._onDidAdd = new Emitter();
4888
- this.onDidAdd = this._onDidAdd.event;
4889
- this._onDidActiveChange = new Emitter();
4890
- this.onDidActiveChange = this._onDidActiveChange.event;
4891
- this._bufferOnDidLayoutChange = new TickDelayedEvent();
4892
- this.element.style.height = '100%';
4893
- this.element.style.width = '100%';
4894
- options.parentElement.appendChild(this.element);
4895
- this.gridview = new Gridview(!!options.proportionalLayout, options.styles, options.orientation);
4896
- this.gridview.locked = !!options.locked;
4897
- this.element.appendChild(this.gridview.element);
4898
- this.layout(0, 0, true); // set some elements height/widths
4899
- this.addDisposables(Disposable.from(() => {
4900
- var _a;
4901
- (_a = this.element.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(this.element);
4902
- }), this.gridview.onDidChange(() => {
4903
- this._bufferOnDidLayoutChange.fire();
4904
- }), exports.DockviewEvent.any(this.onDidAdd, this.onDidRemove, this.onDidActiveChange)(() => {
4905
- this._bufferOnDidLayoutChange.fire();
4906
- }), this._bufferOnDidLayoutChange.onEvent(() => {
4907
- this._onDidLayoutChange.fire();
4908
- }), this._bufferOnDidLayoutChange);
4909
- }
4910
- setVisible(panel, visible) {
4911
- this.gridview.setViewVisible(getGridLocation(panel.element), visible);
4912
- this._onDidLayoutChange.fire();
4913
- }
4914
- isVisible(panel) {
4915
- return this.gridview.isViewVisible(getGridLocation(panel.element));
4916
- }
4917
- maximizeGroup(panel) {
4918
- this.gridview.maximizeView(panel);
4919
- this.doSetGroupActive(panel);
4920
- }
4921
- isMaximizedGroup(panel) {
4922
- return this.gridview.maximizedView() === panel;
4923
- }
4924
- exitMaximizedGroup() {
4925
- this.gridview.exitMaximizedView();
4926
- }
4927
- hasMaximizedGroup() {
4928
- return this.gridview.hasMaximizedView();
4929
- }
4930
- get onDidMaximizedGroupChange() {
4931
- return this.gridview.onDidMaximizedNodeChange;
4993
+ super();
4994
+ this.options = options;
4932
4995
  }
4933
- doAddGroup(group, location = [0], size) {
4934
- this.gridview.addView(group, size !== null && size !== void 0 ? size : exports.Sizing.Distribute, location);
4935
- this._onDidAdd.fire(group);
4996
+ getData() {
4997
+ return this.options.getData();
4936
4998
  }
4937
- doRemoveGroup(group, options) {
4938
- if (!this._groups.has(group.id)) {
4939
- throw new Error('invalid operation');
4940
- }
4941
- const item = this._groups.get(group.id);
4942
- const view = this.gridview.remove(group, exports.Sizing.Distribute);
4943
- if (item && !(options === null || options === void 0 ? void 0 : options.skipDispose)) {
4944
- item.disposable.dispose();
4945
- item.value.dispose();
4946
- this._groups.delete(group.id);
4947
- this._onDidRemove.fire(group);
4948
- }
4949
- if (!(options === null || options === void 0 ? void 0 : options.skipActive) && this._activeGroup === group) {
4950
- const groups = Array.from(this._groups.values());
4951
- this.doSetGroupActive(groups.length > 0 ? groups[0].value : undefined);
4952
- }
4953
- return view;
4999
+ }
5000
+ class DockviewWillDropEvent extends DockviewDidDropEvent {
5001
+ get kind() {
5002
+ return this._kind;
4954
5003
  }
4955
- getPanel(id) {
4956
- var _a;
4957
- return (_a = this._groups.get(id)) === null || _a === void 0 ? void 0 : _a.value;
5004
+ constructor(options) {
5005
+ super(options);
5006
+ this._kind = options.kind;
4958
5007
  }
4959
- doSetGroupActive(group) {
4960
- if (this._activeGroup === group) {
4961
- return;
4962
- }
4963
- if (this._activeGroup) {
4964
- this._activeGroup.setActive(false);
4965
- }
4966
- if (group) {
4967
- group.setActive(true);
4968
- }
4969
- this._activeGroup = group;
4970
- this._onDidActiveChange.fire(group);
5008
+ }
5009
+ class WillShowOverlayLocationEvent {
5010
+ get kind() {
5011
+ return this.options.kind;
4971
5012
  }
4972
- removeGroup(group) {
4973
- this.doRemoveGroup(group);
5013
+ get nativeEvent() {
5014
+ return this.event.nativeEvent;
4974
5015
  }
4975
- moveToNext(options) {
4976
- var _a;
4977
- if (!options) {
4978
- options = {};
4979
- }
4980
- if (!options.group) {
4981
- if (!this.activeGroup) {
4982
- return;
4983
- }
4984
- options.group = this.activeGroup;
4985
- }
4986
- const location = getGridLocation(options.group.element);
4987
- const next = (_a = this.gridview.next(location)) === null || _a === void 0 ? void 0 : _a.view;
4988
- this.doSetGroupActive(next);
5016
+ get position() {
5017
+ return this.event.position;
4989
5018
  }
4990
- moveToPrevious(options) {
4991
- var _a;
4992
- if (!options) {
4993
- options = {};
4994
- }
4995
- if (!options.group) {
4996
- if (!this.activeGroup) {
4997
- return;
4998
- }
4999
- options.group = this.activeGroup;
5000
- }
5001
- const location = getGridLocation(options.group.element);
5002
- const next = (_a = this.gridview.previous(location)) === null || _a === void 0 ? void 0 : _a.view;
5003
- this.doSetGroupActive(next);
5019
+ get defaultPrevented() {
5020
+ return this.event.defaultPrevented;
5004
5021
  }
5005
- layout(width, height, forceResize) {
5006
- const different = forceResize !== null && forceResize !== void 0 ? forceResize : (width !== this.width || height !== this.height);
5007
- if (!different) {
5008
- return;
5009
- }
5010
- this.gridview.element.style.height = `${height}px`;
5011
- this.gridview.element.style.width = `${width}px`;
5012
- this.gridview.layout(width, height);
5022
+ get panel() {
5023
+ return this.options.panel;
5013
5024
  }
5014
- dispose() {
5015
- this._onDidActiveChange.dispose();
5016
- this._onDidAdd.dispose();
5017
- this._onDidRemove.dispose();
5018
- this._onDidLayoutChange.dispose();
5019
- for (const group of this.groups) {
5020
- group.dispose();
5021
- }
5022
- this.gridview.dispose();
5023
- super.dispose();
5025
+ get api() {
5026
+ return this.options.api;
5024
5027
  }
5025
- }
5026
-
5027
- class WillFocusEvent extends DockviewEvent {
5028
- constructor() {
5029
- super();
5028
+ get group() {
5029
+ return this.options.group;
5030
5030
  }
5031
- }
5032
- /**
5033
- * A core api implementation that should be used across all panel-like objects
5034
- */
5035
- class PanelApiImpl extends CompositeDisposable {
5036
- get isFocused() {
5037
- return this._isFocused;
5031
+ preventDefault() {
5032
+ this.event.preventDefault();
5038
5033
  }
5039
- get isActive() {
5040
- return this._isActive;
5034
+ getData() {
5035
+ return this.options.getData();
5041
5036
  }
5042
- get isVisible() {
5043
- return this._isVisible;
5037
+ constructor(event, options) {
5038
+ this.event = event;
5039
+ this.options = options;
5044
5040
  }
5045
- get width() {
5046
- return this._width;
5041
+ }
5042
+ class DockviewGroupPanelModel extends CompositeDisposable {
5043
+ get element() {
5044
+ throw new Error('not supported');
5047
5045
  }
5048
- get height() {
5049
- return this._height;
5046
+ get activePanel() {
5047
+ return this._activePanel;
5050
5048
  }
5051
- constructor(id, component) {
5052
- super();
5053
- this.id = id;
5054
- this.component = component;
5055
- this._isFocused = false;
5056
- this._isActive = false;
5057
- this._isVisible = true;
5058
- this._width = 0;
5059
- this._height = 0;
5060
- this._parameters = {};
5061
- this.panelUpdatesDisposable = new MutableDisposable();
5062
- this._onDidDimensionChange = new Emitter();
5063
- this.onDidDimensionsChange = this._onDidDimensionChange.event;
5064
- this._onDidChangeFocus = new Emitter();
5065
- this.onDidFocusChange = this._onDidChangeFocus.event;
5066
- //
5067
- this._onWillFocus = new Emitter();
5068
- this.onWillFocus = this._onWillFocus.event;
5069
- //
5070
- this._onDidVisibilityChange = new Emitter();
5071
- this.onDidVisibilityChange = this._onDidVisibilityChange.event;
5072
- this._onWillVisibilityChange = new Emitter();
5073
- this.onWillVisibilityChange = this._onWillVisibilityChange.event;
5074
- this._onDidActiveChange = new Emitter();
5075
- this.onDidActiveChange = this._onDidActiveChange.event;
5076
- this._onActiveChange = new Emitter();
5077
- this.onActiveChange = this._onActiveChange.event;
5078
- this._onDidParametersChange = new Emitter();
5079
- this.onDidParametersChange = this._onDidParametersChange.event;
5080
- this.addDisposables(this.onDidFocusChange((event) => {
5081
- this._isFocused = event.isFocused;
5082
- }), this.onDidActiveChange((event) => {
5083
- this._isActive = event.isActive;
5084
- }), this.onDidVisibilityChange((event) => {
5085
- this._isVisible = event.isVisible;
5086
- }), this.onDidDimensionsChange((event) => {
5087
- this._width = event.width;
5088
- this._height = event.height;
5089
- }), this.panelUpdatesDisposable, this._onDidDimensionChange, this._onDidChangeFocus, this._onDidVisibilityChange, this._onDidActiveChange, this._onWillFocus, this._onActiveChange, this._onWillFocus, this._onWillVisibilityChange, this._onDidParametersChange);
5049
+ get locked() {
5050
+ return this._locked;
5090
5051
  }
5091
- getParameters() {
5092
- return this._parameters;
5052
+ set locked(value) {
5053
+ this._locked = value;
5054
+ toggleClass(this.container, 'locked-groupview', value === 'no-drop-target' || value);
5093
5055
  }
5094
- initialize(panel) {
5095
- this.panelUpdatesDisposable.value = this._onDidParametersChange.event((parameters) => {
5096
- this._parameters = parameters;
5097
- panel.update({
5098
- params: parameters,
5099
- });
5100
- });
5056
+ get isActive() {
5057
+ return this._isGroupActive;
5101
5058
  }
5102
- setVisible(isVisible) {
5103
- this._onWillVisibilityChange.fire({ isVisible });
5059
+ get panels() {
5060
+ return this._panels;
5104
5061
  }
5105
- setActive() {
5106
- this._onActiveChange.fire();
5062
+ get size() {
5063
+ return this._panels.length;
5107
5064
  }
5108
- updateParameters(parameters) {
5109
- this._onDidParametersChange.fire(parameters);
5065
+ get isEmpty() {
5066
+ return this._panels.length === 0;
5110
5067
  }
5111
- }
5112
-
5113
- class SplitviewPanelApiImpl extends PanelApiImpl {
5114
- //
5115
- constructor(id, component) {
5116
- super(id, component);
5117
- this._onDidConstraintsChangeInternal = new Emitter();
5118
- this.onDidConstraintsChangeInternal = this._onDidConstraintsChangeInternal.event;
5119
- //
5120
- this._onDidConstraintsChange = new Emitter({
5121
- replay: true,
5122
- });
5123
- this.onDidConstraintsChange = this._onDidConstraintsChange.event;
5124
- //
5125
- this._onDidSizeChange = new Emitter();
5126
- this.onDidSizeChange = this._onDidSizeChange.event;
5127
- this.addDisposables(this._onDidConstraintsChangeInternal, this._onDidConstraintsChange, this._onDidSizeChange);
5068
+ get hasWatermark() {
5069
+ return !!(this.watermark && this.container.contains(this.watermark.element));
5128
5070
  }
5129
- setConstraints(value) {
5130
- this._onDidConstraintsChangeInternal.fire(value);
5071
+ get header() {
5072
+ return this.tabsContainer;
5131
5073
  }
5132
- setSize(event) {
5133
- this._onDidSizeChange.fire(event);
5074
+ get isContentFocused() {
5075
+ if (!document.activeElement) {
5076
+ return false;
5077
+ }
5078
+ return isAncestor(document.activeElement, this.contentContainer.element);
5134
5079
  }
5135
- }
5136
-
5137
- class PaneviewPanelApiImpl extends SplitviewPanelApiImpl {
5138
- set pane(pane) {
5139
- this._pane = pane;
5080
+ get location() {
5081
+ return this._location;
5140
5082
  }
5141
- constructor(id, component) {
5142
- super(id, component);
5143
- this._onDidExpansionChange = new Emitter({
5144
- replay: true,
5083
+ set location(value) {
5084
+ this._location = value;
5085
+ toggleClass(this.container, 'dv-groupview-floating', false);
5086
+ toggleClass(this.container, 'dv-groupview-popout', false);
5087
+ switch (value.type) {
5088
+ case 'grid':
5089
+ this.contentContainer.dropTarget.setTargetZones([
5090
+ 'top',
5091
+ 'bottom',
5092
+ 'left',
5093
+ 'right',
5094
+ 'center',
5095
+ ]);
5096
+ break;
5097
+ case 'floating':
5098
+ this.contentContainer.dropTarget.setTargetZones(['center']);
5099
+ this.contentContainer.dropTarget.setTargetZones(value
5100
+ ? ['center']
5101
+ : ['top', 'bottom', 'left', 'right', 'center']);
5102
+ toggleClass(this.container, 'dv-groupview-floating', true);
5103
+ break;
5104
+ case 'popout':
5105
+ this.contentContainer.dropTarget.setTargetZones(['center']);
5106
+ toggleClass(this.container, 'dv-groupview-popout', true);
5107
+ break;
5108
+ }
5109
+ this.groupPanel.api._onDidLocationChange.fire({
5110
+ location: this.location,
5145
5111
  });
5146
- this.onDidExpansionChange = this._onDidExpansionChange.event;
5147
- this._onMouseEnter = new Emitter({});
5148
- this.onMouseEnter = this._onMouseEnter.event;
5149
- this._onMouseLeave = new Emitter({});
5150
- this.onMouseLeave = this._onMouseLeave.event;
5151
- this.addDisposables(this._onDidExpansionChange, this._onMouseEnter, this._onMouseLeave);
5152
- }
5153
- setExpanded(isExpanded) {
5154
- var _a;
5155
- (_a = this._pane) === null || _a === void 0 ? void 0 : _a.setExpanded(isExpanded);
5156
5112
  }
5157
- get isExpanded() {
5113
+ constructor(container, accessor, id, options, groupPanel) {
5158
5114
  var _a;
5159
- return !!((_a = this._pane) === null || _a === void 0 ? void 0 : _a.isExpanded());
5160
- }
5161
- }
5162
-
5163
- class BasePanelView extends CompositeDisposable {
5164
- get element() {
5165
- return this._element;
5115
+ super();
5116
+ this.container = container;
5117
+ this.accessor = accessor;
5118
+ this.id = id;
5119
+ this.options = options;
5120
+ this.groupPanel = groupPanel;
5121
+ this._isGroupActive = false;
5122
+ this._locked = false;
5123
+ this._location = { type: 'grid' };
5124
+ this.mostRecentlyUsed = [];
5125
+ this._onDidChange = new Emitter();
5126
+ this.onDidChange = this._onDidChange.event;
5127
+ this._width = 0;
5128
+ this._height = 0;
5129
+ this._panels = [];
5130
+ this._panelDisposables = new Map();
5131
+ this._onMove = new Emitter();
5132
+ this.onMove = this._onMove.event;
5133
+ this._onDidDrop = new Emitter();
5134
+ this.onDidDrop = this._onDidDrop.event;
5135
+ this._onWillDrop = new Emitter();
5136
+ this.onWillDrop = this._onWillDrop.event;
5137
+ this._onWillShowOverlay = new Emitter();
5138
+ this.onWillShowOverlay = this._onWillShowOverlay.event;
5139
+ this._onTabDragStart = new Emitter();
5140
+ this.onTabDragStart = this._onTabDragStart.event;
5141
+ this._onGroupDragStart = new Emitter();
5142
+ this.onGroupDragStart = this._onGroupDragStart.event;
5143
+ this._onDidAddPanel = new Emitter();
5144
+ this.onDidAddPanel = this._onDidAddPanel.event;
5145
+ this._onDidPanelTitleChange = new Emitter();
5146
+ this.onDidPanelTitleChange = this._onDidPanelTitleChange.event;
5147
+ this._onDidPanelParametersChange = new Emitter();
5148
+ this.onDidPanelParametersChange = this._onDidPanelParametersChange.event;
5149
+ this._onDidRemovePanel = new Emitter();
5150
+ this.onDidRemovePanel = this._onDidRemovePanel.event;
5151
+ this._onDidActivePanelChange = new Emitter();
5152
+ this.onDidActivePanelChange = this._onDidActivePanelChange.event;
5153
+ this._onUnhandledDragOverEvent = new Emitter();
5154
+ this.onUnhandledDragOverEvent = this._onUnhandledDragOverEvent.event;
5155
+ this._overwriteRenderContainer = null;
5156
+ toggleClass(this.container, 'groupview', true);
5157
+ this._api = new DockviewApi(this.accessor);
5158
+ this.tabsContainer = new TabsContainer(this.accessor, this.groupPanel);
5159
+ this.contentContainer = new ContentContainer(this.accessor, this);
5160
+ container.append(this.tabsContainer.element, this.contentContainer.element);
5161
+ this.header.hidden = !!options.hideHeader;
5162
+ this.locked = (_a = options.locked) !== null && _a !== void 0 ? _a : false;
5163
+ this.addDisposables(this._onTabDragStart, this._onGroupDragStart, this._onWillShowOverlay, this.tabsContainer.onTabDragStart((event) => {
5164
+ this._onTabDragStart.fire(event);
5165
+ }), this.tabsContainer.onGroupDragStart((event) => {
5166
+ this._onGroupDragStart.fire(event);
5167
+ }), this.tabsContainer.onDrop((event) => {
5168
+ this.handleDropEvent('header', event.event, 'center', event.index);
5169
+ }), this.contentContainer.onDidFocus(() => {
5170
+ this.accessor.doSetGroupActive(this.groupPanel);
5171
+ }), this.contentContainer.onDidBlur(() => {
5172
+ // noop
5173
+ }), this.contentContainer.dropTarget.onDrop((event) => {
5174
+ this.handleDropEvent('content', event.nativeEvent, event.position);
5175
+ }), this.tabsContainer.onWillShowOverlay((event) => {
5176
+ this._onWillShowOverlay.fire(event);
5177
+ }), this.contentContainer.dropTarget.onWillShowOverlay((event) => {
5178
+ this._onWillShowOverlay.fire(new WillShowOverlayLocationEvent(event, {
5179
+ kind: 'content',
5180
+ panel: this.activePanel,
5181
+ api: this._api,
5182
+ group: this.groupPanel,
5183
+ getData: getPanelData,
5184
+ }));
5185
+ }), this._onMove, this._onDidChange, this._onDidDrop, this._onWillDrop, this._onDidAddPanel, this._onDidRemovePanel, this._onDidActivePanelChange, this._onUnhandledDragOverEvent);
5166
5186
  }
5167
- get width() {
5168
- return this._width;
5187
+ focusContent() {
5188
+ this.contentContainer.element.focus();
5169
5189
  }
5170
- get height() {
5171
- return this._height;
5190
+ set renderContainer(value) {
5191
+ this.panels.forEach((panel) => {
5192
+ this.renderContainer.detatch(panel);
5193
+ });
5194
+ this._overwriteRenderContainer = value;
5195
+ this.panels.forEach((panel) => {
5196
+ this.rerender(panel);
5197
+ });
5172
5198
  }
5173
- get params() {
5199
+ get renderContainer() {
5174
5200
  var _a;
5175
- return (_a = this._params) === null || _a === void 0 ? void 0 : _a.params;
5176
- }
5177
- constructor(id, component, api) {
5178
- super();
5179
- this.id = id;
5180
- this.component = component;
5181
- this.api = api;
5182
- this._height = 0;
5183
- this._width = 0;
5184
- this._element = document.createElement('div');
5185
- this._element.tabIndex = -1;
5186
- this._element.style.outline = 'none';
5187
- this._element.style.height = '100%';
5188
- this._element.style.width = '100%';
5189
- this._element.style.overflow = 'hidden';
5190
- const focusTracker = trackFocus(this._element);
5191
- this.addDisposables(this.api, focusTracker.onDidFocus(() => {
5192
- this.api._onDidChangeFocus.fire({ isFocused: true });
5193
- }), focusTracker.onDidBlur(() => {
5194
- this.api._onDidChangeFocus.fire({ isFocused: false });
5195
- }), focusTracker);
5201
+ return ((_a = this._overwriteRenderContainer) !== null && _a !== void 0 ? _a : this.accessor.overlayRenderContainer);
5196
5202
  }
5197
- focus() {
5198
- const event = new WillFocusEvent();
5199
- this.api._onWillFocus.fire(event);
5200
- if (event.defaultPrevented) {
5201
- return;
5203
+ initialize() {
5204
+ if (this.options.panels) {
5205
+ this.options.panels.forEach((panel) => {
5206
+ this.doAddPanel(panel);
5207
+ });
5202
5208
  }
5203
- this._element.focus();
5204
- }
5205
- layout(width, height) {
5206
- this._width = width;
5207
- this._height = height;
5208
- this.api._onDidDimensionChange.fire({ width, height });
5209
- if (this.part) {
5210
- if (this._params) {
5211
- this.part.update(this._params.params);
5212
- }
5209
+ if (this.options.activePanel) {
5210
+ this.openPanel(this.options.activePanel);
5211
+ }
5212
+ // must be run after the constructor otherwise this.parent may not be
5213
+ // correctly initialized
5214
+ this.setActive(this.isActive, true);
5215
+ this.updateContainer();
5216
+ if (this.accessor.options.createRightHeaderActionComponent) {
5217
+ this._rightHeaderActions =
5218
+ this.accessor.options.createRightHeaderActionComponent(this.groupPanel);
5219
+ this.addDisposables(this._rightHeaderActions);
5220
+ this._rightHeaderActions.init({
5221
+ containerApi: this._api,
5222
+ api: this.groupPanel.api,
5223
+ group: this.groupPanel,
5224
+ });
5225
+ this.tabsContainer.setRightActionsElement(this._rightHeaderActions.element);
5226
+ }
5227
+ if (this.accessor.options.createLeftHeaderActionComponent) {
5228
+ this._leftHeaderActions =
5229
+ this.accessor.options.createLeftHeaderActionComponent(this.groupPanel);
5230
+ this.addDisposables(this._leftHeaderActions);
5231
+ this._leftHeaderActions.init({
5232
+ containerApi: this._api,
5233
+ api: this.groupPanel.api,
5234
+ group: this.groupPanel,
5235
+ });
5236
+ this.tabsContainer.setLeftActionsElement(this._leftHeaderActions.element);
5237
+ }
5238
+ if (this.accessor.options.createPrefixHeaderActionComponent) {
5239
+ this._prefixHeaderActions =
5240
+ this.accessor.options.createPrefixHeaderActionComponent(this.groupPanel);
5241
+ this.addDisposables(this._prefixHeaderActions);
5242
+ this._prefixHeaderActions.init({
5243
+ containerApi: this._api,
5244
+ api: this.groupPanel.api,
5245
+ group: this.groupPanel,
5246
+ });
5247
+ this.tabsContainer.setPrefixActionsElement(this._prefixHeaderActions.element);
5213
5248
  }
5214
5249
  }
5215
- init(parameters) {
5216
- this._params = parameters;
5217
- this.part = this.getComponent();
5250
+ rerender(panel) {
5251
+ this.contentContainer.renderPanel(panel, { asActive: false });
5218
5252
  }
5219
- update(event) {
5220
- var _a, _b;
5221
- // merge the new parameters with the existing parameters
5222
- this._params = Object.assign(Object.assign({}, this._params), { params: Object.assign(Object.assign({}, (_a = this._params) === null || _a === void 0 ? void 0 : _a.params), event.params) });
5223
- /**
5224
- * delete new keys that have a value of undefined,
5225
- * allow values of null
5226
- */
5227
- for (const key of Object.keys(event.params)) {
5228
- if (event.params[key] === undefined) {
5229
- delete this._params.params[key];
5230
- }
5231
- }
5232
- // update the view with the updated props
5233
- (_b = this.part) === null || _b === void 0 ? void 0 : _b.update({ params: this._params.params });
5253
+ indexOf(panel) {
5254
+ return this.tabsContainer.indexOf(panel.id);
5234
5255
  }
5235
5256
  toJSON() {
5236
- var _a, _b;
5237
- const params = (_b = (_a = this._params) === null || _a === void 0 ? void 0 : _a.params) !== null && _b !== void 0 ? _b : {};
5238
- return {
5257
+ var _a;
5258
+ const result = {
5259
+ views: this.tabsContainer.panels,
5260
+ activeView: (_a = this._activePanel) === null || _a === void 0 ? void 0 : _a.id,
5239
5261
  id: this.id,
5240
- component: this.component,
5241
- params: Object.keys(params).length > 0 ? params : undefined,
5242
5262
  };
5263
+ if (this.locked !== false) {
5264
+ result.locked = this.locked;
5265
+ }
5266
+ if (this.header.hidden) {
5267
+ result.hideHeader = true;
5268
+ }
5269
+ return result;
5243
5270
  }
5244
- dispose() {
5245
- var _a;
5246
- this.api.dispose();
5247
- (_a = this.part) === null || _a === void 0 ? void 0 : _a.dispose();
5248
- super.dispose();
5249
- }
5250
- }
5251
-
5252
- class PaneviewPanel extends BasePanelView {
5253
- set orientation(value) {
5254
- this._orientation = value;
5255
- }
5256
- get orientation() {
5257
- return this._orientation;
5258
- }
5259
- get minimumSize() {
5260
- const headerSize = this.headerSize;
5261
- const expanded = this.isExpanded();
5262
- const minimumBodySize = expanded ? this._minimumBodySize : 0;
5263
- return headerSize + minimumBodySize;
5264
- }
5265
- get maximumSize() {
5266
- const headerSize = this.headerSize;
5267
- const expanded = this.isExpanded();
5268
- const maximumBodySize = expanded ? this._maximumBodySize : 0;
5269
- return headerSize + maximumBodySize;
5270
- }
5271
- get size() {
5272
- return this._size;
5273
- }
5274
- get orthogonalSize() {
5275
- return this._orthogonalSize;
5276
- }
5277
- set orthogonalSize(size) {
5278
- this._orthogonalSize = size;
5279
- }
5280
- get minimumBodySize() {
5281
- return this._minimumBodySize;
5282
- }
5283
- set minimumBodySize(value) {
5284
- this._minimumBodySize = typeof value === 'number' ? value : 0;
5285
- }
5286
- get maximumBodySize() {
5287
- return this._maximumBodySize;
5288
- }
5289
- set maximumBodySize(value) {
5290
- this._maximumBodySize =
5291
- typeof value === 'number' ? value : Number.POSITIVE_INFINITY;
5292
- }
5293
- get headerVisible() {
5294
- return this._headerVisible;
5295
- }
5296
- set headerVisible(value) {
5297
- this._headerVisible = value;
5298
- this.header.style.display = value ? '' : 'none';
5271
+ moveToNext(options) {
5272
+ if (!options) {
5273
+ options = {};
5274
+ }
5275
+ if (!options.panel) {
5276
+ options.panel = this.activePanel;
5277
+ }
5278
+ const index = options.panel ? this.panels.indexOf(options.panel) : -1;
5279
+ let normalizedIndex;
5280
+ if (index < this.panels.length - 1) {
5281
+ normalizedIndex = index + 1;
5282
+ }
5283
+ else if (!options.suppressRoll) {
5284
+ normalizedIndex = 0;
5285
+ }
5286
+ else {
5287
+ return;
5288
+ }
5289
+ this.openPanel(this.panels[normalizedIndex]);
5299
5290
  }
5300
- constructor(id, component, headerComponent, orientation, isExpanded, isHeaderVisible) {
5301
- super(id, component, new PaneviewPanelApiImpl(id, component));
5302
- this.headerComponent = headerComponent;
5303
- this._onDidChangeExpansionState = new Emitter({ replay: true });
5304
- this.onDidChangeExpansionState = this._onDidChangeExpansionState.event;
5305
- this._onDidChange = new Emitter();
5306
- this.onDidChange = this._onDidChange.event;
5307
- this.headerSize = 22;
5308
- this._orthogonalSize = 0;
5309
- this._size = 0;
5310
- this._minimumBodySize = 100;
5311
- this._maximumBodySize = Number.POSITIVE_INFINITY;
5312
- this._isExpanded = false;
5313
- this.expandedSize = 0;
5314
- this.api.pane = this; // TODO cannot use 'this' before 'super'
5315
- this.api.initialize(this);
5316
- this._isExpanded = isExpanded;
5317
- this._headerVisible = isHeaderVisible;
5318
- this._onDidChangeExpansionState.fire(this.isExpanded()); // initialize value
5319
- this._orientation = orientation;
5320
- this.element.classList.add('pane');
5321
- this.addDisposables(this.api.onWillVisibilityChange((event) => {
5322
- const { isVisible } = event;
5323
- const { accessor } = this._params;
5324
- accessor.setVisible(this, isVisible);
5325
- }), this.api.onDidSizeChange((event) => {
5326
- this._onDidChange.fire({ size: event.size });
5327
- }), addDisposableListener(this.element, 'mouseenter', (ev) => {
5328
- this.api._onMouseEnter.fire(ev);
5329
- }), addDisposableListener(this.element, 'mouseleave', (ev) => {
5330
- this.api._onMouseLeave.fire(ev);
5331
- }));
5332
- this.addDisposables(this._onDidChangeExpansionState, this.onDidChangeExpansionState((isPanelExpanded) => {
5333
- this.api._onDidExpansionChange.fire({
5334
- isExpanded: isPanelExpanded,
5335
- });
5336
- }), this.api.onDidFocusChange((e) => {
5337
- if (!this.header) {
5338
- return;
5339
- }
5340
- if (e.isFocused) {
5341
- addClasses(this.header, 'focused');
5342
- }
5343
- else {
5344
- removeClasses(this.header, 'focused');
5345
- }
5346
- }));
5347
- this.renderOnce();
5291
+ moveToPrevious(options) {
5292
+ if (!options) {
5293
+ options = {};
5294
+ }
5295
+ if (!options.panel) {
5296
+ options.panel = this.activePanel;
5297
+ }
5298
+ if (!options.panel) {
5299
+ return;
5300
+ }
5301
+ const index = this.panels.indexOf(options.panel);
5302
+ let normalizedIndex;
5303
+ if (index > 0) {
5304
+ normalizedIndex = index - 1;
5305
+ }
5306
+ else if (!options.suppressRoll) {
5307
+ normalizedIndex = this.panels.length - 1;
5308
+ }
5309
+ else {
5310
+ return;
5311
+ }
5312
+ this.openPanel(this.panels[normalizedIndex]);
5348
5313
  }
5349
- setVisible(isVisible) {
5350
- this.api._onDidVisibilityChange.fire({ isVisible });
5314
+ containsPanel(panel) {
5315
+ return this.panels.includes(panel);
5351
5316
  }
5352
- setActive(isActive) {
5353
- this.api._onDidActiveChange.fire({ isActive });
5317
+ init(_params) {
5318
+ //noop
5354
5319
  }
5355
- isExpanded() {
5356
- return this._isExpanded;
5320
+ update(_params) {
5321
+ //noop
5357
5322
  }
5358
- setExpanded(expanded) {
5359
- if (this._isExpanded === expanded) {
5323
+ focus() {
5324
+ var _a;
5325
+ (_a = this._activePanel) === null || _a === void 0 ? void 0 : _a.focus();
5326
+ }
5327
+ openPanel(panel, options = {}) {
5328
+ /**
5329
+ * set the panel group
5330
+ * add the panel
5331
+ * check if group active
5332
+ * check if panel active
5333
+ */
5334
+ if (typeof options.index !== 'number' ||
5335
+ options.index > this.panels.length) {
5336
+ options.index = this.panels.length;
5337
+ }
5338
+ const skipSetActive = !!options.skipSetActive;
5339
+ // ensure the group is updated before we fire any events
5340
+ panel.updateParentGroup(this.groupPanel, {
5341
+ skipSetActive: options.skipSetActive,
5342
+ });
5343
+ this.doAddPanel(panel, options.index, {
5344
+ skipSetActive: skipSetActive,
5345
+ });
5346
+ if (this._activePanel === panel) {
5347
+ this.contentContainer.renderPanel(panel, { asActive: true });
5360
5348
  return;
5361
5349
  }
5362
- this._isExpanded = expanded;
5363
- if (expanded) {
5364
- if (this.animationTimer) {
5365
- clearTimeout(this.animationTimer);
5366
- }
5367
- if (this.body) {
5368
- this.element.appendChild(this.body);
5350
+ if (!skipSetActive) {
5351
+ this.doSetActivePanel(panel);
5352
+ }
5353
+ if (!options.skipSetGroupActive) {
5354
+ this.accessor.doSetGroupActive(this.groupPanel);
5355
+ }
5356
+ if (!options.skipSetActive) {
5357
+ this.updateContainer();
5358
+ }
5359
+ }
5360
+ removePanel(groupItemOrId, options = {
5361
+ skipSetActive: false,
5362
+ }) {
5363
+ const id = typeof groupItemOrId === 'string'
5364
+ ? groupItemOrId
5365
+ : groupItemOrId.id;
5366
+ const panelToRemove = this._panels.find((panel) => panel.id === id);
5367
+ if (!panelToRemove) {
5368
+ throw new Error('invalid operation');
5369
+ }
5370
+ return this._removePanel(panelToRemove, options);
5371
+ }
5372
+ closeAllPanels() {
5373
+ if (this.panels.length > 0) {
5374
+ // take a copy since we will be edting the array as we iterate through
5375
+ const arrPanelCpy = [...this.panels];
5376
+ for (const panel of arrPanelCpy) {
5377
+ this.doClose(panel);
5369
5378
  }
5370
5379
  }
5371
5380
  else {
5372
- this.animationTimer = setTimeout(() => {
5373
- var _a;
5374
- (_a = this.body) === null || _a === void 0 ? void 0 : _a.remove();
5375
- }, 200);
5381
+ this.accessor.removeGroup(this.groupPanel);
5376
5382
  }
5377
- this._onDidChange.fire(expanded ? { size: this.width } : {});
5378
- this._onDidChangeExpansionState.fire(expanded);
5379
5383
  }
5380
- layout(size, orthogonalSize) {
5381
- this._size = size;
5382
- this._orthogonalSize = orthogonalSize;
5383
- const [width, height] = this.orientation === exports.Orientation.HORIZONTAL
5384
- ? [size, orthogonalSize]
5385
- : [orthogonalSize, size];
5386
- if (this.isExpanded()) {
5387
- this.expandedSize = width;
5384
+ closePanel(panel) {
5385
+ this.doClose(panel);
5386
+ }
5387
+ doClose(panel) {
5388
+ this.accessor.removePanel(panel);
5389
+ }
5390
+ isPanelActive(panel) {
5391
+ return this._activePanel === panel;
5392
+ }
5393
+ updateActions(element) {
5394
+ this.tabsContainer.setRightActionsElement(element);
5395
+ }
5396
+ setActive(isGroupActive, force = false) {
5397
+ if (!force && this.isActive === isGroupActive) {
5398
+ return;
5388
5399
  }
5389
- super.layout(width, height);
5400
+ this._isGroupActive = isGroupActive;
5401
+ toggleClass(this.container, 'active-group', isGroupActive);
5402
+ toggleClass(this.container, 'inactive-group', !isGroupActive);
5403
+ this.tabsContainer.setActive(this.isActive);
5404
+ if (!this._activePanel && this.panels.length > 0) {
5405
+ this.doSetActivePanel(this.panels[0]);
5406
+ }
5407
+ this.updateContainer();
5390
5408
  }
5391
- init(parameters) {
5392
- var _a, _b;
5393
- super.init(parameters);
5394
- if (typeof parameters.minimumBodySize === 'number') {
5395
- this.minimumBodySize = parameters.minimumBodySize;
5409
+ layout(width, height) {
5410
+ var _a;
5411
+ this._width = width;
5412
+ this._height = height;
5413
+ this.contentContainer.layout(this._width, this._height);
5414
+ if ((_a = this._activePanel) === null || _a === void 0 ? void 0 : _a.layout) {
5415
+ this._activePanel.layout(this._width, this._height);
5396
5416
  }
5397
- if (typeof parameters.maximumBodySize === 'number') {
5398
- this.maximumBodySize = parameters.maximumBodySize;
5417
+ }
5418
+ _removePanel(panel, options) {
5419
+ const isActivePanel = this._activePanel === panel;
5420
+ this.doRemovePanel(panel);
5421
+ if (isActivePanel && this.panels.length > 0) {
5422
+ const nextPanel = this.mostRecentlyUsed[0];
5423
+ this.openPanel(nextPanel, {
5424
+ skipSetActive: options.skipSetActive,
5425
+ skipSetGroupActive: options.skipSetActiveGroup,
5426
+ });
5399
5427
  }
5400
- this.bodyPart = this.getBodyComponent();
5401
- this.headerPart = this.getHeaderComponent();
5402
- this.bodyPart.init(Object.assign(Object.assign({}, parameters), { api: this.api }));
5403
- this.headerPart.init(Object.assign(Object.assign({}, parameters), { api: this.api }));
5404
- (_a = this.body) === null || _a === void 0 ? void 0 : _a.append(this.bodyPart.element);
5405
- (_b = this.header) === null || _b === void 0 ? void 0 : _b.append(this.headerPart.element);
5406
- if (typeof parameters.isExpanded === 'boolean') {
5407
- this.setExpanded(parameters.isExpanded);
5428
+ if (this._activePanel && this.panels.length === 0) {
5429
+ this.doSetActivePanel(undefined);
5430
+ }
5431
+ if (!options.skipSetActive) {
5432
+ this.updateContainer();
5408
5433
  }
5434
+ return panel;
5409
5435
  }
5410
- toJSON() {
5411
- const params = this._params;
5412
- return Object.assign(Object.assign({}, super.toJSON()), { headerComponent: this.headerComponent, title: params.title });
5436
+ doRemovePanel(panel) {
5437
+ const index = this.panels.indexOf(panel);
5438
+ if (this._activePanel === panel) {
5439
+ this.contentContainer.closePanel();
5440
+ }
5441
+ this.tabsContainer.delete(panel.id);
5442
+ this._panels.splice(index, 1);
5443
+ if (this.mostRecentlyUsed.includes(panel)) {
5444
+ const index = this.mostRecentlyUsed.indexOf(panel);
5445
+ this.mostRecentlyUsed.splice(index, 1);
5446
+ }
5447
+ const disposable = this._panelDisposables.get(panel.id);
5448
+ if (disposable) {
5449
+ disposable.dispose();
5450
+ this._panelDisposables.delete(panel.id);
5451
+ }
5452
+ this._onDidRemovePanel.fire({ panel });
5413
5453
  }
5414
- renderOnce() {
5415
- this.header = document.createElement('div');
5416
- this.header.tabIndex = 0;
5417
- this.header.className = 'pane-header';
5418
- this.header.style.height = `${this.headerSize}px`;
5419
- this.header.style.lineHeight = `${this.headerSize}px`;
5420
- this.header.style.minHeight = `${this.headerSize}px`;
5421
- this.header.style.maxHeight = `${this.headerSize}px`;
5422
- this.element.appendChild(this.header);
5423
- this.body = document.createElement('div');
5424
- this.body.className = 'pane-body';
5425
- this.element.appendChild(this.body);
5454
+ doAddPanel(panel, index = this.panels.length, options = { skipSetActive: false }) {
5455
+ const existingPanel = this._panels.indexOf(panel);
5456
+ const hasExistingPanel = existingPanel > -1;
5457
+ this.tabsContainer.show();
5458
+ this.contentContainer.show();
5459
+ this.tabsContainer.openPanel(panel, index);
5460
+ if (!options.skipSetActive) {
5461
+ this.contentContainer.openPanel(panel);
5462
+ }
5463
+ if (hasExistingPanel) {
5464
+ // TODO - need to ensure ordering hasn't changed and if it has need to re-order this.panels
5465
+ return;
5466
+ }
5467
+ this.updateMru(panel);
5468
+ this.panels.splice(index, 0, panel);
5469
+ this._panelDisposables.set(panel.id, new CompositeDisposable(panel.api.onDidTitleChange((event) => this._onDidPanelTitleChange.fire(event)), panel.api.onDidParametersChange((event) => this._onDidPanelParametersChange.fire(event))));
5470
+ this._onDidAddPanel.fire({ panel });
5426
5471
  }
5427
- // TODO slightly hacky by-pass of the component to create a body and header component
5428
- getComponent() {
5429
- return {
5430
- update: (params) => {
5431
- var _a, _b;
5432
- (_a = this.bodyPart) === null || _a === void 0 ? void 0 : _a.update({ params });
5433
- (_b = this.headerPart) === null || _b === void 0 ? void 0 : _b.update({ params });
5434
- },
5435
- dispose: () => {
5436
- var _a, _b;
5437
- (_a = this.bodyPart) === null || _a === void 0 ? void 0 : _a.dispose();
5438
- (_b = this.headerPart) === null || _b === void 0 ? void 0 : _b.dispose();
5439
- },
5440
- };
5472
+ doSetActivePanel(panel) {
5473
+ if (this._activePanel === panel) {
5474
+ return;
5475
+ }
5476
+ this._activePanel = panel;
5477
+ if (panel) {
5478
+ this.tabsContainer.setActivePanel(panel);
5479
+ panel.layout(this._width, this._height);
5480
+ this.updateMru(panel);
5481
+ this._onDidActivePanelChange.fire({
5482
+ panel,
5483
+ });
5484
+ }
5441
5485
  }
5442
- }
5443
-
5444
- class DraggablePaneviewPanel extends PaneviewPanel {
5445
- constructor(accessor, id, component, headerComponent, orientation, isExpanded, disableDnd) {
5446
- super(id, component, headerComponent, orientation, isExpanded, true);
5447
- this.accessor = accessor;
5448
- this._onDidDrop = new Emitter();
5449
- this.onDidDrop = this._onDidDrop.event;
5450
- if (!disableDnd) {
5451
- this.initDragFeatures();
5486
+ updateMru(panel) {
5487
+ if (this.mostRecentlyUsed.includes(panel)) {
5488
+ this.mostRecentlyUsed.splice(this.mostRecentlyUsed.indexOf(panel), 1);
5452
5489
  }
5490
+ this.mostRecentlyUsed = [panel, ...this.mostRecentlyUsed];
5453
5491
  }
5454
- initDragFeatures() {
5455
- if (!this.header) {
5492
+ updateContainer() {
5493
+ var _a, _b;
5494
+ toggleClass(this.container, 'empty', this.isEmpty);
5495
+ this.panels.forEach((panel) => panel.runEvents());
5496
+ if (this.isEmpty && !this.watermark) {
5497
+ const watermark = this.accessor.createWatermarkComponent();
5498
+ watermark.init({
5499
+ containerApi: this._api,
5500
+ group: this.groupPanel,
5501
+ });
5502
+ this.watermark = watermark;
5503
+ addDisposableListener(this.watermark.element, 'click', () => {
5504
+ if (!this.isActive) {
5505
+ this.accessor.doSetGroupActive(this.groupPanel);
5506
+ }
5507
+ });
5508
+ this.tabsContainer.hide();
5509
+ this.contentContainer.element.appendChild(this.watermark.element);
5510
+ this.watermark.updateParentGroup(this.groupPanel, true);
5511
+ }
5512
+ if (!this.isEmpty && this.watermark) {
5513
+ this.watermark.element.remove();
5514
+ (_b = (_a = this.watermark).dispose) === null || _b === void 0 ? void 0 : _b.call(_a);
5515
+ this.watermark = undefined;
5516
+ this.tabsContainer.show();
5517
+ }
5518
+ }
5519
+ canDisplayOverlay(event, position, target) {
5520
+ const firedEvent = new DockviewUnhandledDragOverEvent(event, target, position, getPanelData, this.accessor.getPanel(this.id));
5521
+ this._onUnhandledDragOverEvent.fire(firedEvent);
5522
+ return firedEvent.isAccepted;
5523
+ }
5524
+ handleDropEvent(type, event, position, index) {
5525
+ if (this.locked === 'no-drop-target') {
5456
5526
  return;
5457
5527
  }
5458
- const id = this.id;
5459
- const accessorId = this.accessor.id;
5460
- this.header.draggable = true;
5461
- this.handler = new (class PaneDragHandler extends DragHandler {
5462
- getData() {
5463
- LocalSelectionTransfer.getInstance().setData([new PaneTransfer(accessorId, id)], PaneTransfer.prototype);
5464
- return {
5465
- dispose: () => {
5466
- LocalSelectionTransfer.getInstance().clearData(PaneTransfer.prototype);
5467
- },
5468
- };
5528
+ function getKind() {
5529
+ switch (type) {
5530
+ case 'header':
5531
+ return typeof index === 'number' ? 'tab' : 'header_space';
5532
+ case 'content':
5533
+ return 'content';
5469
5534
  }
5470
- })(this.header);
5471
- this.target = new Droptarget(this.element, {
5472
- acceptedTargetZones: ['top', 'bottom'],
5473
- overlayModel: {
5474
- activationSize: { type: 'percentage', value: 50 },
5475
- },
5476
- canDisplayOverlay: (event) => {
5477
- const data = getPaneData();
5478
- if (data) {
5479
- if (data.paneId !== this.id &&
5480
- data.viewId === this.accessor.id) {
5481
- return true;
5482
- }
5483
- }
5484
- if (this.accessor.options.showDndOverlay) {
5485
- return this.accessor.options.showDndOverlay({
5486
- nativeEvent: event,
5487
- getData: getPaneData,
5488
- panel: this,
5489
- });
5490
- }
5491
- return false;
5492
- },
5535
+ }
5536
+ const panel = typeof index === 'number' ? this.panels[index] : undefined;
5537
+ const willDropEvent = new DockviewWillDropEvent({
5538
+ nativeEvent: event,
5539
+ position,
5540
+ panel,
5541
+ getData: () => getPanelData(),
5542
+ kind: getKind(),
5543
+ group: this.groupPanel,
5544
+ api: this._api,
5493
5545
  });
5494
- this.addDisposables(this._onDidDrop, this.handler, this.target, this.target.onDrop((event) => {
5495
- this.onDrop(event);
5496
- }));
5497
- }
5498
- onDrop(event) {
5499
- const data = getPaneData();
5500
- if (!data || data.viewId !== this.accessor.id) {
5501
- // if there is no local drag event for this panel
5502
- // or if the drag event was creating by another Paneview instance
5503
- this._onDidDrop.fire(Object.assign(Object.assign({}, event), { panel: this, api: new PaneviewApi(this.accessor), getData: getPaneData }));
5546
+ this._onWillDrop.fire(willDropEvent);
5547
+ if (willDropEvent.defaultPrevented) {
5504
5548
  return;
5505
5549
  }
5506
- const containerApi = this._params
5507
- .containerApi;
5508
- const panelId = data.paneId;
5509
- const existingPanel = containerApi.getPanel(panelId);
5510
- if (!existingPanel) {
5511
- // if the panel doesn't exist
5512
- this._onDidDrop.fire(Object.assign(Object.assign({}, event), { panel: this, getData: getPaneData, api: new PaneviewApi(this.accessor) }));
5513
- return;
5550
+ const data = getPanelData();
5551
+ if (data && data.viewId === this.accessor.id) {
5552
+ if (data.panelId === null) {
5553
+ // this is a group move dnd event
5554
+ const { groupId } = data;
5555
+ this._onMove.fire({
5556
+ target: position,
5557
+ groupId: groupId,
5558
+ index,
5559
+ });
5560
+ return;
5561
+ }
5562
+ const fromSameGroup = this.tabsContainer.indexOf(data.panelId) !== -1;
5563
+ if (fromSameGroup && this.tabsContainer.size === 1) {
5564
+ return;
5565
+ }
5566
+ const { groupId, panelId } = data;
5567
+ const isSameGroup = this.id === groupId;
5568
+ if (isSameGroup && !position) {
5569
+ const oldIndex = this.tabsContainer.indexOf(panelId);
5570
+ if (oldIndex === index) {
5571
+ return;
5572
+ }
5573
+ }
5574
+ this._onMove.fire({
5575
+ target: position,
5576
+ groupId: data.groupId,
5577
+ itemId: data.panelId,
5578
+ index,
5579
+ });
5514
5580
  }
5515
- const allPanels = containerApi.panels;
5516
- const fromIndex = allPanels.indexOf(existingPanel);
5517
- let toIndex = containerApi.panels.indexOf(this);
5518
- if (event.position === 'left' || event.position === 'top') {
5519
- toIndex = Math.max(0, toIndex - 1);
5581
+ else {
5582
+ this._onDidDrop.fire(new DockviewDidDropEvent({
5583
+ nativeEvent: event,
5584
+ position,
5585
+ panel,
5586
+ getData: () => getPanelData(),
5587
+ group: this.groupPanel,
5588
+ api: this._api,
5589
+ }));
5520
5590
  }
5521
- if (event.position === 'right' || event.position === 'bottom') {
5522
- if (fromIndex > toIndex) {
5523
- toIndex++;
5524
- }
5525
- toIndex = Math.min(allPanels.length - 1, toIndex);
5591
+ }
5592
+ dispose() {
5593
+ var _a, _b, _c;
5594
+ super.dispose();
5595
+ (_a = this.watermark) === null || _a === void 0 ? void 0 : _a.element.remove();
5596
+ (_c = (_b = this.watermark) === null || _b === void 0 ? void 0 : _b.dispose) === null || _c === void 0 ? void 0 : _c.call(_b);
5597
+ this.watermark = undefined;
5598
+ for (const panel of this.panels) {
5599
+ panel.dispose();
5526
5600
  }
5527
- containerApi.movePanel(fromIndex, toIndex);
5601
+ this.tabsContainer.dispose();
5602
+ this.contentContainer.dispose();
5528
5603
  }
5529
5604
  }
5530
5605
 
@@ -5711,9 +5786,12 @@
5711
5786
  constructor(id, accessor) {
5712
5787
  super(id, '__dockviewgroup__');
5713
5788
  this.accessor = accessor;
5789
+ this._mutableDisposable = new MutableDisposable();
5714
5790
  this._onDidLocationChange = new Emitter();
5715
5791
  this.onDidLocationChange = this._onDidLocationChange.event;
5716
- this.addDisposables(this._onDidLocationChange);
5792
+ this._onDidActivePanelChange = new Emitter();
5793
+ this.onDidActivePanelChange = this._onDidActivePanelChange.event;
5794
+ this.addDisposables(this._onDidLocationChange, this._onDidActivePanelChange, this._mutableDisposable);
5717
5795
  }
5718
5796
  close() {
5719
5797
  if (!this._group) {
@@ -5771,6 +5849,19 @@
5771
5849
  }
5772
5850
  initialize(group) {
5773
5851
  this._group = group;
5852
+ /**
5853
+ * TODO: Annoying initialization order caveat
5854
+ *
5855
+ * Due to the order on initialization we know that the model isn't defined until later in the same stack-frame of setup.
5856
+ * By queuing a microtask we can ensure the setup is completed within the same stack-frame, but after everything else has
5857
+ * finished ensuring the `model` is defined.
5858
+ */
5859
+ queueMicrotask(() => {
5860
+ this._mutableDisposable.value =
5861
+ this._group.model.onDidActivePanelChange((event) => {
5862
+ this._onDidActivePanelChange.fire(event);
5863
+ });
5864
+ });
5774
5865
  }
5775
5866
  }
5776
5867
 
@@ -5831,31 +5922,6 @@
5831
5922
  }
5832
5923
  }
5833
5924
 
5834
- function isPanelOptionsWithPanel(data) {
5835
- if (data.referencePanel) {
5836
- return true;
5837
- }
5838
- return false;
5839
- }
5840
- function isPanelOptionsWithGroup(data) {
5841
- if (data.referenceGroup) {
5842
- return true;
5843
- }
5844
- return false;
5845
- }
5846
- function isGroupOptionsWithPanel(data) {
5847
- if (data.referencePanel) {
5848
- return true;
5849
- }
5850
- return false;
5851
- }
5852
- function isGroupOptionsWithGroup(data) {
5853
- if (data.referenceGroup) {
5854
- return true;
5855
- }
5856
- return false;
5857
- }
5858
-
5859
5925
  class DockviewPanelApiImpl extends GridviewPanelApiImpl {
5860
5926
  get location() {
5861
5927
  return this.group.api.location;
@@ -6223,7 +6289,7 @@
6223
6289
  this._tab = this.createTabComponent(this.id, tabComponent);
6224
6290
  }
6225
6291
  init(params) {
6226
- this.content.init(Object.assign(Object.assign({}, params), { tab: this.tab }));
6292
+ this.content.init(params);
6227
6293
  this.tab.init(params);
6228
6294
  }
6229
6295
  updateParentGroup(_group, _isPanelVisible) {
@@ -6244,20 +6310,29 @@
6244
6310
  (_d = (_c = this.tab).dispose) === null || _d === void 0 ? void 0 : _d.call(_c);
6245
6311
  }
6246
6312
  createContentComponent(id, componentName) {
6247
- var _a, _b;
6248
- return createComponent(id, componentName, (_a = this.accessor.options.components) !== null && _a !== void 0 ? _a : {}, this.accessor.options.frameworkComponents, (_b = this.accessor.options.frameworkComponentFactory) === null || _b === void 0 ? void 0 : _b.content);
6313
+ return this.accessor.options.createComponent({
6314
+ id,
6315
+ name: componentName,
6316
+ });
6249
6317
  }
6250
6318
  createTabComponent(id, componentName) {
6251
- var _a, _b;
6252
- if (componentName) {
6253
- return createComponent(id, componentName, this.accessor.options.tabComponents, this.accessor.options.frameworkTabComponents, (_a = this.accessor.options.frameworkComponentFactory) === null || _a === void 0 ? void 0 : _a.tab, () => new DefaultTab());
6254
- }
6255
- else if (this.accessor.options.defaultTabComponent) {
6256
- return createComponent(id, this.accessor.options.defaultTabComponent, this.accessor.options.tabComponents, this.accessor.options.frameworkTabComponents, (_b = this.accessor.options.frameworkComponentFactory) === null || _b === void 0 ? void 0 : _b.tab, () => new DefaultTab());
6257
- }
6258
- else {
6259
- return new DefaultTab();
6319
+ const name = componentName !== null && componentName !== void 0 ? componentName : this.accessor.options.defaultTabComponent;
6320
+ if (name) {
6321
+ if (this.accessor.options.createTabComponent) {
6322
+ const component = this.accessor.options.createTabComponent({
6323
+ id,
6324
+ name,
6325
+ });
6326
+ if (component) {
6327
+ return component;
6328
+ }
6329
+ else {
6330
+ return new DefaultTab();
6331
+ }
6332
+ }
6333
+ console.warn(`dockview: tabComponent '${componentName}' was not found. falling back to the default tab.`);
6260
6334
  }
6335
+ return new DefaultTab();
6261
6336
  }
6262
6337
  }
6263
6338
 
@@ -7017,11 +7092,13 @@
7017
7092
  return this._api;
7018
7093
  }
7019
7094
  constructor(options) {
7020
- var _a, _b;
7095
+ var _a;
7021
7096
  super({
7022
7097
  proportionalLayout: true,
7023
- orientation: (_a = options.orientation) !== null && _a !== void 0 ? _a : exports.Orientation.HORIZONTAL,
7024
- styles: options.styles,
7098
+ orientation: exports.Orientation.HORIZONTAL,
7099
+ styles: options.hideBorders
7100
+ ? { separatorBorder: 'transparent' }
7101
+ : undefined,
7025
7102
  parentElement: options.parentElement,
7026
7103
  disableAutoResizing: options.disableAutoResizing,
7027
7104
  locked: options.locked,
@@ -7039,6 +7116,8 @@
7039
7116
  this.onWillDrop = this._onWillDrop.event;
7040
7117
  this._onWillShowOverlay = new Emitter();
7041
7118
  this.onWillShowOverlay = this._onWillShowOverlay.event;
7119
+ this._onUnhandledDragOverEvent = new Emitter();
7120
+ this.onUnhandledDragOverEvent = this._onUnhandledDragOverEvent.event;
7042
7121
  this._onDidRemovePanel = new Emitter();
7043
7122
  this.onDidRemovePanel = this._onDidRemovePanel.event;
7044
7123
  this._onDidAddPanel = new Emitter();
@@ -7064,7 +7143,7 @@
7064
7143
  this.overlayRenderContainer = new OverlayRenderContainer(gready);
7065
7144
  toggleClass(this.gridview.element, 'dv-dockview', true);
7066
7145
  toggleClass(this.element, 'dv-debug', !!options.debug);
7067
- 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.onDidAdd((event) => {
7146
+ 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.onDidAdd((event) => {
7068
7147
  if (!this._moving) {
7069
7148
  this._onDidAddGroup.fire(event);
7070
7149
  }
@@ -7091,22 +7170,6 @@
7091
7170
  }
7092
7171
  }));
7093
7172
  this._options = options;
7094
- if (!this.options.components) {
7095
- this.options.components = {};
7096
- }
7097
- if (!this.options.frameworkComponents) {
7098
- this.options.frameworkComponents = {};
7099
- }
7100
- if (!this.options.frameworkTabComponents) {
7101
- this.options.frameworkTabComponents = {};
7102
- }
7103
- if (!this.options.tabComponents) {
7104
- this.options.tabComponents = {};
7105
- }
7106
- if (!this.options.watermarkComponent &&
7107
- !this.options.watermarkFrameworkComponent) {
7108
- this.options.watermarkComponent = Watermark;
7109
- }
7110
7173
  this._rootDropTarget = new Droptarget(this.element, {
7111
7174
  canDisplayOverlay: (event, position) => {
7112
7175
  const data = getPanelData();
@@ -7121,26 +7184,20 @@
7121
7184
  }
7122
7185
  return true;
7123
7186
  }
7124
- if (this.options.showDndOverlay) {
7125
- if (position === 'center' && this.gridview.length !== 0) {
7126
- /**
7127
- * for external events only show the four-corner drag overlays, disable
7128
- * the center position so that external drag events can fall through to the group
7129
- * and panel drop target handlers
7130
- */
7131
- return false;
7132
- }
7133
- return this.options.showDndOverlay({
7134
- nativeEvent: event,
7135
- position: position,
7136
- target: 'edge',
7137
- getData: getPanelData,
7138
- });
7187
+ if (position === 'center' && this.gridview.length !== 0) {
7188
+ /**
7189
+ * for external events only show the four-corner drag overlays, disable
7190
+ * the center position so that external drag events can fall through to the group
7191
+ * and panel drop target handlers
7192
+ */
7193
+ return false;
7139
7194
  }
7140
- return false;
7195
+ const firedEvent = new DockviewUnhandledDragOverEvent(event, 'edge', position, getPanelData);
7196
+ this._onUnhandledDragOverEvent.fire(firedEvent);
7197
+ return firedEvent.isAccepted;
7141
7198
  },
7142
7199
  acceptedTargetZones: ['top', 'bottom', 'left', 'right', 'center'],
7143
- overlayModel: (_b = this.options.rootOverlayModel) !== null && _b !== void 0 ? _b : DEFAULT_ROOT_OVERLAY_MODEL,
7200
+ overlayModel: (_a = this.options.rootOverlayModel) !== null && _a !== void 0 ? _a : DEFAULT_ROOT_OVERLAY_MODEL,
7144
7201
  });
7145
7202
  this.addDisposables(this._rootDropTarget, this._rootDropTarget.onWillShowOverlay((event) => {
7146
7203
  if (this.gridview.length > 0 && event.position === 'center') {
@@ -7364,7 +7421,7 @@
7364
7421
  skipDispose: true,
7365
7422
  skipSetActiveGroup: true,
7366
7423
  }));
7367
- group.model.openPanel(item, { skipSetGroupActive: true });
7424
+ this.movingLock(() => group.model.openPanel(item, { skipSetGroupActive: true }));
7368
7425
  }
7369
7426
  else {
7370
7427
  group = item;
@@ -7437,7 +7494,7 @@
7437
7494
  // this is either a resize or a move
7438
7495
  // to inform the panels .layout(...) the group with it's current size
7439
7496
  // don't care about resize since the above watcher handles that
7440
- group.layout(group.height, group.width);
7497
+ group.layout(group.width, group.height);
7441
7498
  }), overlay.onDidChangeEnd(() => {
7442
7499
  this._bufferOnDidLayoutChange.fire();
7443
7500
  }), group.onDidChange((event) => {
@@ -7492,16 +7549,11 @@
7492
7549
  }
7493
7550
  updateOptions(options) {
7494
7551
  var _a, _b;
7495
- const changed_orientation = typeof options.orientation === 'string' &&
7496
- this.gridview.orientation !== options.orientation;
7497
- const changed_floatingGroupBounds = options.floatingGroupBounds !== undefined &&
7552
+ const changed_floatingGroupBounds = 'floatingGroupBounds' in options &&
7498
7553
  options.floatingGroupBounds !== this.options.floatingGroupBounds;
7499
- const changed_rootOverlayOptions = options.rootOverlayModel !== undefined &&
7554
+ const changed_rootOverlayOptions = 'rootOverlayModel' in options &&
7500
7555
  options.rootOverlayModel !== this.options.rootOverlayModel;
7501
7556
  this._options = Object.assign(Object.assign({}, this.options), options);
7502
- if (changed_orientation) {
7503
- this.gridview.orientation = options.orientation;
7504
- }
7505
7557
  if (changed_floatingGroupBounds) {
7506
7558
  for (const group of this._floatingGroups) {
7507
7559
  switch (this.options.floatingGroupBounds) {
@@ -7789,7 +7841,7 @@
7789
7841
  ? this.getGroupPanel(options.position.referencePanel)
7790
7842
  : options.position.referencePanel;
7791
7843
  if (!referencePanel) {
7792
- throw new Error(`referencePanel ${options.position.referencePanel} does not exist`);
7844
+ throw new Error(`referencePanel '${options.position.referencePanel}' does not exist`);
7793
7845
  }
7794
7846
  referenceGroup = this.findGroup(referencePanel);
7795
7847
  }
@@ -7799,14 +7851,19 @@
7799
7851
  ? (_a = this._groups.get(options.position.referenceGroup)) === null || _a === void 0 ? void 0 : _a.value
7800
7852
  : options.position.referenceGroup;
7801
7853
  if (!referenceGroup) {
7802
- throw new Error(`referencePanel ${options.position.referenceGroup} does not exist`);
7854
+ throw new Error(`referenceGroup '${options.position.referenceGroup}' does not exist`);
7803
7855
  }
7804
7856
  }
7805
7857
  else {
7806
7858
  const group = this.orthogonalize(directionToPosition(options.position.direction));
7807
7859
  const panel = this.createPanel(options, group);
7808
- group.model.openPanel(panel);
7809
- this.doSetGroupAndPanelActive(group);
7860
+ group.model.openPanel(panel, {
7861
+ skipSetActive: options.inactive,
7862
+ skipSetGroupActive: options.inactive,
7863
+ });
7864
+ if (!options.inactive) {
7865
+ this.doSetGroupAndPanelActive(group);
7866
+ }
7810
7867
  return panel;
7811
7868
  }
7812
7869
  }
@@ -7829,43 +7886,64 @@
7829
7886
  skipActiveGroup: true,
7830
7887
  });
7831
7888
  panel = this.createPanel(options, group);
7832
- group.model.openPanel(panel);
7889
+ group.model.openPanel(panel, {
7890
+ skipSetActive: options.inactive,
7891
+ skipSetGroupActive: options.inactive,
7892
+ });
7833
7893
  }
7834
7894
  else if (referenceGroup.api.location.type === 'floating' ||
7835
7895
  target === 'center') {
7836
7896
  panel = this.createPanel(options, referenceGroup);
7837
- referenceGroup.model.openPanel(panel);
7838
- this.doSetGroupAndPanelActive(referenceGroup);
7897
+ referenceGroup.model.openPanel(panel, {
7898
+ skipSetActive: options.inactive,
7899
+ skipSetGroupActive: options.inactive,
7900
+ });
7901
+ if (!options.inactive) {
7902
+ this.doSetGroupAndPanelActive(referenceGroup);
7903
+ }
7839
7904
  }
7840
7905
  else {
7841
7906
  const location = getGridLocation(referenceGroup.element);
7842
7907
  const relativeLocation = getRelativeLocation(this.gridview.orientation, location, target);
7843
7908
  const group = this.createGroupAtLocation(relativeLocation);
7844
7909
  panel = this.createPanel(options, group);
7845
- group.model.openPanel(panel);
7846
- this.doSetGroupAndPanelActive(group);
7910
+ group.model.openPanel(panel, {
7911
+ skipSetActive: options.inactive,
7912
+ skipSetGroupActive: options.inactive,
7913
+ });
7914
+ if (!options.inactive) {
7915
+ this.doSetGroupAndPanelActive(group);
7916
+ }
7847
7917
  }
7848
7918
  }
7849
7919
  else if (options.floating) {
7850
7920
  const group = this.createGroup();
7851
7921
  this._onDidAddGroup.fire(group);
7852
- const o = typeof options.floating === 'object' &&
7922
+ const coordinates = typeof options.floating === 'object' &&
7853
7923
  options.floating !== null
7854
7924
  ? options.floating
7855
7925
  : {};
7856
- this.addFloatingGroup(group, o, {
7926
+ this.addFloatingGroup(group, coordinates, {
7857
7927
  inDragMode: false,
7858
7928
  skipRemoveGroup: true,
7859
7929
  skipActiveGroup: true,
7860
7930
  });
7861
7931
  panel = this.createPanel(options, group);
7862
- group.model.openPanel(panel);
7932
+ group.model.openPanel(panel, {
7933
+ skipSetActive: options.inactive,
7934
+ skipSetGroupActive: options.inactive,
7935
+ });
7863
7936
  }
7864
7937
  else {
7865
7938
  const group = this.createGroupAtLocation();
7866
7939
  panel = this.createPanel(options, group);
7867
- group.model.openPanel(panel);
7868
- this.doSetGroupAndPanelActive(group);
7940
+ group.model.openPanel(panel, {
7941
+ skipSetActive: options.inactive,
7942
+ skipSetGroupActive: options.inactive,
7943
+ });
7944
+ if (!options.inactive) {
7945
+ this.doSetGroupAndPanelActive(group);
7946
+ }
7869
7947
  }
7870
7948
  return panel;
7871
7949
  }
@@ -7889,12 +7967,10 @@
7889
7967
  }
7890
7968
  }
7891
7969
  createWatermarkComponent() {
7892
- var _a;
7893
- return createComponent('watermark-id', 'watermark-name', this.options.watermarkComponent
7894
- ? { 'watermark-name': this.options.watermarkComponent }
7895
- : {}, this.options.watermarkFrameworkComponent
7896
- ? { 'watermark-name': this.options.watermarkFrameworkComponent }
7897
- : {}, (_a = this.options.frameworkComponentFactory) === null || _a === void 0 ? void 0 : _a.watermark);
7970
+ if (this.options.createWatermarkComponent) {
7971
+ return this.options.createWatermarkComponent();
7972
+ }
7973
+ return new Watermark();
7898
7974
  }
7899
7975
  updateWatermark() {
7900
7976
  var _a, _b;
@@ -7918,7 +7994,6 @@
7918
7994
  }
7919
7995
  addGroup(options) {
7920
7996
  var _a;
7921
- const group = this.createGroup(options);
7922
7997
  if (options) {
7923
7998
  let referenceGroup;
7924
7999
  if (isGroupOptionsWithPanel(options)) {
@@ -7952,6 +8027,7 @@
7952
8027
  const target = toTarget(options.direction || 'within');
7953
8028
  const location = getGridLocation(referenceGroup.element);
7954
8029
  const relativeLocation = getRelativeLocation(this.gridview.orientation, location, target);
8030
+ const group = this.createGroup(options);
7955
8031
  this.doAddGroup(group, relativeLocation);
7956
8032
  if (!options.skipSetActive) {
7957
8033
  this.doSetGroupAndPanelActive(group);
@@ -7959,6 +8035,7 @@
7959
8035
  return group;
7960
8036
  }
7961
8037
  else {
8038
+ const group = this.createGroup(options);
7962
8039
  this.doAddGroup(group);
7963
8040
  this.doSetGroupAndPanelActive(group);
7964
8041
  return group;
@@ -8275,6 +8352,8 @@
8275
8352
  return;
8276
8353
  }
8277
8354
  this._onWillShowOverlay.fire(event);
8355
+ }), view.model.onUnhandledDragOverEvent((event) => {
8356
+ this._onUnhandledDragOverEvent.fire(event);
8278
8357
  }), view.model.onDidAddPanel((event) => {
8279
8358
  if (this._moving) {
8280
8359
  return;
@@ -9308,6 +9387,7 @@
9308
9387
  exports.DockviewGroupPanelModel = DockviewGroupPanelModel;
9309
9388
  exports.DockviewMutableDisposable = MutableDisposable;
9310
9389
  exports.DockviewPanel = DockviewPanel;
9390
+ exports.DockviewUnhandledDragOverEvent = DockviewUnhandledDragOverEvent;
9311
9391
  exports.DockviewWillDropEvent = DockviewWillDropEvent;
9312
9392
  exports.DraggablePaneviewPanel = DraggablePaneviewPanel;
9313
9393
  exports.Gridview = Gridview;
@@ -9315,6 +9395,7 @@
9315
9395
  exports.GridviewComponent = GridviewComponent;
9316
9396
  exports.GridviewPanel = GridviewPanel;
9317
9397
  exports.LocalSelectionTransfer = LocalSelectionTransfer;
9398
+ exports.PROPERTY_KEYS = PROPERTY_KEYS;
9318
9399
  exports.PaneFramework = PaneFramework;
9319
9400
  exports.PaneTransfer = PaneTransfer;
9320
9401
  exports.PanelTransfer = PanelTransfer;