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