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