dockview 1.12.0 → 1.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/dist/cjs/dockview/defaultTab.d.ts +1 -1
  2. package/dist/cjs/dockview/dockview.d.ts +12 -40
  3. package/dist/cjs/dockview/dockview.js +102 -112
  4. package/dist/cjs/dockview/headerActionsRenderer.d.ts +3 -13
  5. package/dist/cjs/dockview/headerActionsRenderer.js +4 -14
  6. package/dist/cjs/dockview/reactContentPart.d.ts +2 -3
  7. package/dist/cjs/dockview/reactHeaderPart.d.ts +1 -2
  8. package/dist/cjs/dockview/reactWatermarkPart.d.ts +1 -6
  9. package/dist/cjs/dockview/reactWatermarkPart.js +0 -5
  10. package/dist/cjs/gridview/gridview.d.ts +2 -2
  11. package/dist/cjs/index.d.ts +0 -2
  12. package/dist/cjs/paneview/paneview.d.ts +3 -3
  13. package/dist/cjs/splitview/splitview.d.ts +2 -2
  14. package/dist/cjs/types.d.ts +0 -4
  15. package/dist/dockview.amd.js +2072 -2054
  16. package/dist/dockview.amd.js.map +1 -1
  17. package/dist/dockview.amd.min.js +2 -2
  18. package/dist/dockview.amd.min.js.map +1 -1
  19. package/dist/dockview.amd.min.noStyle.js +2 -2
  20. package/dist/dockview.amd.min.noStyle.js.map +1 -1
  21. package/dist/dockview.amd.noStyle.js +2072 -2054
  22. package/dist/dockview.amd.noStyle.js.map +1 -1
  23. package/dist/dockview.cjs.js +2072 -2054
  24. package/dist/dockview.cjs.js.map +1 -1
  25. package/dist/dockview.esm.js +2071 -2055
  26. package/dist/dockview.esm.js.map +1 -1
  27. package/dist/dockview.esm.min.js +2 -2
  28. package/dist/dockview.esm.min.js.map +1 -1
  29. package/dist/dockview.js +2072 -2054
  30. package/dist/dockview.js.map +1 -1
  31. package/dist/dockview.min.js +2 -2
  32. package/dist/dockview.min.js.map +1 -1
  33. package/dist/dockview.min.noStyle.js +2 -2
  34. package/dist/dockview.min.noStyle.js.map +1 -1
  35. package/dist/dockview.noStyle.js +2072 -2054
  36. package/dist/dockview.noStyle.js.map +1 -1
  37. package/dist/esm/dockview/defaultTab.d.ts +1 -1
  38. package/dist/esm/dockview/dockview.d.ts +12 -40
  39. package/dist/esm/dockview/dockview.js +93 -114
  40. package/dist/esm/dockview/headerActionsRenderer.d.ts +3 -13
  41. package/dist/esm/dockview/headerActionsRenderer.js +4 -10
  42. package/dist/esm/dockview/reactContentPart.d.ts +2 -3
  43. package/dist/esm/dockview/reactHeaderPart.d.ts +1 -2
  44. package/dist/esm/dockview/reactWatermarkPart.d.ts +1 -6
  45. package/dist/esm/dockview/reactWatermarkPart.js +0 -5
  46. package/dist/esm/gridview/gridview.d.ts +2 -2
  47. package/dist/esm/index.d.ts +0 -2
  48. package/dist/esm/paneview/paneview.d.ts +3 -3
  49. package/dist/esm/splitview/splitview.d.ts +2 -2
  50. package/dist/esm/types.d.ts +0 -4
  51. package/package.json +3 -3
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * dockview
3
- * @version 1.12.0
3
+ * @version 1.13.0
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -2469,6 +2469,261 @@ class Gridview {
2469
2469
  }
2470
2470
  }
2471
2471
 
2472
+ class Resizable extends CompositeDisposable {
2473
+ get element() {
2474
+ return this._element;
2475
+ }
2476
+ get disableResizing() {
2477
+ return this._disableResizing;
2478
+ }
2479
+ set disableResizing(value) {
2480
+ this._disableResizing = value;
2481
+ }
2482
+ constructor(parentElement, disableResizing = false) {
2483
+ super();
2484
+ this._disableResizing = disableResizing;
2485
+ this._element = parentElement;
2486
+ this.addDisposables(watchElementResize(this._element, (entry) => {
2487
+ if (this.isDisposed) {
2488
+ /**
2489
+ * resize is delayed through requestAnimationFrame so there is a small chance
2490
+ * the component has already been disposed of
2491
+ */
2492
+ return;
2493
+ }
2494
+ if (this.disableResizing) {
2495
+ return;
2496
+ }
2497
+ if (!this._element.offsetParent) {
2498
+ /**
2499
+ * offsetParent === null is equivalent to display: none being set on the element or one
2500
+ * of it's parents. In the display: none case the size will become (0, 0) which we do
2501
+ * not want to propagate.
2502
+ *
2503
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetParent
2504
+ *
2505
+ * You could use checkVisibility() but at the time of writing it's not supported across
2506
+ * all Browsers
2507
+ *
2508
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility
2509
+ */
2510
+ return;
2511
+ }
2512
+ if (!isInDocument(this._element)) {
2513
+ /**
2514
+ * since the event is dispatched through requestAnimationFrame there is a small chance
2515
+ * the component is no longer attached to the DOM, if that is the case the dimensions
2516
+ * are mostly likely all zero and meaningless. we should skip this case.
2517
+ */
2518
+ return;
2519
+ }
2520
+ const { width, height } = entry.contentRect;
2521
+ this.layout(width, height);
2522
+ }));
2523
+ }
2524
+ }
2525
+
2526
+ const nextLayoutId$1 = sequentialNumberGenerator();
2527
+ function toTarget(direction) {
2528
+ switch (direction) {
2529
+ case 'left':
2530
+ return 'left';
2531
+ case 'right':
2532
+ return 'right';
2533
+ case 'above':
2534
+ return 'top';
2535
+ case 'below':
2536
+ return 'bottom';
2537
+ case 'within':
2538
+ default:
2539
+ return 'center';
2540
+ }
2541
+ }
2542
+ class BaseGrid extends Resizable {
2543
+ get id() {
2544
+ return this._id;
2545
+ }
2546
+ get size() {
2547
+ return this._groups.size;
2548
+ }
2549
+ get groups() {
2550
+ return Array.from(this._groups.values()).map((_) => _.value);
2551
+ }
2552
+ get width() {
2553
+ return this.gridview.width;
2554
+ }
2555
+ get height() {
2556
+ return this.gridview.height;
2557
+ }
2558
+ get minimumHeight() {
2559
+ return this.gridview.minimumHeight;
2560
+ }
2561
+ get maximumHeight() {
2562
+ return this.gridview.maximumHeight;
2563
+ }
2564
+ get minimumWidth() {
2565
+ return this.gridview.minimumWidth;
2566
+ }
2567
+ get maximumWidth() {
2568
+ return this.gridview.maximumWidth;
2569
+ }
2570
+ get activeGroup() {
2571
+ return this._activeGroup;
2572
+ }
2573
+ get locked() {
2574
+ return this.gridview.locked;
2575
+ }
2576
+ set locked(value) {
2577
+ this.gridview.locked = value;
2578
+ }
2579
+ constructor(options) {
2580
+ super(document.createElement('div'), options.disableAutoResizing);
2581
+ this._id = nextLayoutId$1.next();
2582
+ this._groups = new Map();
2583
+ this._onDidLayoutChange = new Emitter();
2584
+ this.onDidLayoutChange = this._onDidLayoutChange.event;
2585
+ this._onDidRemove = new Emitter();
2586
+ this.onDidRemove = this._onDidRemove.event;
2587
+ this._onDidAdd = new Emitter();
2588
+ this.onDidAdd = this._onDidAdd.event;
2589
+ this._onDidActiveChange = new Emitter();
2590
+ this.onDidActiveChange = this._onDidActiveChange.event;
2591
+ this._bufferOnDidLayoutChange = new TickDelayedEvent();
2592
+ this.element.style.height = '100%';
2593
+ this.element.style.width = '100%';
2594
+ options.parentElement.appendChild(this.element);
2595
+ this.gridview = new Gridview(!!options.proportionalLayout, options.styles, options.orientation);
2596
+ this.gridview.locked = !!options.locked;
2597
+ this.element.appendChild(this.gridview.element);
2598
+ this.layout(0, 0, true); // set some elements height/widths
2599
+ this.addDisposables(Disposable.from(() => {
2600
+ var _a;
2601
+ (_a = this.element.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(this.element);
2602
+ }), this.gridview.onDidChange(() => {
2603
+ this._bufferOnDidLayoutChange.fire();
2604
+ }), Event.any(this.onDidAdd, this.onDidRemove, this.onDidActiveChange)(() => {
2605
+ this._bufferOnDidLayoutChange.fire();
2606
+ }), this._bufferOnDidLayoutChange.onEvent(() => {
2607
+ this._onDidLayoutChange.fire();
2608
+ }), this._bufferOnDidLayoutChange);
2609
+ }
2610
+ setVisible(panel, visible) {
2611
+ this.gridview.setViewVisible(getGridLocation(panel.element), visible);
2612
+ this._onDidLayoutChange.fire();
2613
+ }
2614
+ isVisible(panel) {
2615
+ return this.gridview.isViewVisible(getGridLocation(panel.element));
2616
+ }
2617
+ maximizeGroup(panel) {
2618
+ this.gridview.maximizeView(panel);
2619
+ this.doSetGroupActive(panel);
2620
+ }
2621
+ isMaximizedGroup(panel) {
2622
+ return this.gridview.maximizedView() === panel;
2623
+ }
2624
+ exitMaximizedGroup() {
2625
+ this.gridview.exitMaximizedView();
2626
+ }
2627
+ hasMaximizedGroup() {
2628
+ return this.gridview.hasMaximizedView();
2629
+ }
2630
+ get onDidMaximizedGroupChange() {
2631
+ return this.gridview.onDidMaximizedNodeChange;
2632
+ }
2633
+ doAddGroup(group, location = [0], size) {
2634
+ this.gridview.addView(group, size !== null && size !== void 0 ? size : Sizing.Distribute, location);
2635
+ this._onDidAdd.fire(group);
2636
+ }
2637
+ doRemoveGroup(group, options) {
2638
+ if (!this._groups.has(group.id)) {
2639
+ throw new Error('invalid operation');
2640
+ }
2641
+ const item = this._groups.get(group.id);
2642
+ const view = this.gridview.remove(group, Sizing.Distribute);
2643
+ if (item && !(options === null || options === void 0 ? void 0 : options.skipDispose)) {
2644
+ item.disposable.dispose();
2645
+ item.value.dispose();
2646
+ this._groups.delete(group.id);
2647
+ this._onDidRemove.fire(group);
2648
+ }
2649
+ if (!(options === null || options === void 0 ? void 0 : options.skipActive) && this._activeGroup === group) {
2650
+ const groups = Array.from(this._groups.values());
2651
+ this.doSetGroupActive(groups.length > 0 ? groups[0].value : undefined);
2652
+ }
2653
+ return view;
2654
+ }
2655
+ getPanel(id) {
2656
+ var _a;
2657
+ return (_a = this._groups.get(id)) === null || _a === void 0 ? void 0 : _a.value;
2658
+ }
2659
+ doSetGroupActive(group) {
2660
+ if (this._activeGroup === group) {
2661
+ return;
2662
+ }
2663
+ if (this._activeGroup) {
2664
+ this._activeGroup.setActive(false);
2665
+ }
2666
+ if (group) {
2667
+ group.setActive(true);
2668
+ }
2669
+ this._activeGroup = group;
2670
+ this._onDidActiveChange.fire(group);
2671
+ }
2672
+ removeGroup(group) {
2673
+ this.doRemoveGroup(group);
2674
+ }
2675
+ moveToNext(options) {
2676
+ var _a;
2677
+ if (!options) {
2678
+ options = {};
2679
+ }
2680
+ if (!options.group) {
2681
+ if (!this.activeGroup) {
2682
+ return;
2683
+ }
2684
+ options.group = this.activeGroup;
2685
+ }
2686
+ const location = getGridLocation(options.group.element);
2687
+ const next = (_a = this.gridview.next(location)) === null || _a === void 0 ? void 0 : _a.view;
2688
+ this.doSetGroupActive(next);
2689
+ }
2690
+ moveToPrevious(options) {
2691
+ var _a;
2692
+ if (!options) {
2693
+ options = {};
2694
+ }
2695
+ if (!options.group) {
2696
+ if (!this.activeGroup) {
2697
+ return;
2698
+ }
2699
+ options.group = this.activeGroup;
2700
+ }
2701
+ const location = getGridLocation(options.group.element);
2702
+ const next = (_a = this.gridview.previous(location)) === null || _a === void 0 ? void 0 : _a.view;
2703
+ this.doSetGroupActive(next);
2704
+ }
2705
+ layout(width, height, forceResize) {
2706
+ const different = forceResize !== null && forceResize !== void 0 ? forceResize : (width !== this.width || height !== this.height);
2707
+ if (!different) {
2708
+ return;
2709
+ }
2710
+ this.gridview.element.style.height = `${height}px`;
2711
+ this.gridview.element.style.width = `${width}px`;
2712
+ this.gridview.layout(width, height);
2713
+ }
2714
+ dispose() {
2715
+ this._onDidActiveChange.dispose();
2716
+ this._onDidAdd.dispose();
2717
+ this._onDidRemove.dispose();
2718
+ this._onDidLayoutChange.dispose();
2719
+ for (const group of this.groups) {
2720
+ group.dispose();
2721
+ }
2722
+ this.gridview.dispose();
2723
+ super.dispose();
2724
+ }
2725
+ }
2726
+
2472
2727
  class SplitviewApi {
2473
2728
  /**
2474
2729
  * The minimum size the component can reach where size is measured in the direction of orientation provided.
@@ -3011,6 +3266,9 @@ class DockviewApi {
3011
3266
  get onWillDragPanel() {
3012
3267
  return this.component.onWillDragPanel;
3013
3268
  }
3269
+ get onUnhandledDragOverEvent() {
3270
+ return this.component.onUnhandledDragOverEvent;
3271
+ }
3014
3272
  /**
3015
3273
  * All panel objects.
3016
3274
  */
@@ -3148,6 +3406,67 @@ class DockviewApi {
3148
3406
  }
3149
3407
  }
3150
3408
 
3409
+ class DragHandler extends CompositeDisposable {
3410
+ constructor(el) {
3411
+ super();
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();
3419
+ }
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
+
3151
3470
  class DragAndDropObserver extends CompositeDisposable {
3152
3471
  constructor(element, callbacks) {
3153
3472
  super();
@@ -3292,6 +3611,10 @@ class Droptarget extends CompositeDisposable {
3292
3611
  this.removeDropTarget();
3293
3612
  return;
3294
3613
  }
3614
+ if (!this.options.canDisplayOverlay(e, quadrant)) {
3615
+ this.removeDropTarget();
3616
+ return;
3617
+ }
3295
3618
  const willShowOverlayEvent = new WillShowOverlayEvent({
3296
3619
  nativeEvent: e,
3297
3620
  position: quadrant,
@@ -3305,16 +3628,6 @@ class Droptarget extends CompositeDisposable {
3305
3628
  this.removeDropTarget();
3306
3629
  return;
3307
3630
  }
3308
- if (typeof this.options.canDisplayOverlay === 'boolean') {
3309
- if (!this.options.canDisplayOverlay) {
3310
- this.removeDropTarget();
3311
- return;
3312
- }
3313
- }
3314
- else if (!this.options.canDisplayOverlay(e, quadrant)) {
3315
- this.removeDropTarget();
3316
- return;
3317
- }
3318
3631
  this.markAsUsed(e);
3319
3632
  if (!this.targetElement) {
3320
3633
  this.targetElement = document.createElement('div');
@@ -3505,2023 +3818,1758 @@ function calculateQuadrantAsPixels(overlayType, x, y, width, height, threshold)
3505
3818
  return 'center';
3506
3819
  }
3507
3820
 
3508
- class ContentContainer extends CompositeDisposable {
3509
- get element() {
3510
- return this._element;
3511
- }
3512
- constructor(accessor, group) {
3821
+ class WillFocusEvent extends DockviewEvent {
3822
+ constructor() {
3513
3823
  super();
3514
- this.accessor = accessor;
3515
- this.group = group;
3516
- this.disposable = new MutableDisposable();
3517
- this._onDidFocus = new Emitter();
3518
- this.onDidFocus = this._onDidFocus.event;
3519
- this._onDidBlur = new Emitter();
3520
- this.onDidBlur = this._onDidBlur.event;
3521
- this._element = document.createElement('div');
3522
- this._element.className = 'content-container';
3523
- this._element.tabIndex = -1;
3524
- this.addDisposables(this._onDidFocus, this._onDidBlur);
3525
- this.dropTarget = new Droptarget(this.element, {
3526
- acceptedTargetZones: ['top', 'bottom', 'left', 'right', 'center'],
3527
- canDisplayOverlay: (event, position) => {
3528
- if (this.group.locked === 'no-drop-target' ||
3529
- (this.group.locked && position === 'center')) {
3530
- return false;
3531
- }
3532
- const data = getPanelData();
3533
- if (!data &&
3534
- event.shiftKey &&
3535
- this.group.location.type !== 'floating') {
3536
- return false;
3537
- }
3538
- if (data && data.viewId === this.accessor.id) {
3539
- if (data.groupId === this.group.id) {
3540
- if (position === 'center') {
3541
- // don't allow to drop on self for center position
3542
- return false;
3543
- }
3544
- if (data.panelId === null) {
3545
- // don't allow group move to drop anywhere on self
3546
- return false;
3547
- }
3548
- }
3549
- const groupHasOnePanelAndIsActiveDragElement = this.group.panels.length === 1 &&
3550
- data.groupId === this.group.id;
3551
- return !groupHasOnePanelAndIsActiveDragElement;
3552
- }
3553
- return this.group.canDisplayOverlay(event, position, 'content');
3554
- },
3555
- });
3556
- this.addDisposables(this.dropTarget);
3557
3824
  }
3558
- show() {
3559
- 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;
3560
3832
  }
3561
- hide() {
3562
- this.element.style.display = 'none';
3833
+ get isActive() {
3834
+ return this._isActive;
3563
3835
  }
3564
- renderPanel(panel, options = { asActive: true }) {
3565
- const doRender = options.asActive ||
3566
- (this.panel && this.group.isPanelActive(this.panel));
3567
- if (this.panel &&
3568
- this.panel.view.content.element.parentElement === this._element) {
3569
- /**
3570
- * If the currently attached panel is mounted directly to the content then remove it
3571
- */
3572
- this._element.removeChild(this.panel.view.content.element);
3573
- }
3574
- this.panel = panel;
3575
- let container;
3576
- switch (panel.api.renderer) {
3577
- case 'onlyWhenVisible':
3578
- this.group.renderContainer.detatch(panel);
3579
- if (this.panel) {
3580
- if (doRender) {
3581
- this._element.appendChild(this.panel.view.content.element);
3582
- }
3583
- }
3584
- container = this._element;
3585
- break;
3586
- case 'always':
3587
- if (panel.view.content.element.parentElement === this._element) {
3588
- this._element.removeChild(panel.view.content.element);
3589
- }
3590
- container = this.group.renderContainer.attach({
3591
- panel,
3592
- referenceContainer: this,
3593
- });
3594
- break;
3595
- }
3596
- if (doRender) {
3597
- const _onDidFocus = panel.view.content.onDidFocus;
3598
- const _onDidBlur = panel.view.content.onDidBlur;
3599
- const focusTracker = trackFocus(container);
3600
- const disposable = new CompositeDisposable();
3601
- disposable.addDisposables(focusTracker, focusTracker.onDidFocus(() => this._onDidFocus.fire()), focusTracker.onDidBlur(() => this._onDidBlur.fire()));
3602
- if (_onDidFocus) {
3603
- disposable.addDisposables(_onDidFocus(() => this._onDidFocus.fire()));
3604
- }
3605
- if (_onDidBlur) {
3606
- disposable.addDisposables(_onDidBlur(() => this._onDidBlur.fire()));
3607
- }
3608
- this.disposable.value = disposable;
3609
- }
3836
+ get isVisible() {
3837
+ return this._isVisible;
3610
3838
  }
3611
- openPanel(panel) {
3612
- if (this.panel === panel) {
3613
- return;
3614
- }
3615
- this.renderPanel(panel);
3839
+ get width() {
3840
+ return this._width;
3616
3841
  }
3617
- layout(_width, _height) {
3618
- // noop
3842
+ get height() {
3843
+ return this._height;
3619
3844
  }
3620
- closePanel() {
3621
- var _a;
3622
- if (this.panel) {
3623
- if (this.panel.api.renderer === 'onlyWhenVisible') {
3624
- (_a = this.panel.view.content.element.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(this.panel.view.content.element);
3625
- }
3626
- }
3627
- 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);
3628
3884
  }
3629
- dispose() {
3630
- this.disposable.dispose();
3631
- 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);
3632
3904
  }
3633
3905
  }
3634
3906
 
3635
- class DragHandler extends CompositeDisposable {
3636
- constructor(el) {
3637
- super();
3638
- this.el = el;
3639
- this.dataDisposable = new MutableDisposable();
3640
- this.pointerEventsDisposable = new MutableDisposable();
3641
- this._onDragStart = new Emitter();
3642
- this.onDragStart = this._onDragStart.event;
3643
- this.addDisposables(this._onDragStart, this.dataDisposable, this.pointerEventsDisposable);
3644
- 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);
3645
3922
  }
3646
- isCancelled(_event) {
3647
- return false;
3923
+ setConstraints(value) {
3924
+ this._onDidConstraintsChangeInternal.fire(value);
3648
3925
  }
3649
- configure() {
3650
- this.addDisposables(this._onDragStart, addDisposableListener(this.el, 'dragstart', (event) => {
3651
- if (event.defaultPrevented || this.isCancelled(event)) {
3652
- event.preventDefault();
3653
- return;
3654
- }
3655
- const iframes = [
3656
- ...getElementsByTagName('iframe'),
3657
- ...getElementsByTagName('webview'),
3658
- ];
3659
- this.pointerEventsDisposable.value = {
3660
- dispose: () => {
3661
- for (const iframe of iframes) {
3662
- iframe.style.pointerEvents = 'auto';
3663
- }
3664
- },
3665
- };
3666
- for (const iframe of iframes) {
3667
- iframe.style.pointerEvents = 'none';
3668
- }
3669
- this.el.classList.add('dv-dragged');
3670
- setTimeout(() => this.el.classList.remove('dv-dragged'), 0);
3671
- this.dataDisposable.value = this.getData(event);
3672
- this._onDragStart.fire(event);
3673
- if (event.dataTransfer) {
3674
- event.dataTransfer.effectAllowed = 'move';
3675
- const hasData = event.dataTransfer.items.length > 0;
3676
- if (!hasData) {
3677
- /**
3678
- * Although this is not used by dockview many third party dnd libraries will check
3679
- * dataTransfer.types to determine valid drag events.
3680
- *
3681
- * For example: in react-dnd if dataTransfer.types is not set then the dragStart event will be cancelled
3682
- * through .preventDefault(). Since this is applied globally to all drag events this would break dockviews
3683
- * dnd logic. You can see the code at
3684
- * https://github.com/react-dnd/react-dnd/blob/main/packages/backend-html5/src/HTML5BackendImpl.ts#L542
3685
- */
3686
- event.dataTransfer.setData('text/plain', '__dockview_internal_drag_event__');
3687
- }
3688
- }
3689
- }), addDisposableListener(this.el, 'dragend', () => {
3690
- this.pointerEventsDisposable.dispose();
3691
- this.dataDisposable.dispose();
3692
- }));
3926
+ setSize(event) {
3927
+ this._onDidSizeChange.fire(event);
3693
3928
  }
3694
3929
  }
3695
3930
 
3696
- class TabDragHandler extends DragHandler {
3697
- constructor(element, accessor, group, panel) {
3698
- super(element);
3699
- this.accessor = accessor;
3700
- this.group = group;
3701
- this.panel = panel;
3702
- this.panelTransfer = LocalSelectionTransfer.getInstance();
3931
+ class PaneviewPanelApiImpl extends SplitviewPanelApiImpl {
3932
+ set pane(pane) {
3933
+ this._pane = pane;
3703
3934
  }
3704
- getData(event) {
3705
- this.panelTransfer.setData([new PanelTransfer(this.accessor.id, this.group.id, this.panel.id)], PanelTransfer.prototype);
3706
- return {
3707
- dispose: () => {
3708
- this.panelTransfer.clearData(PanelTransfer.prototype);
3709
- },
3710
- };
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());
3711
3954
  }
3712
3955
  }
3713
- class Tab extends CompositeDisposable {
3956
+
3957
+ class BasePanelView extends CompositeDisposable {
3714
3958
  get element() {
3715
3959
  return this._element;
3716
3960
  }
3717
- 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) {
3718
3972
  super();
3719
- this.panel = panel;
3720
- this.accessor = accessor;
3721
- this.group = group;
3722
- this.content = undefined;
3723
- this._onChanged = new Emitter();
3724
- this.onChanged = this._onChanged.event;
3725
- this._onDropped = new Emitter();
3726
- this.onDrop = this._onDropped.event;
3727
- this._onDragStart = new Emitter();
3728
- 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;
3729
3978
  this._element = document.createElement('div');
3730
- this._element.className = 'tab';
3731
- this._element.tabIndex = 0;
3732
- this._element.draggable = true;
3733
- toggleClass(this.element, 'inactive-tab', true);
3734
- const dragHandler = new TabDragHandler(this._element, this.accessor, this.group, this.panel);
3735
- this.dropTarget = new Droptarget(this._element, {
3736
- acceptedTargetZones: ['center'],
3737
- canDisplayOverlay: (event, position) => {
3738
- if (this.group.locked) {
3739
- return false;
3740
- }
3741
- const data = getPanelData();
3742
- if (data && this.accessor.id === data.viewId) {
3743
- if (data.panelId === null &&
3744
- data.groupId === this.group.id) {
3745
- // don't allow group move to drop on self
3746
- return false;
3747
- }
3748
- return this.panel.id !== data.panelId;
3749
- }
3750
- return this.group.model.canDisplayOverlay(event, position, 'tab');
3751
- },
3752
- });
3753
- this.onWillShowOverlay = this.dropTarget.onWillShowOverlay;
3754
- this.addDisposables(this._onChanged, this._onDropped, this._onDragStart, dragHandler.onDragStart((event) => {
3755
- this._onDragStart.fire(event);
3756
- }), dragHandler, addDisposableListener(this._element, 'mousedown', (event) => {
3757
- if (event.defaultPrevented) {
3758
- 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);
3759
4006
  }
3760
- this._onChanged.fire(event);
3761
- }), this.dropTarget.onDrop((event) => {
3762
- this._onDropped.fire(event);
3763
- }), this.dropTarget);
4007
+ }
3764
4008
  }
3765
- setActive(isActive) {
3766
- toggleClass(this.element, 'active-tab', isActive);
3767
- toggleClass(this.element, 'inactive-tab', !isActive);
4009
+ init(parameters) {
4010
+ this._params = parameters;
4011
+ this.part = this.getComponent();
3768
4012
  }
3769
- setContent(part) {
3770
- if (this.content) {
3771
- 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
+ }
3772
4025
  }
3773
- this.content = part;
3774
- 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
+ };
3775
4037
  }
3776
4038
  dispose() {
4039
+ var _a;
4040
+ this.api.dispose();
4041
+ (_a = this.part) === null || _a === void 0 ? void 0 : _a.dispose();
3777
4042
  super.dispose();
3778
4043
  }
3779
4044
  }
3780
4045
 
3781
- function addGhostImage(dataTransfer, ghostElement) {
3782
- // class dockview provides to force ghost image to be drawn on a different layer and prevent weird rendering issues
3783
- addClasses(ghostElement, 'dv-dragged');
3784
- document.body.appendChild(ghostElement);
3785
- dataTransfer.setDragImage(ghostElement, 0, 0);
3786
- setTimeout(() => {
3787
- removeClasses(ghostElement, 'dv-dragged');
3788
- ghostElement.remove();
3789
- }, 0);
3790
- }
3791
-
3792
- class GroupDragHandler extends DragHandler {
3793
- constructor(element, accessor, group) {
3794
- super(element);
3795
- this.accessor = accessor;
3796
- this.group = group;
3797
- this.panelTransfer = LocalSelectionTransfer.getInstance();
3798
- this.addDisposables(addDisposableListener(element, 'mousedown', (e) => {
3799
- if (e.shiftKey) {
3800
- /**
3801
- * You cannot call e.preventDefault() because that will prevent drag events from firing
3802
- * but we also need to stop any group overlay drag events from occuring
3803
- * Use a custom event marker that can be checked by the overlay drag events
3804
- */
3805
- quasiPreventDefault(e);
3806
- }
3807
- }, true));
4046
+ class PaneviewPanel extends BasePanelView {
4047
+ set orientation(value) {
4048
+ this._orientation = value;
3808
4049
  }
3809
- isCancelled(_event) {
3810
- if (this.group.api.location.type === 'floating' && !_event.shiftKey) {
3811
- return true;
3812
- }
3813
- return false;
4050
+ get orientation() {
4051
+ return this._orientation;
3814
4052
  }
3815
- getData(dragEvent) {
3816
- const dataTransfer = dragEvent.dataTransfer;
3817
- this.panelTransfer.setData([new PanelTransfer(this.accessor.id, this.group.id, null)], PanelTransfer.prototype);
3818
- const style = window.getComputedStyle(this.el);
3819
- const bgColor = style.getPropertyValue('--dv-activegroup-visiblepanel-tab-background-color');
3820
- const color = style.getPropertyValue('--dv-activegroup-visiblepanel-tab-color');
3821
- if (dataTransfer) {
3822
- const ghostElement = document.createElement('div');
3823
- ghostElement.style.backgroundColor = bgColor;
3824
- ghostElement.style.color = color;
3825
- ghostElement.style.padding = '2px 8px';
3826
- ghostElement.style.height = '24px';
3827
- ghostElement.style.fontSize = '11px';
3828
- ghostElement.style.lineHeight = '20px';
3829
- ghostElement.style.borderRadius = '12px';
3830
- ghostElement.style.position = 'absolute';
3831
- ghostElement.textContent = `Multiple Panels (${this.group.size})`;
3832
- addGhostImage(dataTransfer, ghostElement);
3833
- }
3834
- return {
3835
- dispose: () => {
3836
- this.panelTransfer.clearData(PanelTransfer.prototype);
3837
- },
3838
- };
4053
+ get minimumSize() {
4054
+ const headerSize = this.headerSize;
4055
+ const expanded = this.isExpanded();
4056
+ const minimumBodySize = expanded ? this._minimumBodySize : 0;
4057
+ return headerSize + minimumBodySize;
3839
4058
  }
3840
- }
3841
-
3842
- class VoidContainer extends CompositeDisposable {
3843
- get element() {
3844
- 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;
3845
4064
  }
3846
- constructor(accessor, group) {
3847
- super();
3848
- this.accessor = accessor;
3849
- this.group = group;
3850
- this._onDrop = new Emitter();
3851
- this.onDrop = this._onDrop.event;
3852
- this._onDragStart = new Emitter();
3853
- this.onDragStart = this._onDragStart.event;
3854
- this._element = document.createElement('div');
3855
- this._element.className = 'void-container';
3856
- this._element.tabIndex = 0;
3857
- this._element.draggable = true;
3858
- this.addDisposables(this._onDrop, this._onDragStart, addDisposableListener(this._element, 'click', () => {
3859
- this.accessor.doSetGroupActive(this.group);
3860
- }));
3861
- const handler = new GroupDragHandler(this._element, accessor, group);
3862
- this.dropTraget = new Droptarget(this._element, {
3863
- acceptedTargetZones: ['center'],
3864
- canDisplayOverlay: (event, position) => {
3865
- var _a;
3866
- const data = getPanelData();
3867
- if (data && this.accessor.id === data.viewId) {
3868
- if (data.panelId === null &&
3869
- data.groupId === this.group.id) {
3870
- // don't allow group move to drop on self
3871
- return false;
3872
- }
3873
- // don't show the overlay if the tab being dragged is the last panel of this group
3874
- return ((_a = last(this.group.panels)) === null || _a === void 0 ? void 0 : _a.id) !== data.panelId;
3875
- }
3876
- return group.model.canDisplayOverlay(event, position, 'header_space');
3877
- },
3878
- });
3879
- this.onWillShowOverlay = this.dropTraget.onWillShowOverlay;
3880
- this.addDisposables(handler, handler.onDragStart((event) => {
3881
- this._onDragStart.fire(event);
3882
- }), this.dropTraget.onDrop((event) => {
3883
- this._onDrop.fire(event);
3884
- }), this.dropTraget);
4065
+ get size() {
4066
+ return this._size;
3885
4067
  }
3886
- }
3887
-
3888
- class TabsContainer extends CompositeDisposable {
3889
- get panels() {
3890
- return this.tabs.map((_) => _.value.panel.id);
4068
+ get orthogonalSize() {
4069
+ return this._orthogonalSize;
3891
4070
  }
3892
- get size() {
3893
- return this.tabs.length;
4071
+ set orthogonalSize(size) {
4072
+ this._orthogonalSize = size;
3894
4073
  }
3895
- get hidden() {
3896
- return this._hidden;
4074
+ get minimumBodySize() {
4075
+ return this._minimumBodySize;
3897
4076
  }
3898
- set hidden(value) {
3899
- this._hidden = value;
3900
- this.element.style.display = value ? 'none' : '';
4077
+ set minimumBodySize(value) {
4078
+ this._minimumBodySize = typeof value === 'number' ? value : 0;
3901
4079
  }
3902
- show() {
3903
- if (!this.hidden) {
3904
- this.element.style.display = '';
3905
- }
4080
+ get maximumBodySize() {
4081
+ return this._maximumBodySize;
3906
4082
  }
3907
- hide() {
3908
- this._element.style.display = 'none';
4083
+ set maximumBodySize(value) {
4084
+ this._maximumBodySize =
4085
+ typeof value === 'number' ? value : Number.POSITIVE_INFINITY;
3909
4086
  }
3910
- setRightActionsElement(element) {
3911
- 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) {
3912
4154
  return;
3913
4155
  }
3914
- if (this.rightActions) {
3915
- this.rightActions.remove();
3916
- 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
+ }
3917
4164
  }
3918
- if (element) {
3919
- this.rightActionsContainer.appendChild(element);
3920
- 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);
3921
4170
  }
4171
+ this._onDidChange.fire(expanded ? { size: this.width } : {});
4172
+ this._onDidChangeExpansionState.fire(expanded);
3922
4173
  }
3923
- setLeftActionsElement(element) {
3924
- if (this.leftActions === element) {
3925
- return;
3926
- }
3927
- if (this.leftActions) {
3928
- this.leftActions.remove();
3929
- this.leftActions = undefined;
3930
- }
3931
- if (element) {
3932
- this.leftActionsContainer.appendChild(element);
3933
- this.leftActions = element;
4174
+ layout(size, orthogonalSize) {
4175
+ this._size = size;
4176
+ this._orthogonalSize = orthogonalSize;
4177
+ const [width, height] = this.orientation === Orientation.HORIZONTAL
4178
+ ? [size, orthogonalSize]
4179
+ : [orthogonalSize, size];
4180
+ if (this.isExpanded()) {
4181
+ this.expandedSize = width;
3934
4182
  }
4183
+ super.layout(width, height);
3935
4184
  }
3936
- setPrefixActionsElement(element) {
3937
- if (this.preActions === element) {
3938
- return;
4185
+ init(parameters) {
4186
+ var _a, _b;
4187
+ super.init(parameters);
4188
+ if (typeof parameters.minimumBodySize === 'number') {
4189
+ this.minimumBodySize = parameters.minimumBodySize;
3939
4190
  }
3940
- if (this.preActions) {
3941
- this.preActions.remove();
3942
- this.preActions = undefined;
4191
+ if (typeof parameters.maximumBodySize === 'number') {
4192
+ this.maximumBodySize = parameters.maximumBodySize;
3943
4193
  }
3944
- if (element) {
3945
- this.preActionsContainer.appendChild(element);
3946
- 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);
3947
4202
  }
3948
4203
  }
3949
- get element() {
3950
- return this._element;
4204
+ toJSON() {
4205
+ const params = this._params;
4206
+ return Object.assign(Object.assign({}, super.toJSON()), { headerComponent: this.headerComponent, title: params.title });
3951
4207
  }
3952
- isActive(tab) {
3953
- return (this.selectedIndex > -1 &&
3954
- 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);
3955
4220
  }
3956
- indexOf(id) {
3957
- 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
+ };
3958
4235
  }
3959
- constructor(accessor, group) {
3960
- 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);
3961
4241
  this.accessor = accessor;
3962
- this.group = group;
3963
- this.tabs = [];
3964
- this.selectedIndex = -1;
3965
- this._hidden = false;
3966
- this._onDrop = new Emitter();
3967
- this.onDrop = this._onDrop.event;
3968
- this._onTabDragStart = new Emitter();
3969
- this.onTabDragStart = this._onTabDragStart.event;
3970
- this._onGroupDragStart = new Emitter();
3971
- this.onGroupDragStart = this._onGroupDragStart.event;
3972
- this._onWillShowOverlay = new Emitter();
3973
- this.onWillShowOverlay = this._onWillShowOverlay.event;
3974
- this._element = document.createElement('div');
3975
- this._element.className = 'tabs-and-actions-container';
3976
- toggleClass(this._element, 'dv-full-width-single-tab', this.accessor.options.singleTabMode === 'fullwidth');
3977
- this.rightActionsContainer = document.createElement('div');
3978
- this.rightActionsContainer.className = 'right-actions-container';
3979
- this.leftActionsContainer = document.createElement('div');
3980
- this.leftActionsContainer.className = 'left-actions-container';
3981
- this.preActionsContainer = document.createElement('div');
3982
- this.preActionsContainer.className = 'pre-actions-container';
3983
- this.tabContainer = document.createElement('div');
3984
- this.tabContainer.className = 'tabs-container';
3985
- this.voidContainer = new VoidContainer(this.accessor, this.group);
3986
- this._element.appendChild(this.preActionsContainer);
3987
- this._element.appendChild(this.tabContainer);
3988
- this._element.appendChild(this.leftActionsContainer);
3989
- this._element.appendChild(this.voidContainer.element);
3990
- this._element.appendChild(this.rightActionsContainer);
3991
- this.addDisposables(this.accessor.onDidAddPanel((e) => {
3992
- if (e.api.group === this.group) {
3993
- toggleClass(this._element, 'dv-single-tab', this.size === 1);
3994
- }
3995
- }), this.accessor.onDidRemovePanel((e) => {
3996
- if (e.api.group === this.group) {
3997
- toggleClass(this._element, 'dv-single-tab', this.size === 1);
3998
- }
3999
- }), this._onWillShowOverlay, this._onDrop, this._onTabDragStart, this._onGroupDragStart, this.voidContainer, this.voidContainer.onDragStart((event) => {
4000
- this._onGroupDragStart.fire({
4001
- nativeEvent: event,
4002
- group: this.group,
4003
- });
4004
- }), this.voidContainer.onDrop((event) => {
4005
- this._onDrop.fire({
4006
- event: event.nativeEvent,
4007
- index: this.tabs.length,
4008
- });
4009
- }), this.voidContainer.onWillShowOverlay((event) => {
4010
- this._onWillShowOverlay.fire(new WillShowOverlayLocationEvent(event, {
4011
- kind: 'header_space',
4012
- panel: this.group.activePanel,
4013
- api: this.accessor.api,
4014
- group: this.group,
4015
- getData: getPanelData,
4016
- }));
4017
- }), addDisposableListener(this.voidContainer.element, 'mousedown', (event) => {
4018
- const isFloatingGroupsEnabled = !this.accessor.options.disableFloatingGroups;
4019
- if (isFloatingGroupsEnabled &&
4020
- event.shiftKey &&
4021
- this.group.api.location.type !== 'floating') {
4022
- event.preventDefault();
4023
- const { top, left } = this.element.getBoundingClientRect();
4024
- const { top: rootTop, left: rootLeft } = this.accessor.element.getBoundingClientRect();
4025
- this.accessor.addFloatingGroup(this.group, {
4026
- x: left - rootLeft + 20,
4027
- y: top - rootTop + 20,
4028
- }, { inDragMode: true });
4029
- }
4030
- }), addDisposableListener(this.tabContainer, 'mousedown', (event) => {
4031
- if (event.defaultPrevented) {
4032
- return;
4033
- }
4034
- const isLeftClick = event.button === 0;
4035
- if (isLeftClick) {
4036
- this.accessor.doSetGroupActive(this.group);
4037
- }
4038
- }));
4039
- }
4040
- setActive(_isGroupActive) {
4041
- // noop
4042
- }
4043
- addTab(tab, index = this.tabs.length) {
4044
- if (index < 0 || index > this.tabs.length) {
4045
- throw new Error('invalid location');
4046
- }
4047
- this.tabContainer.insertBefore(tab.value.element, this.tabContainer.children[index]);
4048
- this.tabs = [
4049
- ...this.tabs.slice(0, index),
4050
- tab,
4051
- ...this.tabs.slice(index),
4052
- ];
4053
- if (this.selectedIndex < 0) {
4054
- this.selectedIndex = index;
4242
+ this._onDidDrop = new Emitter();
4243
+ this.onDidDrop = this._onDidDrop.event;
4244
+ if (!disableDnd) {
4245
+ this.initDragFeatures();
4055
4246
  }
4056
4247
  }
4057
- delete(id) {
4058
- const index = this.tabs.findIndex((tab) => tab.value.panel.id === id);
4059
- const tabToRemove = this.tabs.splice(index, 1)[0];
4060
- const { value, disposable } = tabToRemove;
4061
- disposable.dispose();
4062
- value.dispose();
4063
- value.element.remove();
4064
- }
4065
- setActivePanel(panel) {
4066
- this.tabs.forEach((tab) => {
4067
- const isActivePanel = panel.id === tab.value.panel.id;
4068
- tab.value.setActive(isActivePanel);
4069
- });
4070
- }
4071
- openPanel(panel, index = this.tabs.length) {
4072
- var _a;
4073
- if (this.tabs.find((tab) => tab.value.panel.id === panel.id)) {
4248
+ initDragFeatures() {
4249
+ if (!this.header) {
4074
4250
  return;
4075
4251
  }
4076
- const tab = new Tab(panel, this.accessor, this.group);
4077
- if (!((_a = panel.view) === null || _a === void 0 ? void 0 : _a.tab)) {
4078
- throw new Error('invalid header component');
4079
- }
4080
- tab.setContent(panel.view.tab);
4081
- const disposable = new CompositeDisposable(tab.onDragStart((event) => {
4082
- this._onTabDragStart.fire({ nativeEvent: event, panel });
4083
- }), tab.onChanged((event) => {
4084
- const isFloatingGroupsEnabled = !this.accessor.options.disableFloatingGroups;
4085
- const isFloatingWithOnePanel = this.group.api.location.type === 'floating' &&
4086
- this.size === 1;
4087
- if (isFloatingGroupsEnabled &&
4088
- !isFloatingWithOnePanel &&
4089
- event.shiftKey) {
4090
- event.preventDefault();
4091
- const panel = this.accessor.getGroupPanel(tab.panel.id);
4092
- const { top, left } = tab.element.getBoundingClientRect();
4093
- const { top: rootTop, left: rootLeft } = this.accessor.element.getBoundingClientRect();
4094
- this.accessor.addFloatingGroup(panel, {
4095
- x: left - rootLeft,
4096
- y: top - rootTop,
4097
- }, { inDragMode: true });
4098
- return;
4099
- }
4100
- const isLeftClick = event.button === 0;
4101
- if (!isLeftClick || event.defaultPrevented) {
4102
- return;
4103
- }
4104
- if (this.group.activePanel !== panel) {
4105
- this.group.model.openPanel(panel);
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
+ };
4106
4263
  }
4107
- }), tab.onDrop((event) => {
4108
- this._onDrop.fire({
4109
- event: event.nativeEvent,
4110
- index: this.tabs.findIndex((x) => x.value === tab),
4111
- });
4112
- }), tab.onWillShowOverlay((event) => {
4113
- this._onWillShowOverlay.fire(new WillShowOverlayLocationEvent(event, {
4114
- kind: 'tab',
4115
- panel: this.group.activePanel,
4116
- api: this.accessor.api,
4117
- group: this.group,
4118
- getData: getPanelData,
4119
- }));
4120
- }));
4121
- const value = { value: tab, disposable };
4122
- this.addTab(value, index);
4123
- }
4124
- closePanel(panel) {
4125
- this.delete(panel.id);
4126
- }
4127
- dispose() {
4128
- super.dispose();
4129
- for (const { value, disposable } of this.tabs) {
4130
- disposable.dispose();
4131
- value.dispose();
4132
- }
4133
- this.tabs = [];
4134
- }
4135
- }
4136
-
4137
- class DockviewDidDropEvent extends DockviewEvent {
4138
- get nativeEvent() {
4139
- return this.options.nativeEvent;
4140
- }
4141
- get position() {
4142
- return this.options.position;
4143
- }
4144
- get panel() {
4145
- return this.options.panel;
4146
- }
4147
- get group() {
4148
- return this.options.group;
4149
- }
4150
- get api() {
4151
- return this.options.api;
4152
- }
4153
- constructor(options) {
4154
- super();
4155
- this.options = options;
4156
- }
4157
- getData() {
4158
- return this.options.getData();
4159
- }
4160
- }
4161
- class DockviewWillDropEvent extends DockviewDidDropEvent {
4162
- get kind() {
4163
- return this._kind;
4164
- }
4165
- constructor(options) {
4166
- super(options);
4167
- this._kind = options.kind;
4168
- }
4169
- }
4170
- class WillShowOverlayLocationEvent {
4171
- get kind() {
4172
- return this.options.kind;
4173
- }
4174
- get nativeEvent() {
4175
- return this.event.nativeEvent;
4176
- }
4177
- get position() {
4178
- return this.event.position;
4179
- }
4180
- get defaultPrevented() {
4181
- return this.event.defaultPrevented;
4182
- }
4183
- get panel() {
4184
- return this.options.panel;
4185
- }
4186
- get api() {
4187
- return this.options.api;
4188
- }
4189
- get group() {
4190
- return this.options.group;
4191
- }
4192
- preventDefault() {
4193
- this.event.preventDefault();
4194
- }
4195
- getData() {
4196
- return this.options.getData();
4197
- }
4198
- constructor(event, options) {
4199
- this.event = event;
4200
- this.options = options;
4201
- }
4202
- }
4203
- class DockviewGroupPanelModel extends CompositeDisposable {
4204
- get element() {
4205
- throw new Error('not supported');
4206
- }
4207
- get activePanel() {
4208
- return this._activePanel;
4209
- }
4210
- get locked() {
4211
- return this._locked;
4212
- }
4213
- set locked(value) {
4214
- this._locked = value;
4215
- toggleClass(this.container, 'locked-groupview', value === 'no-drop-target' || value);
4216
- }
4217
- get isActive() {
4218
- return this._isGroupActive;
4219
- }
4220
- get panels() {
4221
- return this._panels;
4222
- }
4223
- get size() {
4224
- return this._panels.length;
4225
- }
4226
- get isEmpty() {
4227
- return this._panels.length === 0;
4228
- }
4229
- get hasWatermark() {
4230
- return !!(this.watermark && this.container.contains(this.watermark.element));
4231
- }
4232
- get header() {
4233
- return this.tabsContainer;
4234
- }
4235
- get isContentFocused() {
4236
- if (!document.activeElement) {
4237
- return false;
4238
- }
4239
- return isAncestor(document.activeElement, this.contentContainer.element);
4240
- }
4241
- get location() {
4242
- return this._location;
4243
- }
4244
- set location(value) {
4245
- this._location = value;
4246
- toggleClass(this.container, 'dv-groupview-floating', false);
4247
- toggleClass(this.container, 'dv-groupview-popout', false);
4248
- switch (value.type) {
4249
- case 'grid':
4250
- this.contentContainer.dropTarget.setTargetZones([
4251
- 'top',
4252
- 'bottom',
4253
- 'left',
4254
- 'right',
4255
- 'center',
4256
- ]);
4257
- break;
4258
- case 'floating':
4259
- this.contentContainer.dropTarget.setTargetZones(['center']);
4260
- this.contentContainer.dropTarget.setTargetZones(value
4261
- ? ['center']
4262
- : ['top', 'bottom', 'left', 'right', 'center']);
4263
- toggleClass(this.container, 'dv-groupview-floating', true);
4264
- break;
4265
- case 'popout':
4266
- this.contentContainer.dropTarget.setTargetZones(['center']);
4267
- toggleClass(this.container, 'dv-groupview-popout', true);
4268
- break;
4269
- }
4270
- this.groupPanel.api._onDidLocationChange.fire({
4271
- location: this.location,
4272
- });
4273
- }
4274
- constructor(container, accessor, id, options, groupPanel) {
4275
- var _a;
4276
- super();
4277
- this.container = container;
4278
- this.accessor = accessor;
4279
- this.id = id;
4280
- this.options = options;
4281
- this.groupPanel = groupPanel;
4282
- this._isGroupActive = false;
4283
- this._locked = false;
4284
- this._location = { type: 'grid' };
4285
- this.mostRecentlyUsed = [];
4286
- this._onDidChange = new Emitter();
4287
- this.onDidChange = this._onDidChange.event;
4288
- this._width = 0;
4289
- this._height = 0;
4290
- this._panels = [];
4291
- this._panelDisposables = new Map();
4292
- this._onMove = new Emitter();
4293
- this.onMove = this._onMove.event;
4294
- this._onDidDrop = new Emitter();
4295
- this.onDidDrop = this._onDidDrop.event;
4296
- this._onWillDrop = new Emitter();
4297
- this.onWillDrop = this._onWillDrop.event;
4298
- this._onWillShowOverlay = new Emitter();
4299
- this.onWillShowOverlay = this._onWillShowOverlay.event;
4300
- this._onTabDragStart = new Emitter();
4301
- this.onTabDragStart = this._onTabDragStart.event;
4302
- this._onGroupDragStart = new Emitter();
4303
- this.onGroupDragStart = this._onGroupDragStart.event;
4304
- this._onDidAddPanel = new Emitter();
4305
- this.onDidAddPanel = this._onDidAddPanel.event;
4306
- this._onDidPanelTitleChange = new Emitter();
4307
- this.onDidPanelTitleChange = this._onDidPanelTitleChange.event;
4308
- this._onDidPanelParametersChange = new Emitter();
4309
- this.onDidPanelParametersChange = this._onDidPanelParametersChange.event;
4310
- this._onDidRemovePanel = new Emitter();
4311
- this.onDidRemovePanel = this._onDidRemovePanel.event;
4312
- this._onDidActivePanelChange = new Emitter();
4313
- this.onDidActivePanelChange = this._onDidActivePanelChange.event;
4314
- this._overwriteRenderContainer = null;
4315
- toggleClass(this.container, 'groupview', true);
4316
- this._api = new DockviewApi(this.accessor);
4317
- this.tabsContainer = new TabsContainer(this.accessor, this.groupPanel);
4318
- this.contentContainer = new ContentContainer(this.accessor, this);
4319
- container.append(this.tabsContainer.element, this.contentContainer.element);
4320
- this.header.hidden = !!options.hideHeader;
4321
- this.locked = (_a = options.locked) !== null && _a !== void 0 ? _a : false;
4322
- this.addDisposables(this._onTabDragStart, this._onGroupDragStart, this._onWillShowOverlay, this.tabsContainer.onTabDragStart((event) => {
4323
- this._onTabDragStart.fire(event);
4324
- }), this.tabsContainer.onGroupDragStart((event) => {
4325
- this._onGroupDragStart.fire(event);
4326
- }), this.tabsContainer.onDrop((event) => {
4327
- this.handleDropEvent('header', event.event, 'center', event.index);
4328
- }), this.contentContainer.onDidFocus(() => {
4329
- this.accessor.doSetGroupActive(this.groupPanel);
4330
- }), this.contentContainer.onDidBlur(() => {
4331
- // noop
4332
- }), this.contentContainer.dropTarget.onDrop((event) => {
4333
- this.handleDropEvent('content', event.nativeEvent, event.position);
4334
- }), this.tabsContainer.onWillShowOverlay((event) => {
4335
- this._onWillShowOverlay.fire(event);
4336
- }), this.contentContainer.dropTarget.onWillShowOverlay((event) => {
4337
- this._onWillShowOverlay.fire(new WillShowOverlayLocationEvent(event, {
4338
- kind: 'content',
4339
- panel: this.activePanel,
4340
- api: this._api,
4341
- group: this.groupPanel,
4342
- getData: getPanelData,
4343
- }));
4344
- }), this._onMove, this._onDidChange, this._onDidDrop, this._onWillDrop, this._onDidAddPanel, this._onDidRemovePanel, this._onDidActivePanelChange);
4345
- }
4346
- focusContent() {
4347
- this.contentContainer.element.focus();
4348
- }
4349
- set renderContainer(value) {
4350
- this.panels.forEach((panel) => {
4351
- this.renderContainer.detatch(panel);
4352
- });
4353
- this._overwriteRenderContainer = value;
4354
- this.panels.forEach((panel) => {
4355
- this.rerender(panel);
4356
- });
4357
- }
4358
- get renderContainer() {
4359
- var _a;
4360
- return ((_a = this._overwriteRenderContainer) !== null && _a !== void 0 ? _a : this.accessor.overlayRenderContainer);
4361
- }
4362
- initialize() {
4363
- if (this.options.panels) {
4364
- this.options.panels.forEach((panel) => {
4365
- this.doAddPanel(panel);
4366
- });
4367
- }
4368
- if (this.options.activePanel) {
4369
- this.openPanel(this.options.activePanel);
4370
- }
4371
- // must be run after the constructor otherwise this.parent may not be
4372
- // correctly initialized
4373
- this.setActive(this.isActive, true);
4374
- this.updateContainer();
4375
- if (this.accessor.options.createRightHeaderActionsElement) {
4376
- this._rightHeaderActions =
4377
- this.accessor.options.createRightHeaderActionsElement(this.groupPanel);
4378
- this.addDisposables(this._rightHeaderActions);
4379
- this._rightHeaderActions.init({
4380
- containerApi: this._api,
4381
- api: this.groupPanel.api,
4382
- });
4383
- this.tabsContainer.setRightActionsElement(this._rightHeaderActions.element);
4384
- }
4385
- if (this.accessor.options.createLeftHeaderActionsElement) {
4386
- this._leftHeaderActions =
4387
- this.accessor.options.createLeftHeaderActionsElement(this.groupPanel);
4388
- this.addDisposables(this._leftHeaderActions);
4389
- this._leftHeaderActions.init({
4390
- containerApi: this._api,
4391
- api: this.groupPanel.api,
4392
- });
4393
- this.tabsContainer.setLeftActionsElement(this._leftHeaderActions.element);
4394
- }
4395
- if (this.accessor.options.createPrefixHeaderActionsElement) {
4396
- this._prefixHeaderActions =
4397
- this.accessor.options.createPrefixHeaderActionsElement(this.groupPanel);
4398
- this.addDisposables(this._prefixHeaderActions);
4399
- this._prefixHeaderActions.init({
4400
- containerApi: this._api,
4401
- api: this.groupPanel.api,
4402
- });
4403
- this.tabsContainer.setPrefixActionsElement(this._prefixHeaderActions.element);
4404
- }
4405
- }
4406
- rerender(panel) {
4407
- this.contentContainer.renderPanel(panel, { asActive: false });
4408
- }
4409
- indexOf(panel) {
4410
- return this.tabsContainer.indexOf(panel.id);
4411
- }
4412
- toJSON() {
4413
- var _a;
4414
- const result = {
4415
- views: this.tabsContainer.panels,
4416
- activeView: (_a = this._activePanel) === null || _a === void 0 ? void 0 : _a.id,
4417
- id: this.id,
4418
- };
4419
- if (this.locked !== false) {
4420
- result.locked = this.locked;
4421
- }
4422
- if (this.header.hidden) {
4423
- result.hideHeader = true;
4424
- }
4425
- return result;
4426
- }
4427
- moveToNext(options) {
4428
- if (!options) {
4429
- options = {};
4430
- }
4431
- if (!options.panel) {
4432
- options.panel = this.activePanel;
4433
- }
4434
- const index = options.panel ? this.panels.indexOf(options.panel) : -1;
4435
- let normalizedIndex;
4436
- if (index < this.panels.length - 1) {
4437
- normalizedIndex = index + 1;
4438
- }
4439
- else if (!options.suppressRoll) {
4440
- normalizedIndex = 0;
4441
- }
4442
- else {
4443
- return;
4444
- }
4445
- this.openPanel(this.panels[normalizedIndex]);
4446
- }
4447
- moveToPrevious(options) {
4448
- if (!options) {
4449
- options = {};
4450
- }
4451
- if (!options.panel) {
4452
- options.panel = this.activePanel;
4453
- }
4454
- if (!options.panel) {
4455
- return;
4456
- }
4457
- const index = this.panels.indexOf(options.panel);
4458
- let normalizedIndex;
4459
- if (index > 0) {
4460
- normalizedIndex = index - 1;
4461
- }
4462
- else if (!options.suppressRoll) {
4463
- normalizedIndex = this.panels.length - 1;
4464
- }
4465
- else {
4466
- return;
4467
- }
4468
- this.openPanel(this.panels[normalizedIndex]);
4469
- }
4470
- containsPanel(panel) {
4471
- return this.panels.includes(panel);
4472
- }
4473
- init(_params) {
4474
- //noop
4475
- }
4476
- update(_params) {
4477
- //noop
4478
- }
4479
- focus() {
4480
- var _a;
4481
- (_a = this._activePanel) === null || _a === void 0 ? void 0 : _a.focus();
4482
- }
4483
- openPanel(panel, options = {}) {
4484
- /**
4485
- * set the panel group
4486
- * add the panel
4487
- * check if group active
4488
- * check if panel active
4489
- */
4490
- if (typeof options.index !== 'number' ||
4491
- options.index > this.panels.length) {
4492
- options.index = this.panels.length;
4493
- }
4494
- const skipSetActive = !!options.skipSetActive;
4495
- // ensure the group is updated before we fire any events
4496
- panel.updateParentGroup(this.groupPanel, {
4497
- skipSetActive: options.skipSetActive,
4498
- });
4499
- this.doAddPanel(panel, options.index, {
4500
- skipSetActive: skipSetActive,
4501
- });
4502
- if (this._activePanel === panel) {
4503
- this.contentContainer.renderPanel(panel, { asActive: true });
4504
- return;
4505
- }
4506
- if (!skipSetActive) {
4507
- this.doSetActivePanel(panel);
4508
- }
4509
- if (!options.skipSetGroupActive) {
4510
- this.accessor.doSetGroupActive(this.groupPanel);
4511
- }
4512
- if (!options.skipSetActive) {
4513
- this.updateContainer();
4514
- }
4515
- }
4516
- removePanel(groupItemOrId, options = {
4517
- skipSetActive: false,
4518
- }) {
4519
- const id = typeof groupItemOrId === 'string'
4520
- ? groupItemOrId
4521
- : groupItemOrId.id;
4522
- const panelToRemove = this._panels.find((panel) => panel.id === id);
4523
- if (!panelToRemove) {
4524
- throw new Error('invalid operation');
4525
- }
4526
- return this._removePanel(panelToRemove, options);
4527
- }
4528
- closeAllPanels() {
4529
- if (this.panels.length > 0) {
4530
- // take a copy since we will be edting the array as we iterate through
4531
- const arrPanelCpy = [...this.panels];
4532
- for (const panel of arrPanelCpy) {
4533
- this.doClose(panel);
4534
- }
4535
- }
4536
- else {
4537
- this.accessor.removeGroup(this.groupPanel);
4538
- }
4539
- }
4540
- closePanel(panel) {
4541
- this.doClose(panel);
4542
- }
4543
- doClose(panel) {
4544
- this.accessor.removePanel(panel);
4545
- }
4546
- isPanelActive(panel) {
4547
- return this._activePanel === panel;
4548
- }
4549
- updateActions(element) {
4550
- this.tabsContainer.setRightActionsElement(element);
4551
- }
4552
- setActive(isGroupActive, force = false) {
4553
- if (!force && this.isActive === isGroupActive) {
4554
- return;
4555
- }
4556
- this._isGroupActive = isGroupActive;
4557
- toggleClass(this.container, 'active-group', isGroupActive);
4558
- toggleClass(this.container, 'inactive-group', !isGroupActive);
4559
- this.tabsContainer.setActive(this.isActive);
4560
- if (!this._activePanel && this.panels.length > 0) {
4561
- this.doSetActivePanel(this.panels[0]);
4562
- }
4563
- this.updateContainer();
4564
- }
4565
- layout(width, height) {
4566
- var _a;
4567
- this._width = width;
4568
- this._height = height;
4569
- this.contentContainer.layout(this._width, this._height);
4570
- if ((_a = this._activePanel) === null || _a === void 0 ? void 0 : _a.layout) {
4571
- this._activePanel.layout(this._width, this._height);
4572
- }
4573
- }
4574
- _removePanel(panel, options) {
4575
- const isActivePanel = this._activePanel === panel;
4576
- this.doRemovePanel(panel);
4577
- if (isActivePanel && this.panels.length > 0) {
4578
- const nextPanel = this.mostRecentlyUsed[0];
4579
- this.openPanel(nextPanel, {
4580
- skipSetActive: options.skipSetActive,
4581
- skipSetGroupActive: options.skipSetActiveGroup,
4582
- });
4583
- }
4584
- if (this._activePanel && this.panels.length === 0) {
4585
- this.doSetActivePanel(undefined);
4586
- }
4587
- if (!options.skipSetActive) {
4588
- this.updateContainer();
4589
- }
4590
- return panel;
4591
- }
4592
- doRemovePanel(panel) {
4593
- const index = this.panels.indexOf(panel);
4594
- if (this._activePanel === panel) {
4595
- this.contentContainer.closePanel();
4596
- }
4597
- this.tabsContainer.delete(panel.id);
4598
- this._panels.splice(index, 1);
4599
- if (this.mostRecentlyUsed.includes(panel)) {
4600
- this.mostRecentlyUsed.splice(this.mostRecentlyUsed.indexOf(panel), 1);
4601
- }
4602
- const disposable = this._panelDisposables.get(panel.id);
4603
- if (disposable) {
4604
- disposable.dispose();
4605
- this._panelDisposables.delete(panel.id);
4606
- }
4607
- this._onDidRemovePanel.fire({ panel });
4608
- }
4609
- doAddPanel(panel, index = this.panels.length, options = { skipSetActive: false }) {
4610
- const existingPanel = this._panels.indexOf(panel);
4611
- const hasExistingPanel = existingPanel > -1;
4612
- this.tabsContainer.show();
4613
- this.contentContainer.show();
4614
- this.tabsContainer.openPanel(panel, index);
4615
- if (!options.skipSetActive) {
4616
- this.contentContainer.openPanel(panel);
4617
- }
4618
- if (hasExistingPanel) {
4619
- // TODO - need to ensure ordering hasn't changed and if it has need to re-order this.panels
4620
- return;
4621
- }
4622
- this.updateMru(panel);
4623
- this.panels.splice(index, 0, panel);
4624
- this._panelDisposables.set(panel.id, new CompositeDisposable(panel.api.onDidTitleChange((event) => this._onDidPanelTitleChange.fire(event)), panel.api.onDidParametersChange((event) => this._onDidPanelParametersChange.fire(event))));
4625
- this._onDidAddPanel.fire({ panel });
4626
- }
4627
- doSetActivePanel(panel) {
4628
- if (this._activePanel === panel) {
4629
- return;
4630
- }
4631
- this._activePanel = panel;
4632
- if (panel) {
4633
- this.tabsContainer.setActivePanel(panel);
4634
- panel.layout(this._width, this._height);
4635
- this.updateMru(panel);
4636
- this._onDidActivePanelChange.fire({
4637
- panel,
4638
- });
4639
- }
4640
- }
4641
- updateMru(panel) {
4642
- if (this.mostRecentlyUsed.includes(panel)) {
4643
- this.mostRecentlyUsed.splice(this.mostRecentlyUsed.indexOf(panel), 1);
4644
- }
4645
- this.mostRecentlyUsed = [panel, ...this.mostRecentlyUsed];
4646
- }
4647
- updateContainer() {
4648
- var _a, _b;
4649
- toggleClass(this.container, 'empty', this.isEmpty);
4650
- this.panels.forEach((panel) => panel.runEvents());
4651
- if (this.isEmpty && !this.watermark) {
4652
- const watermark = this.accessor.createWatermarkComponent();
4653
- watermark.init({
4654
- containerApi: this._api,
4655
- group: this.groupPanel,
4656
- });
4657
- this.watermark = watermark;
4658
- addDisposableListener(this.watermark.element, 'click', () => {
4659
- if (!this.isActive) {
4660
- this.accessor.doSetGroupActive(this.groupPanel);
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
+ });
4661
4284
  }
4662
- });
4663
- this.tabsContainer.hide();
4664
- this.contentContainer.element.appendChild(this.watermark.element);
4665
- this.watermark.updateParentGroup(this.groupPanel, true);
4666
- }
4667
- if (!this.isEmpty && this.watermark) {
4668
- this.watermark.element.remove();
4669
- (_b = (_a = this.watermark).dispose) === null || _b === void 0 ? void 0 : _b.call(_a);
4670
- this.watermark = undefined;
4671
- this.tabsContainer.show();
4672
- }
4673
- }
4674
- canDisplayOverlay(event, position, target) {
4675
- // custom overlay handler
4676
- if (this.accessor.options.showDndOverlay) {
4677
- return this.accessor.options.showDndOverlay({
4678
- nativeEvent: event,
4679
- target,
4680
- group: this.accessor.getPanel(this.id),
4681
- position,
4682
- getData: getPanelData,
4683
- });
4684
- }
4685
- return false;
4285
+ return false;
4286
+ },
4287
+ });
4288
+ this.addDisposables(this._onDidDrop, this.handler, this.target, this.target.onDrop((event) => {
4289
+ this.onDrop(event);
4290
+ }));
4686
4291
  }
4687
- handleDropEvent(type, event, position, index) {
4688
- if (this.locked === 'no-drop-target') {
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 }));
4689
4298
  return;
4690
4299
  }
4691
- function getKind() {
4692
- switch (type) {
4693
- case 'header':
4694
- return typeof index === 'number' ? 'tab' : 'header_space';
4695
- case 'content':
4696
- return 'content';
4697
- }
4698
- }
4699
- const panel = typeof index === 'number' ? this.panels[index] : undefined;
4700
- const willDropEvent = new DockviewWillDropEvent({
4701
- nativeEvent: event,
4702
- position,
4703
- panel,
4704
- getData: () => getPanelData(),
4705
- kind: getKind(),
4706
- group: this.groupPanel,
4707
- api: this._api,
4708
- });
4709
- this._onWillDrop.fire(willDropEvent);
4710
- if (willDropEvent.defaultPrevented) {
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) }));
4711
4307
  return;
4712
4308
  }
4713
- const data = getPanelData();
4714
- if (data && data.viewId === this.accessor.id) {
4715
- if (data.panelId === null) {
4716
- // this is a group move dnd event
4717
- const { groupId } = data;
4718
- this._onMove.fire({
4719
- target: position,
4720
- groupId: groupId,
4721
- index,
4722
- });
4723
- return;
4724
- }
4725
- const fromSameGroup = this.tabsContainer.indexOf(data.panelId) !== -1;
4726
- if (fromSameGroup && this.tabsContainer.size === 1) {
4727
- return;
4728
- }
4729
- const { groupId, panelId } = data;
4730
- const isSameGroup = this.id === groupId;
4731
- if (isSameGroup && !position) {
4732
- const oldIndex = this.tabsContainer.indexOf(panelId);
4733
- if (oldIndex === index) {
4734
- return;
4735
- }
4736
- }
4737
- this._onMove.fire({
4738
- target: position,
4739
- groupId: data.groupId,
4740
- itemId: data.panelId,
4741
- index,
4742
- });
4743
- }
4744
- else {
4745
- this._onDidDrop.fire(new DockviewDidDropEvent({
4746
- nativeEvent: event,
4747
- position,
4748
- panel,
4749
- getData: () => getPanelData(),
4750
- group: this.groupPanel,
4751
- api: this._api,
4752
- }));
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);
4753
4314
  }
4754
- }
4755
- dispose() {
4756
- var _a, _b, _c;
4757
- super.dispose();
4758
- (_a = this.watermark) === null || _a === void 0 ? void 0 : _a.element.remove();
4759
- (_c = (_b = this.watermark) === null || _b === void 0 ? void 0 : _b.dispose) === null || _c === void 0 ? void 0 : _c.call(_b);
4760
- this.watermark = undefined;
4761
- for (const panel of this.panels) {
4762
- panel.dispose();
4315
+ if (event.position === 'right' || event.position === 'bottom') {
4316
+ if (fromIndex > toIndex) {
4317
+ toIndex++;
4318
+ }
4319
+ toIndex = Math.min(allPanels.length - 1, toIndex);
4763
4320
  }
4764
- this.tabsContainer.dispose();
4765
- this.contentContainer.dispose();
4321
+ containerApi.movePanel(fromIndex, toIndex);
4766
4322
  }
4767
4323
  }
4768
4324
 
4769
- class Resizable extends CompositeDisposable {
4325
+ class ContentContainer extends CompositeDisposable {
4770
4326
  get element() {
4771
4327
  return this._element;
4772
4328
  }
4773
- get disableResizing() {
4774
- return this._disableResizing;
4329
+ constructor(accessor, group) {
4330
+ super();
4331
+ this.accessor = accessor;
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);
4775
4374
  }
4776
- set disableResizing(value) {
4777
- this._disableResizing = value;
4375
+ show() {
4376
+ this.element.style.display = '';
4778
4377
  }
4779
- constructor(parentElement, disableResizing = false) {
4780
- super();
4781
- this._disableResizing = disableResizing;
4782
- this._element = parentElement;
4783
- this.addDisposables(watchElementResize(this._element, (entry) => {
4784
- if (this.isDisposed) {
4785
- /**
4786
- * resize is delayed through requestAnimationFrame so there is a small chance
4787
- * the component has already been disposed of
4788
- */
4789
- return;
4790
- }
4791
- if (this.disableResizing) {
4792
- return;
4793
- }
4794
- if (!this._element.offsetParent) {
4795
- /**
4796
- * offsetParent === null is equivalent to display: none being set on the element or one
4797
- * of it's parents. In the display: none case the size will become (0, 0) which we do
4798
- * not want to propagate.
4799
- *
4800
- * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetParent
4801
- *
4802
- * You could use checkVisibility() but at the time of writing it's not supported across
4803
- * all Browsers
4804
- *
4805
- * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility
4806
- */
4807
- return;
4808
- }
4809
- if (!isInDocument(this._element)) {
4810
- /**
4811
- * since the event is dispatched through requestAnimationFrame there is a small chance
4812
- * the component is no longer attached to the DOM, if that is the case the dimensions
4813
- * are mostly likely all zero and meaningless. we should skip this case.
4814
- */
4815
- return;
4816
- }
4817
- const { width, height } = entry.contentRect;
4818
- this.layout(width, height);
4819
- }));
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);
4390
+ }
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;
4412
+ }
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;
4418
+ }
4820
4419
  }
4821
- }
4822
-
4823
- const nextLayoutId$1 = sequentialNumberGenerator();
4824
- function toTarget(direction) {
4825
- switch (direction) {
4826
- case 'left':
4827
- return 'left';
4828
- case 'right':
4829
- return 'right';
4830
- case 'above':
4831
- return 'top';
4832
- case 'below':
4833
- return 'bottom';
4834
- case 'within':
4835
- default:
4836
- return 'center';
4420
+ openPanel(panel) {
4421
+ if (this.panel === panel) {
4422
+ return;
4423
+ }
4424
+ this.renderPanel(panel);
4837
4425
  }
4838
- }
4839
- class BaseGrid extends Resizable {
4840
- get id() {
4841
- return this._id;
4426
+ layout(_width, _height) {
4427
+ // noop
4842
4428
  }
4843
- get size() {
4844
- return this._groups.size;
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
+ }
4435
+ }
4436
+ this.panel = undefined;
4845
4437
  }
4846
- get groups() {
4847
- return Array.from(this._groups.values()).map((_) => _.value);
4438
+ dispose() {
4439
+ this.disposable.dispose();
4440
+ super.dispose();
4848
4441
  }
4849
- get width() {
4850
- return this.gridview.width;
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();
4851
4451
  }
4852
- get height() {
4853
- return this.gridview.height;
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
+ };
4854
4459
  }
4855
- get minimumHeight() {
4856
- return this.gridview.minimumHeight;
4460
+ }
4461
+ class Tab extends CompositeDisposable {
4462
+ get element() {
4463
+ return this._element;
4857
4464
  }
4858
- get maximumHeight() {
4859
- return this.gridview.maximumHeight;
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
+ },
4500
+ });
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);
4860
4512
  }
4861
- get minimumWidth() {
4862
- return this.gridview.minimumWidth;
4513
+ setActive(isActive) {
4514
+ toggleClass(this.element, 'active-tab', isActive);
4515
+ toggleClass(this.element, 'inactive-tab', !isActive);
4863
4516
  }
4864
- get maximumWidth() {
4865
- return this.gridview.maximumWidth;
4517
+ setContent(part) {
4518
+ if (this.content) {
4519
+ this._element.removeChild(this.content.element);
4520
+ }
4521
+ this.content = part;
4522
+ this._element.appendChild(this.content.element);
4866
4523
  }
4867
- get activeGroup() {
4868
- return this._activeGroup;
4524
+ dispose() {
4525
+ super.dispose();
4869
4526
  }
4870
- get locked() {
4871
- return this.gridview.locked;
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);
4554
+ }
4555
+ }, true));
4872
4556
  }
4873
- set locked(value) {
4874
- this.gridview.locked = value;
4557
+ isCancelled(_event) {
4558
+ if (this.group.api.location.type === 'floating' && !_event.shiftKey) {
4559
+ return true;
4560
+ }
4561
+ return false;
4875
4562
  }
4876
- constructor(options) {
4877
- super(document.createElement('div'), options.disableAutoResizing);
4878
- this._id = nextLayoutId$1.next();
4879
- this._groups = new Map();
4880
- this._onDidLayoutChange = new Emitter();
4881
- this.onDidLayoutChange = this._onDidLayoutChange.event;
4882
- this._onDidRemove = new Emitter();
4883
- this.onDidRemove = this._onDidRemove.event;
4884
- this._onDidAdd = new Emitter();
4885
- this.onDidAdd = this._onDidAdd.event;
4886
- this._onDidActiveChange = new Emitter();
4887
- this.onDidActiveChange = this._onDidActiveChange.event;
4888
- this._bufferOnDidLayoutChange = new TickDelayedEvent();
4889
- this.element.style.height = '100%';
4890
- this.element.style.width = '100%';
4891
- options.parentElement.appendChild(this.element);
4892
- this.gridview = new Gridview(!!options.proportionalLayout, options.styles, options.orientation);
4893
- this.gridview.locked = !!options.locked;
4894
- this.element.appendChild(this.gridview.element);
4895
- this.layout(0, 0, true); // set some elements height/widths
4896
- this.addDisposables(Disposable.from(() => {
4897
- var _a;
4898
- (_a = this.element.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(this.element);
4899
- }), this.gridview.onDidChange(() => {
4900
- this._bufferOnDidLayoutChange.fire();
4901
- }), Event.any(this.onDidAdd, this.onDidRemove, this.onDidActiveChange)(() => {
4902
- this._bufferOnDidLayoutChange.fire();
4903
- }), this._bufferOnDidLayoutChange.onEvent(() => {
4904
- this._onDidLayoutChange.fire();
4905
- }), this._bufferOnDidLayoutChange);
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
+ };
4906
4587
  }
4907
- setVisible(panel, visible) {
4908
- this.gridview.setViewVisible(getGridLocation(panel.element), visible);
4909
- this._onDidLayoutChange.fire();
4588
+ }
4589
+
4590
+ class VoidContainer extends CompositeDisposable {
4591
+ get element() {
4592
+ return this._element;
4910
4593
  }
4911
- isVisible(panel) {
4912
- return this.gridview.isViewVisible(getGridLocation(panel.element));
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);
4913
4633
  }
4914
- maximizeGroup(panel) {
4915
- this.gridview.maximizeView(panel);
4916
- this.doSetGroupActive(panel);
4634
+ }
4635
+
4636
+ class TabsContainer extends CompositeDisposable {
4637
+ get panels() {
4638
+ return this.tabs.map((_) => _.value.panel.id);
4917
4639
  }
4918
- isMaximizedGroup(panel) {
4919
- return this.gridview.maximizedView() === panel;
4640
+ get size() {
4641
+ return this.tabs.length;
4920
4642
  }
4921
- exitMaximizedGroup() {
4922
- this.gridview.exitMaximizedView();
4643
+ get hidden() {
4644
+ return this._hidden;
4923
4645
  }
4924
- hasMaximizedGroup() {
4925
- return this.gridview.hasMaximizedView();
4646
+ set hidden(value) {
4647
+ this._hidden = value;
4648
+ this.element.style.display = value ? 'none' : '';
4926
4649
  }
4927
- get onDidMaximizedGroupChange() {
4928
- return this.gridview.onDidMaximizedNodeChange;
4650
+ show() {
4651
+ if (!this.hidden) {
4652
+ this.element.style.display = '';
4653
+ }
4929
4654
  }
4930
- doAddGroup(group, location = [0], size) {
4931
- this.gridview.addView(group, size !== null && size !== void 0 ? size : Sizing.Distribute, location);
4932
- this._onDidAdd.fire(group);
4655
+ hide() {
4656
+ this._element.style.display = 'none';
4933
4657
  }
4934
- doRemoveGroup(group, options) {
4935
- if (!this._groups.has(group.id)) {
4936
- throw new Error('invalid operation');
4658
+ setRightActionsElement(element) {
4659
+ if (this.rightActions === element) {
4660
+ return;
4937
4661
  }
4938
- const item = this._groups.get(group.id);
4939
- const view = this.gridview.remove(group, Sizing.Distribute);
4940
- if (item && !(options === null || options === void 0 ? void 0 : options.skipDispose)) {
4941
- item.disposable.dispose();
4942
- item.value.dispose();
4943
- this._groups.delete(group.id);
4944
- this._onDidRemove.fire(group);
4662
+ if (this.rightActions) {
4663
+ this.rightActions.remove();
4664
+ this.rightActions = undefined;
4945
4665
  }
4946
- if (!(options === null || options === void 0 ? void 0 : options.skipActive) && this._activeGroup === group) {
4947
- const groups = Array.from(this._groups.values());
4948
- this.doSetGroupActive(groups.length > 0 ? groups[0].value : undefined);
4666
+ if (element) {
4667
+ this.rightActionsContainer.appendChild(element);
4668
+ this.rightActions = element;
4949
4669
  }
4950
- return view;
4951
4670
  }
4952
- getPanel(id) {
4953
- var _a;
4954
- return (_a = this._groups.get(id)) === null || _a === void 0 ? void 0 : _a.value;
4671
+ setLeftActionsElement(element) {
4672
+ if (this.leftActions === element) {
4673
+ return;
4674
+ }
4675
+ if (this.leftActions) {
4676
+ this.leftActions.remove();
4677
+ this.leftActions = undefined;
4678
+ }
4679
+ if (element) {
4680
+ this.leftActionsContainer.appendChild(element);
4681
+ this.leftActions = element;
4682
+ }
4955
4683
  }
4956
- doSetGroupActive(group) {
4957
- if (this._activeGroup === group) {
4684
+ setPrefixActionsElement(element) {
4685
+ if (this.preActions === element) {
4958
4686
  return;
4959
4687
  }
4960
- if (this._activeGroup) {
4961
- this._activeGroup.setActive(false);
4688
+ if (this.preActions) {
4689
+ this.preActions.remove();
4690
+ this.preActions = undefined;
4962
4691
  }
4963
- if (group) {
4964
- group.setActive(true);
4692
+ if (element) {
4693
+ this.preActionsContainer.appendChild(element);
4694
+ this.preActions = element;
4965
4695
  }
4966
- this._activeGroup = group;
4967
- this._onDidActiveChange.fire(group);
4968
4696
  }
4969
- removeGroup(group) {
4970
- this.doRemoveGroup(group);
4697
+ get element() {
4698
+ return this._element;
4971
4699
  }
4972
- moveToNext(options) {
4700
+ isActive(tab) {
4701
+ return (this.selectedIndex > -1 &&
4702
+ this.tabs[this.selectedIndex].value === tab);
4703
+ }
4704
+ indexOf(id) {
4705
+ return this.tabs.findIndex((tab) => tab.value.panel.id === id);
4706
+ }
4707
+ constructor(accessor, group) {
4708
+ super();
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);
4742
+ }
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) {
4780
+ return;
4781
+ }
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) {
4973
4820
  var _a;
4974
- if (!options) {
4975
- options = {};
4821
+ if (this.tabs.find((tab) => tab.value.panel.id === panel.id)) {
4822
+ return;
4976
4823
  }
4977
- if (!options.group) {
4978
- if (!this.activeGroup) {
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 });
4979
4846
  return;
4980
4847
  }
4981
- options.group = this.activeGroup;
4982
- }
4983
- const location = getGridLocation(options.group.element);
4984
- const next = (_a = this.gridview.next(location)) === null || _a === void 0 ? void 0 : _a.view;
4985
- this.doSetGroupActive(next);
4986
- }
4987
- moveToPrevious(options) {
4988
- var _a;
4989
- if (!options) {
4990
- options = {};
4991
- }
4992
- if (!options.group) {
4993
- if (!this.activeGroup) {
4848
+ const isLeftClick = event.button === 0;
4849
+ if (!isLeftClick || event.defaultPrevented) {
4994
4850
  return;
4995
4851
  }
4996
- options.group = this.activeGroup;
4997
- }
4998
- const location = getGridLocation(options.group.element);
4999
- const next = (_a = this.gridview.previous(location)) === null || _a === void 0 ? void 0 : _a.view;
5000
- this.doSetGroupActive(next);
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
+ }));
4868
+ }));
4869
+ const value = { value: tab, disposable };
4870
+ this.addTab(value, index);
5001
4871
  }
5002
- layout(width, height, forceResize) {
5003
- const different = forceResize !== null && forceResize !== void 0 ? forceResize : (width !== this.width || height !== this.height);
5004
- if (!different) {
5005
- return;
5006
- }
5007
- this.gridview.element.style.height = `${height}px`;
5008
- this.gridview.element.style.width = `${width}px`;
5009
- this.gridview.layout(width, height);
4872
+ closePanel(panel) {
4873
+ this.delete(panel.id);
5010
4874
  }
5011
4875
  dispose() {
5012
- this._onDidActiveChange.dispose();
5013
- this._onDidAdd.dispose();
5014
- this._onDidRemove.dispose();
5015
- this._onDidLayoutChange.dispose();
5016
- for (const group of this.groups) {
5017
- group.dispose();
5018
- }
5019
- this.gridview.dispose();
5020
4876
  super.dispose();
4877
+ for (const { value, disposable } of this.tabs) {
4878
+ disposable.dispose();
4879
+ value.dispose();
4880
+ }
4881
+ this.tabs = [];
5021
4882
  }
5022
4883
  }
5023
4884
 
5024
- class WillFocusEvent extends DockviewEvent {
5025
- constructor() {
5026
- super();
4885
+ class DockviewUnhandledDragOverEvent {
4886
+ get isAccepted() {
4887
+ return this._isAccepted;
4888
+ }
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;
4896
+ }
4897
+ accept() {
4898
+ this._isAccepted = true;
5027
4899
  }
5028
4900
  }
5029
- /**
5030
- * A core api implementation that should be used across all panel-like objects
5031
- */
5032
- class PanelApiImpl extends CompositeDisposable {
5033
- get isFocused() {
5034
- return this._isFocused;
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;
5035
4924
  }
5036
- get isActive() {
5037
- return this._isActive;
4925
+ return false;
4926
+ }
4927
+ function isPanelOptionsWithGroup(data) {
4928
+ if (data.referenceGroup) {
4929
+ return true;
5038
4930
  }
5039
- get isVisible() {
5040
- return this._isVisible;
4931
+ return false;
4932
+ }
4933
+ function isGroupOptionsWithPanel(data) {
4934
+ if (data.referencePanel) {
4935
+ return true;
5041
4936
  }
5042
- get width() {
5043
- return this._width;
4937
+ return false;
4938
+ }
4939
+ function isGroupOptionsWithGroup(data) {
4940
+ if (data.referenceGroup) {
4941
+ return true;
5044
4942
  }
5045
- get height() {
5046
- return this._height;
4943
+ return false;
4944
+ }
4945
+
4946
+ class DockviewDidDropEvent extends DockviewEvent {
4947
+ get nativeEvent() {
4948
+ return this.options.nativeEvent;
5047
4949
  }
5048
- constructor(id, component) {
4950
+ get position() {
4951
+ return this.options.position;
4952
+ }
4953
+ get panel() {
4954
+ return this.options.panel;
4955
+ }
4956
+ get group() {
4957
+ return this.options.group;
4958
+ }
4959
+ get api() {
4960
+ return this.options.api;
4961
+ }
4962
+ constructor(options) {
5049
4963
  super();
5050
- this.id = id;
5051
- this.component = component;
5052
- this._isFocused = false;
5053
- this._isActive = false;
5054
- this._isVisible = true;
5055
- this._width = 0;
5056
- this._height = 0;
5057
- this._parameters = {};
5058
- this.panelUpdatesDisposable = new MutableDisposable();
5059
- this._onDidDimensionChange = new Emitter();
5060
- this.onDidDimensionsChange = this._onDidDimensionChange.event;
5061
- this._onDidChangeFocus = new Emitter();
5062
- this.onDidFocusChange = this._onDidChangeFocus.event;
5063
- //
5064
- this._onWillFocus = new Emitter();
5065
- this.onWillFocus = this._onWillFocus.event;
5066
- //
5067
- this._onDidVisibilityChange = new Emitter();
5068
- this.onDidVisibilityChange = this._onDidVisibilityChange.event;
5069
- this._onWillVisibilityChange = new Emitter();
5070
- this.onWillVisibilityChange = this._onWillVisibilityChange.event;
5071
- this._onDidActiveChange = new Emitter();
5072
- this.onDidActiveChange = this._onDidActiveChange.event;
5073
- this._onActiveChange = new Emitter();
5074
- this.onActiveChange = this._onActiveChange.event;
5075
- this._onDidParametersChange = new Emitter();
5076
- this.onDidParametersChange = this._onDidParametersChange.event;
5077
- this.addDisposables(this.onDidFocusChange((event) => {
5078
- this._isFocused = event.isFocused;
5079
- }), this.onDidActiveChange((event) => {
5080
- this._isActive = event.isActive;
5081
- }), this.onDidVisibilityChange((event) => {
5082
- this._isVisible = event.isVisible;
5083
- }), this.onDidDimensionsChange((event) => {
5084
- this._width = event.width;
5085
- this._height = event.height;
5086
- }), this.panelUpdatesDisposable, this._onDidDimensionChange, this._onDidChangeFocus, this._onDidVisibilityChange, this._onDidActiveChange, this._onWillFocus, this._onActiveChange, this._onWillFocus, this._onWillVisibilityChange, this._onDidParametersChange);
4964
+ this.options = options;
5087
4965
  }
5088
- getParameters() {
5089
- return this._parameters;
4966
+ getData() {
4967
+ return this.options.getData();
5090
4968
  }
5091
- initialize(panel) {
5092
- this.panelUpdatesDisposable.value = this._onDidParametersChange.event((parameters) => {
5093
- this._parameters = parameters;
5094
- panel.update({
5095
- params: parameters,
5096
- });
5097
- });
4969
+ }
4970
+ class DockviewWillDropEvent extends DockviewDidDropEvent {
4971
+ get kind() {
4972
+ return this._kind;
5098
4973
  }
5099
- setVisible(isVisible) {
5100
- this._onWillVisibilityChange.fire({ isVisible });
4974
+ constructor(options) {
4975
+ super(options);
4976
+ this._kind = options.kind;
5101
4977
  }
5102
- setActive() {
5103
- this._onActiveChange.fire();
4978
+ }
4979
+ class WillShowOverlayLocationEvent {
4980
+ get kind() {
4981
+ return this.options.kind;
5104
4982
  }
5105
- updateParameters(parameters) {
5106
- this._onDidParametersChange.fire(parameters);
4983
+ get nativeEvent() {
4984
+ return this.event.nativeEvent;
4985
+ }
4986
+ get position() {
4987
+ return this.event.position;
4988
+ }
4989
+ get defaultPrevented() {
4990
+ return this.event.defaultPrevented;
4991
+ }
4992
+ get panel() {
4993
+ return this.options.panel;
4994
+ }
4995
+ get api() {
4996
+ return this.options.api;
4997
+ }
4998
+ get group() {
4999
+ return this.options.group;
5000
+ }
5001
+ preventDefault() {
5002
+ this.event.preventDefault();
5003
+ }
5004
+ getData() {
5005
+ return this.options.getData();
5006
+ }
5007
+ constructor(event, options) {
5008
+ this.event = event;
5009
+ this.options = options;
5107
5010
  }
5108
5011
  }
5109
-
5110
- class SplitviewPanelApiImpl extends PanelApiImpl {
5111
- //
5112
- constructor(id, component) {
5113
- super(id, component);
5114
- this._onDidConstraintsChangeInternal = new Emitter();
5115
- this.onDidConstraintsChangeInternal = this._onDidConstraintsChangeInternal.event;
5116
- //
5117
- this._onDidConstraintsChange = new Emitter({
5118
- replay: true,
5119
- });
5120
- this.onDidConstraintsChange = this._onDidConstraintsChange.event;
5121
- //
5122
- this._onDidSizeChange = new Emitter();
5123
- this.onDidSizeChange = this._onDidSizeChange.event;
5124
- this.addDisposables(this._onDidConstraintsChangeInternal, this._onDidConstraintsChange, this._onDidSizeChange);
5012
+ class DockviewGroupPanelModel extends CompositeDisposable {
5013
+ get element() {
5014
+ throw new Error('not supported');
5125
5015
  }
5126
- setConstraints(value) {
5127
- this._onDidConstraintsChangeInternal.fire(value);
5016
+ get activePanel() {
5017
+ return this._activePanel;
5018
+ }
5019
+ get locked() {
5020
+ return this._locked;
5021
+ }
5022
+ set locked(value) {
5023
+ this._locked = value;
5024
+ toggleClass(this.container, 'locked-groupview', value === 'no-drop-target' || value);
5025
+ }
5026
+ get isActive() {
5027
+ return this._isGroupActive;
5128
5028
  }
5129
- setSize(event) {
5130
- this._onDidSizeChange.fire(event);
5029
+ get panels() {
5030
+ return this._panels;
5131
5031
  }
5132
- }
5133
-
5134
- class PaneviewPanelApiImpl extends SplitviewPanelApiImpl {
5135
- set pane(pane) {
5136
- this._pane = pane;
5032
+ get size() {
5033
+ return this._panels.length;
5137
5034
  }
5138
- constructor(id, component) {
5139
- super(id, component);
5140
- this._onDidExpansionChange = new Emitter({
5141
- replay: true,
5142
- });
5143
- this.onDidExpansionChange = this._onDidExpansionChange.event;
5144
- this._onMouseEnter = new Emitter({});
5145
- this.onMouseEnter = this._onMouseEnter.event;
5146
- this._onMouseLeave = new Emitter({});
5147
- this.onMouseLeave = this._onMouseLeave.event;
5148
- this.addDisposables(this._onDidExpansionChange, this._onMouseEnter, this._onMouseLeave);
5035
+ get isEmpty() {
5036
+ return this._panels.length === 0;
5149
5037
  }
5150
- setExpanded(isExpanded) {
5151
- var _a;
5152
- (_a = this._pane) === null || _a === void 0 ? void 0 : _a.setExpanded(isExpanded);
5038
+ get hasWatermark() {
5039
+ return !!(this.watermark && this.container.contains(this.watermark.element));
5153
5040
  }
5154
- get isExpanded() {
5155
- var _a;
5156
- return !!((_a = this._pane) === null || _a === void 0 ? void 0 : _a.isExpanded());
5041
+ get header() {
5042
+ return this.tabsContainer;
5157
5043
  }
5158
- }
5159
-
5160
- class BasePanelView extends CompositeDisposable {
5161
- get element() {
5162
- return this._element;
5044
+ get isContentFocused() {
5045
+ if (!document.activeElement) {
5046
+ return false;
5047
+ }
5048
+ return isAncestor(document.activeElement, this.contentContainer.element);
5163
5049
  }
5164
- get width() {
5165
- return this._width;
5050
+ get location() {
5051
+ return this._location;
5166
5052
  }
5167
- get height() {
5168
- return this._height;
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,
5081
+ });
5169
5082
  }
5170
- get params() {
5083
+ constructor(container, accessor, id, options, groupPanel) {
5171
5084
  var _a;
5172
- return (_a = this._params) === null || _a === void 0 ? void 0 : _a.params;
5173
- }
5174
- constructor(id, component, api) {
5175
5085
  super();
5086
+ this.container = container;
5087
+ this.accessor = accessor;
5176
5088
  this.id = id;
5177
- this.component = component;
5178
- this.api = api;
5179
- this._height = 0;
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;
5180
5097
  this._width = 0;
5181
- this._element = document.createElement('div');
5182
- this._element.tabIndex = -1;
5183
- this._element.style.outline = 'none';
5184
- this._element.style.height = '100%';
5185
- this._element.style.width = '100%';
5186
- this._element.style.overflow = 'hidden';
5187
- const focusTracker = trackFocus(this._element);
5188
- this.addDisposables(this.api, focusTracker.onDidFocus(() => {
5189
- this.api._onDidChangeFocus.fire({ isFocused: true });
5190
- }), focusTracker.onDidBlur(() => {
5191
- this.api._onDidChangeFocus.fire({ isFocused: false });
5192
- }), focusTracker);
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);
5193
5156
  }
5194
- focus() {
5195
- const event = new WillFocusEvent();
5196
- this.api._onWillFocus.fire(event);
5197
- if (event.defaultPrevented) {
5198
- return;
5199
- }
5200
- this._element.focus();
5157
+ focusContent() {
5158
+ this.contentContainer.element.focus();
5201
5159
  }
5202
- layout(width, height) {
5203
- this._width = width;
5204
- this._height = height;
5205
- this.api._onDidDimensionChange.fire({ width, height });
5206
- if (this.part) {
5207
- if (this._params) {
5208
- this.part.update(this._params.params);
5209
- }
5210
- }
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
+ });
5211
5168
  }
5212
- init(parameters) {
5213
- this._params = parameters;
5214
- this.part = this.getComponent();
5169
+ get renderContainer() {
5170
+ var _a;
5171
+ return ((_a = this._overwriteRenderContainer) !== null && _a !== void 0 ? _a : this.accessor.overlayRenderContainer);
5215
5172
  }
5216
- update(event) {
5217
- var _a, _b;
5218
- // merge the new parameters with the existing parameters
5219
- 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) });
5220
- /**
5221
- * delete new keys that have a value of undefined,
5222
- * allow values of null
5223
- */
5224
- for (const key of Object.keys(event.params)) {
5225
- if (event.params[key] === undefined) {
5226
- delete this._params.params[key];
5227
- }
5173
+ initialize() {
5174
+ if (this.options.panels) {
5175
+ this.options.panels.forEach((panel) => {
5176
+ this.doAddPanel(panel);
5177
+ });
5228
5178
  }
5229
- // update the view with the updated props
5230
- (_b = this.part) === null || _b === void 0 ? void 0 : _b.update({ params: this._params.params });
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);
5218
+ }
5219
+ }
5220
+ rerender(panel) {
5221
+ this.contentContainer.renderPanel(panel, { asActive: false });
5222
+ }
5223
+ indexOf(panel) {
5224
+ return this.tabsContainer.indexOf(panel.id);
5231
5225
  }
5232
5226
  toJSON() {
5233
- var _a, _b;
5234
- const params = (_b = (_a = this._params) === null || _a === void 0 ? void 0 : _a.params) !== null && _b !== void 0 ? _b : {};
5235
- 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,
5236
5231
  id: this.id,
5237
- component: this.component,
5238
- params: Object.keys(params).length > 0 ? params : undefined,
5239
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;
5240
5240
  }
5241
- dispose() {
5242
- var _a;
5243
- this.api.dispose();
5244
- (_a = this.part) === null || _a === void 0 ? void 0 : _a.dispose();
5245
- super.dispose();
5246
- }
5247
- }
5248
-
5249
- class PaneviewPanel extends BasePanelView {
5250
- set orientation(value) {
5251
- this._orientation = value;
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]);
5252
5260
  }
5253
- get orientation() {
5254
- return this._orientation;
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]);
5255
5283
  }
5256
- get minimumSize() {
5257
- const headerSize = this.headerSize;
5258
- const expanded = this.isExpanded();
5259
- const minimumBodySize = expanded ? this._minimumBodySize : 0;
5260
- return headerSize + minimumBodySize;
5284
+ containsPanel(panel) {
5285
+ return this.panels.includes(panel);
5261
5286
  }
5262
- get maximumSize() {
5263
- const headerSize = this.headerSize;
5264
- const expanded = this.isExpanded();
5265
- const maximumBodySize = expanded ? this._maximumBodySize : 0;
5266
- return headerSize + maximumBodySize;
5287
+ init(_params) {
5288
+ //noop
5267
5289
  }
5268
- get size() {
5269
- return this._size;
5290
+ update(_params) {
5291
+ //noop
5270
5292
  }
5271
- get orthogonalSize() {
5272
- return this._orthogonalSize;
5293
+ focus() {
5294
+ var _a;
5295
+ (_a = this._activePanel) === null || _a === void 0 ? void 0 : _a.focus();
5273
5296
  }
5274
- set orthogonalSize(size) {
5275
- this._orthogonalSize = size;
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 });
5318
+ return;
5319
+ }
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
+ }
5276
5329
  }
5277
- get minimumBodySize() {
5278
- return this._minimumBodySize;
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);
5279
5341
  }
5280
- set minimumBodySize(value) {
5281
- this._minimumBodySize = typeof value === 'number' ? value : 0;
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);
5348
+ }
5349
+ }
5350
+ else {
5351
+ this.accessor.removeGroup(this.groupPanel);
5352
+ }
5282
5353
  }
5283
- get maximumBodySize() {
5284
- return this._maximumBodySize;
5354
+ closePanel(panel) {
5355
+ this.doClose(panel);
5285
5356
  }
5286
- set maximumBodySize(value) {
5287
- this._maximumBodySize =
5288
- typeof value === 'number' ? value : Number.POSITIVE_INFINITY;
5357
+ doClose(panel) {
5358
+ this.accessor.removePanel(panel);
5289
5359
  }
5290
- get headerVisible() {
5291
- return this._headerVisible;
5360
+ isPanelActive(panel) {
5361
+ return this._activePanel === panel;
5292
5362
  }
5293
- set headerVisible(value) {
5294
- this._headerVisible = value;
5295
- this.header.style.display = value ? '' : 'none';
5363
+ updateActions(element) {
5364
+ this.tabsContainer.setRightActionsElement(element);
5296
5365
  }
5297
- constructor(id, component, headerComponent, orientation, isExpanded, isHeaderVisible) {
5298
- super(id, component, new PaneviewPanelApiImpl(id, component));
5299
- this.headerComponent = headerComponent;
5300
- this._onDidChangeExpansionState = new Emitter({ replay: true });
5301
- this.onDidChangeExpansionState = this._onDidChangeExpansionState.event;
5302
- this._onDidChange = new Emitter();
5303
- this.onDidChange = this._onDidChange.event;
5304
- this.headerSize = 22;
5305
- this._orthogonalSize = 0;
5306
- this._size = 0;
5307
- this._minimumBodySize = 100;
5308
- this._maximumBodySize = Number.POSITIVE_INFINITY;
5309
- this._isExpanded = false;
5310
- this.expandedSize = 0;
5311
- this.api.pane = this; // TODO cannot use 'this' before 'super'
5312
- this.api.initialize(this);
5313
- this._isExpanded = isExpanded;
5314
- this._headerVisible = isHeaderVisible;
5315
- this._onDidChangeExpansionState.fire(this.isExpanded()); // initialize value
5316
- this._orientation = orientation;
5317
- this.element.classList.add('pane');
5318
- this.addDisposables(this.api.onWillVisibilityChange((event) => {
5319
- const { isVisible } = event;
5320
- const { accessor } = this._params;
5321
- accessor.setVisible(this, isVisible);
5322
- }), this.api.onDidSizeChange((event) => {
5323
- this._onDidChange.fire({ size: event.size });
5324
- }), addDisposableListener(this.element, 'mouseenter', (ev) => {
5325
- this.api._onMouseEnter.fire(ev);
5326
- }), addDisposableListener(this.element, 'mouseleave', (ev) => {
5327
- this.api._onMouseLeave.fire(ev);
5328
- }));
5329
- this.addDisposables(this._onDidChangeExpansionState, this.onDidChangeExpansionState((isPanelExpanded) => {
5330
- this.api._onDidExpansionChange.fire({
5331
- isExpanded: isPanelExpanded,
5332
- });
5333
- }), this.api.onDidFocusChange((e) => {
5334
- if (!this.header) {
5335
- return;
5336
- }
5337
- if (e.isFocused) {
5338
- addClasses(this.header, 'focused');
5339
- }
5340
- else {
5341
- removeClasses(this.header, 'focused');
5342
- }
5343
- }));
5344
- this.renderOnce();
5366
+ setActive(isGroupActive, force = false) {
5367
+ if (!force && this.isActive === isGroupActive) {
5368
+ return;
5369
+ }
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();
5345
5378
  }
5346
- setVisible(isVisible) {
5347
- this.api._onDidVisibilityChange.fire({ isVisible });
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);
5386
+ }
5348
5387
  }
5349
- setActive(isActive) {
5350
- this.api._onDidActiveChange.fire({ isActive });
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
+ });
5397
+ }
5398
+ if (this._activePanel && this.panels.length === 0) {
5399
+ this.doSetActivePanel(undefined);
5400
+ }
5401
+ if (!options.skipSetActive) {
5402
+ this.updateContainer();
5403
+ }
5404
+ return panel;
5351
5405
  }
5352
- isExpanded() {
5353
- return this._isExpanded;
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 });
5354
5423
  }
5355
- setExpanded(expanded) {
5356
- if (this._isExpanded === expanded) {
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
5357
5435
  return;
5358
5436
  }
5359
- this._isExpanded = expanded;
5360
- if (expanded) {
5361
- if (this.animationTimer) {
5362
- clearTimeout(this.animationTimer);
5363
- }
5364
- if (this.body) {
5365
- this.element.appendChild(this.body);
5366
- }
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 });
5441
+ }
5442
+ doSetActivePanel(panel) {
5443
+ if (this._activePanel === panel) {
5444
+ return;
5367
5445
  }
5368
- else {
5369
- this.animationTimer = setTimeout(() => {
5370
- var _a;
5371
- (_a = this.body) === null || _a === void 0 ? void 0 : _a.remove();
5372
- }, 200);
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
+ });
5373
5454
  }
5374
- this._onDidChange.fire(expanded ? { size: this.width } : {});
5375
- this._onDidChangeExpansionState.fire(expanded);
5376
5455
  }
5377
- layout(size, orthogonalSize) {
5378
- this._size = size;
5379
- this._orthogonalSize = orthogonalSize;
5380
- const [width, height] = this.orientation === Orientation.HORIZONTAL
5381
- ? [size, orthogonalSize]
5382
- : [orthogonalSize, size];
5383
- if (this.isExpanded()) {
5384
- this.expandedSize = width;
5456
+ updateMru(panel) {
5457
+ if (this.mostRecentlyUsed.includes(panel)) {
5458
+ this.mostRecentlyUsed.splice(this.mostRecentlyUsed.indexOf(panel), 1);
5385
5459
  }
5386
- super.layout(width, height);
5460
+ this.mostRecentlyUsed = [panel, ...this.mostRecentlyUsed];
5387
5461
  }
5388
- init(parameters) {
5462
+ updateContainer() {
5389
5463
  var _a, _b;
5390
- super.init(parameters);
5391
- if (typeof parameters.minimumBodySize === 'number') {
5392
- this.minimumBodySize = parameters.minimumBodySize;
5393
- }
5394
- if (typeof parameters.maximumBodySize === 'number') {
5395
- this.maximumBodySize = parameters.maximumBodySize;
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);
5396
5481
  }
5397
- this.bodyPart = this.getBodyComponent();
5398
- this.headerPart = this.getHeaderComponent();
5399
- this.bodyPart.init(Object.assign(Object.assign({}, parameters), { api: this.api }));
5400
- this.headerPart.init(Object.assign(Object.assign({}, parameters), { api: this.api }));
5401
- (_a = this.body) === null || _a === void 0 ? void 0 : _a.append(this.bodyPart.element);
5402
- (_b = this.header) === null || _b === void 0 ? void 0 : _b.append(this.headerPart.element);
5403
- if (typeof parameters.isExpanded === 'boolean') {
5404
- this.setExpanded(parameters.isExpanded);
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();
5405
5487
  }
5406
5488
  }
5407
- toJSON() {
5408
- const params = this._params;
5409
- return Object.assign(Object.assign({}, super.toJSON()), { headerComponent: this.headerComponent, title: params.title });
5410
- }
5411
- renderOnce() {
5412
- this.header = document.createElement('div');
5413
- this.header.tabIndex = 0;
5414
- this.header.className = 'pane-header';
5415
- this.header.style.height = `${this.headerSize}px`;
5416
- this.header.style.lineHeight = `${this.headerSize}px`;
5417
- this.header.style.minHeight = `${this.headerSize}px`;
5418
- this.header.style.maxHeight = `${this.headerSize}px`;
5419
- this.element.appendChild(this.header);
5420
- this.body = document.createElement('div');
5421
- this.body.className = 'pane-body';
5422
- this.element.appendChild(this.body);
5423
- }
5424
- // TODO slightly hacky by-pass of the component to create a body and header component
5425
- getComponent() {
5426
- return {
5427
- update: (params) => {
5428
- var _a, _b;
5429
- (_a = this.bodyPart) === null || _a === void 0 ? void 0 : _a.update({ params });
5430
- (_b = this.headerPart) === null || _b === void 0 ? void 0 : _b.update({ params });
5431
- },
5432
- dispose: () => {
5433
- var _a, _b;
5434
- (_a = this.bodyPart) === null || _a === void 0 ? void 0 : _a.dispose();
5435
- (_b = this.headerPart) === null || _b === void 0 ? void 0 : _b.dispose();
5436
- },
5437
- };
5438
- }
5439
- }
5440
-
5441
- class DraggablePaneviewPanel extends PaneviewPanel {
5442
- constructor(accessor, id, component, headerComponent, orientation, isExpanded, disableDnd) {
5443
- super(id, component, headerComponent, orientation, isExpanded, true);
5444
- this.accessor = accessor;
5445
- this._onDidDrop = new Emitter();
5446
- this.onDidDrop = this._onDidDrop.event;
5447
- if (!disableDnd) {
5448
- this.initDragFeatures();
5449
- }
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;
5450
5493
  }
5451
- initDragFeatures() {
5452
- if (!this.header) {
5494
+ handleDropEvent(type, event, position, index) {
5495
+ if (this.locked === 'no-drop-target') {
5453
5496
  return;
5454
5497
  }
5455
- const id = this.id;
5456
- const accessorId = this.accessor.id;
5457
- this.header.draggable = true;
5458
- this.handler = new (class PaneDragHandler extends DragHandler {
5459
- getData() {
5460
- LocalSelectionTransfer.getInstance().setData([new PaneTransfer(accessorId, id)], PaneTransfer.prototype);
5461
- return {
5462
- dispose: () => {
5463
- LocalSelectionTransfer.getInstance().clearData(PaneTransfer.prototype);
5464
- },
5465
- };
5498
+ function getKind() {
5499
+ switch (type) {
5500
+ case 'header':
5501
+ return typeof index === 'number' ? 'tab' : 'header_space';
5502
+ case 'content':
5503
+ return 'content';
5466
5504
  }
5467
- })(this.header);
5468
- this.target = new Droptarget(this.element, {
5469
- acceptedTargetZones: ['top', 'bottom'],
5470
- overlayModel: {
5471
- activationSize: { type: 'percentage', value: 50 },
5472
- },
5473
- canDisplayOverlay: (event) => {
5474
- const data = getPaneData();
5475
- if (data) {
5476
- if (data.paneId !== this.id &&
5477
- data.viewId === this.accessor.id) {
5478
- return true;
5479
- }
5480
- }
5481
- if (this.accessor.options.showDndOverlay) {
5482
- return this.accessor.options.showDndOverlay({
5483
- nativeEvent: event,
5484
- getData: getPaneData,
5485
- panel: this,
5486
- });
5487
- }
5488
- return false;
5489
- },
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,
5490
5515
  });
5491
- this.addDisposables(this._onDidDrop, this.handler, this.target, this.target.onDrop((event) => {
5492
- this.onDrop(event);
5493
- }));
5494
- }
5495
- onDrop(event) {
5496
- const data = getPaneData();
5497
- if (!data || data.viewId !== this.accessor.id) {
5498
- // if there is no local drag event for this panel
5499
- // or if the drag event was creating by another Paneview instance
5500
- 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) {
5501
5518
  return;
5502
5519
  }
5503
- const containerApi = this._params
5504
- .containerApi;
5505
- const panelId = data.paneId;
5506
- const existingPanel = containerApi.getPanel(panelId);
5507
- if (!existingPanel) {
5508
- // if the panel doesn't exist
5509
- this._onDidDrop.fire(Object.assign(Object.assign({}, event), { panel: this, getData: getPaneData, api: new PaneviewApi(this.accessor) }));
5510
- 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
+ });
5511
5550
  }
5512
- const allPanels = containerApi.panels;
5513
- const fromIndex = allPanels.indexOf(existingPanel);
5514
- let toIndex = containerApi.panels.indexOf(this);
5515
- if (event.position === 'left' || event.position === 'top') {
5516
- 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
+ }));
5517
5560
  }
5518
- if (event.position === 'right' || event.position === 'bottom') {
5519
- if (fromIndex > toIndex) {
5520
- toIndex++;
5521
- }
5522
- 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();
5523
5570
  }
5524
- containerApi.movePanel(fromIndex, toIndex);
5571
+ this.tabsContainer.dispose();
5572
+ this.contentContainer.dispose();
5525
5573
  }
5526
5574
  }
5527
5575
 
@@ -5708,9 +5756,12 @@ class DockviewGroupPanelApiImpl extends GridviewPanelApiImpl {
5708
5756
  constructor(id, accessor) {
5709
5757
  super(id, '__dockviewgroup__');
5710
5758
  this.accessor = accessor;
5759
+ this._mutableDisposable = new MutableDisposable();
5711
5760
  this._onDidLocationChange = new Emitter();
5712
5761
  this.onDidLocationChange = this._onDidLocationChange.event;
5713
- this.addDisposables(this._onDidLocationChange);
5762
+ this._onDidActivePanelChange = new Emitter();
5763
+ this.onDidActivePanelChange = this._onDidActivePanelChange.event;
5764
+ this.addDisposables(this._onDidLocationChange, this._onDidActivePanelChange, this._mutableDisposable);
5714
5765
  }
5715
5766
  close() {
5716
5767
  if (!this._group) {
@@ -5768,6 +5819,19 @@ class DockviewGroupPanelApiImpl extends GridviewPanelApiImpl {
5768
5819
  }
5769
5820
  initialize(group) {
5770
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
+ });
5771
5835
  }
5772
5836
  }
5773
5837
 
@@ -5828,31 +5892,6 @@ class DockviewGroupPanel extends GridviewPanel {
5828
5892
  }
5829
5893
  }
5830
5894
 
5831
- function isPanelOptionsWithPanel(data) {
5832
- if (data.referencePanel) {
5833
- return true;
5834
- }
5835
- return false;
5836
- }
5837
- function isPanelOptionsWithGroup(data) {
5838
- if (data.referenceGroup) {
5839
- return true;
5840
- }
5841
- return false;
5842
- }
5843
- function isGroupOptionsWithPanel(data) {
5844
- if (data.referencePanel) {
5845
- return true;
5846
- }
5847
- return false;
5848
- }
5849
- function isGroupOptionsWithGroup(data) {
5850
- if (data.referenceGroup) {
5851
- return true;
5852
- }
5853
- return false;
5854
- }
5855
-
5856
5895
  class DockviewPanelApiImpl extends GridviewPanelApiImpl {
5857
5896
  get location() {
5858
5897
  return this.group.api.location;
@@ -6220,7 +6259,7 @@ class DockviewPanelModel {
6220
6259
  this._tab = this.createTabComponent(this.id, tabComponent);
6221
6260
  }
6222
6261
  init(params) {
6223
- this.content.init(Object.assign(Object.assign({}, params), { tab: this.tab }));
6262
+ this.content.init(params);
6224
6263
  this.tab.init(params);
6225
6264
  }
6226
6265
  updateParentGroup(_group, _isPanelVisible) {
@@ -6241,20 +6280,29 @@ class DockviewPanelModel {
6241
6280
  (_d = (_c = this.tab).dispose) === null || _d === void 0 ? void 0 : _d.call(_c);
6242
6281
  }
6243
6282
  createContentComponent(id, componentName) {
6244
- var _a, _b;
6245
- 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
+ });
6246
6287
  }
6247
6288
  createTabComponent(id, componentName) {
6248
- var _a, _b;
6249
- if (componentName) {
6250
- 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());
6251
- }
6252
- else if (this.accessor.options.defaultTabComponent) {
6253
- 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());
6254
- }
6255
- else {
6256
- 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.`);
6257
6304
  }
6305
+ return new DefaultTab();
6258
6306
  }
6259
6307
  }
6260
6308
 
@@ -6991,11 +7039,13 @@ class DockviewComponent extends BaseGrid {
6991
7039
  return this._api;
6992
7040
  }
6993
7041
  constructor(options) {
6994
- var _a, _b;
7042
+ var _a;
6995
7043
  super({
6996
7044
  proportionalLayout: true,
6997
- orientation: (_a = options.orientation) !== null && _a !== void 0 ? _a : Orientation.HORIZONTAL,
6998
- styles: options.styles,
7045
+ orientation: Orientation.HORIZONTAL,
7046
+ styles: options.hideBorders
7047
+ ? { separatorBorder: 'transparent' }
7048
+ : undefined,
6999
7049
  parentElement: options.parentElement,
7000
7050
  disableAutoResizing: options.disableAutoResizing,
7001
7051
  locked: options.locked,
@@ -7013,6 +7063,8 @@ class DockviewComponent extends BaseGrid {
7013
7063
  this.onWillDrop = this._onWillDrop.event;
7014
7064
  this._onWillShowOverlay = new Emitter();
7015
7065
  this.onWillShowOverlay = this._onWillShowOverlay.event;
7066
+ this._onUnhandledDragOverEvent = new Emitter();
7067
+ this.onUnhandledDragOverEvent = this._onUnhandledDragOverEvent.event;
7016
7068
  this._onDidRemovePanel = new Emitter();
7017
7069
  this.onDidRemovePanel = this._onDidRemovePanel.event;
7018
7070
  this._onDidAddPanel = new Emitter();
@@ -7038,7 +7090,7 @@ class DockviewComponent extends BaseGrid {
7038
7090
  this.overlayRenderContainer = new OverlayRenderContainer(gready);
7039
7091
  toggleClass(this.gridview.element, 'dv-dockview', true);
7040
7092
  toggleClass(this.element, 'dv-debug', !!options.debug);
7041
- 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) => {
7093
+ 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) => {
7042
7094
  if (!this._moving) {
7043
7095
  this._onDidAddGroup.fire(event);
7044
7096
  }
@@ -7065,22 +7117,6 @@ class DockviewComponent extends BaseGrid {
7065
7117
  }
7066
7118
  }));
7067
7119
  this._options = options;
7068
- if (!this.options.components) {
7069
- this.options.components = {};
7070
- }
7071
- if (!this.options.frameworkComponents) {
7072
- this.options.frameworkComponents = {};
7073
- }
7074
- if (!this.options.frameworkTabComponents) {
7075
- this.options.frameworkTabComponents = {};
7076
- }
7077
- if (!this.options.tabComponents) {
7078
- this.options.tabComponents = {};
7079
- }
7080
- if (!this.options.watermarkComponent &&
7081
- !this.options.watermarkFrameworkComponent) {
7082
- this.options.watermarkComponent = Watermark;
7083
- }
7084
7120
  this._rootDropTarget = new Droptarget(this.element, {
7085
7121
  canDisplayOverlay: (event, position) => {
7086
7122
  const data = getPanelData();
@@ -7095,26 +7131,20 @@ class DockviewComponent extends BaseGrid {
7095
7131
  }
7096
7132
  return true;
7097
7133
  }
7098
- if (this.options.showDndOverlay) {
7099
- if (position === 'center' && this.gridview.length !== 0) {
7100
- /**
7101
- * for external events only show the four-corner drag overlays, disable
7102
- * the center position so that external drag events can fall through to the group
7103
- * and panel drop target handlers
7104
- */
7105
- return false;
7106
- }
7107
- return this.options.showDndOverlay({
7108
- nativeEvent: event,
7109
- position: position,
7110
- target: 'edge',
7111
- getData: getPanelData,
7112
- });
7134
+ if (position === 'center' && this.gridview.length !== 0) {
7135
+ /**
7136
+ * for external events only show the four-corner drag overlays, disable
7137
+ * the center position so that external drag events can fall through to the group
7138
+ * and panel drop target handlers
7139
+ */
7140
+ return false;
7113
7141
  }
7114
- return false;
7142
+ const firedEvent = new DockviewUnhandledDragOverEvent(event, 'edge', position, getPanelData);
7143
+ this._onUnhandledDragOverEvent.fire(firedEvent);
7144
+ return firedEvent.isAccepted;
7115
7145
  },
7116
7146
  acceptedTargetZones: ['top', 'bottom', 'left', 'right', 'center'],
7117
- overlayModel: (_b = this.options.rootOverlayModel) !== null && _b !== void 0 ? _b : DEFAULT_ROOT_OVERLAY_MODEL,
7147
+ overlayModel: (_a = this.options.rootOverlayModel) !== null && _a !== void 0 ? _a : DEFAULT_ROOT_OVERLAY_MODEL,
7118
7148
  });
7119
7149
  this.addDisposables(this._rootDropTarget, this._rootDropTarget.onWillShowOverlay((event) => {
7120
7150
  if (this.gridview.length > 0 && event.position === 'center') {
@@ -7338,7 +7368,7 @@ class DockviewComponent extends BaseGrid {
7338
7368
  skipDispose: true,
7339
7369
  skipSetActiveGroup: true,
7340
7370
  }));
7341
- group.model.openPanel(item, { skipSetGroupActive: true });
7371
+ this.movingLock(() => group.model.openPanel(item, { skipSetGroupActive: true }));
7342
7372
  }
7343
7373
  else {
7344
7374
  group = item;
@@ -7411,7 +7441,7 @@ class DockviewComponent extends BaseGrid {
7411
7441
  // this is either a resize or a move
7412
7442
  // to inform the panels .layout(...) the group with it's current size
7413
7443
  // don't care about resize since the above watcher handles that
7414
- group.layout(group.height, group.width);
7444
+ group.layout(group.width, group.height);
7415
7445
  }), overlay.onDidChangeEnd(() => {
7416
7446
  this._bufferOnDidLayoutChange.fire();
7417
7447
  }), group.onDidChange((event) => {
@@ -7466,16 +7496,11 @@ class DockviewComponent extends BaseGrid {
7466
7496
  }
7467
7497
  updateOptions(options) {
7468
7498
  var _a, _b;
7469
- const changed_orientation = typeof options.orientation === 'string' &&
7470
- this.gridview.orientation !== options.orientation;
7471
- const changed_floatingGroupBounds = options.floatingGroupBounds !== undefined &&
7499
+ const changed_floatingGroupBounds = 'floatingGroupBounds' in options &&
7472
7500
  options.floatingGroupBounds !== this.options.floatingGroupBounds;
7473
- const changed_rootOverlayOptions = options.rootOverlayModel !== undefined &&
7501
+ const changed_rootOverlayOptions = 'rootOverlayModel' in options &&
7474
7502
  options.rootOverlayModel !== this.options.rootOverlayModel;
7475
7503
  this._options = Object.assign(Object.assign({}, this.options), options);
7476
- if (changed_orientation) {
7477
- this.gridview.orientation = options.orientation;
7478
- }
7479
7504
  if (changed_floatingGroupBounds) {
7480
7505
  for (const group of this._floatingGroups) {
7481
7506
  switch (this.options.floatingGroupBounds) {
@@ -7763,7 +7788,7 @@ class DockviewComponent extends BaseGrid {
7763
7788
  ? this.getGroupPanel(options.position.referencePanel)
7764
7789
  : options.position.referencePanel;
7765
7790
  if (!referencePanel) {
7766
- throw new Error(`referencePanel ${options.position.referencePanel} does not exist`);
7791
+ throw new Error(`referencePanel '${options.position.referencePanel}' does not exist`);
7767
7792
  }
7768
7793
  referenceGroup = this.findGroup(referencePanel);
7769
7794
  }
@@ -7773,14 +7798,19 @@ class DockviewComponent extends BaseGrid {
7773
7798
  ? (_a = this._groups.get(options.position.referenceGroup)) === null || _a === void 0 ? void 0 : _a.value
7774
7799
  : options.position.referenceGroup;
7775
7800
  if (!referenceGroup) {
7776
- throw new Error(`referencePanel ${options.position.referenceGroup} does not exist`);
7801
+ throw new Error(`referenceGroup '${options.position.referenceGroup}' does not exist`);
7777
7802
  }
7778
7803
  }
7779
7804
  else {
7780
7805
  const group = this.orthogonalize(directionToPosition(options.position.direction));
7781
7806
  const panel = this.createPanel(options, group);
7782
- group.model.openPanel(panel);
7783
- this.doSetGroupAndPanelActive(group);
7807
+ group.model.openPanel(panel, {
7808
+ skipSetActive: options.inactive,
7809
+ skipSetGroupActive: options.inactive,
7810
+ });
7811
+ if (!options.inactive) {
7812
+ this.doSetGroupAndPanelActive(group);
7813
+ }
7784
7814
  return panel;
7785
7815
  }
7786
7816
  }
@@ -7803,43 +7833,64 @@ class DockviewComponent extends BaseGrid {
7803
7833
  skipActiveGroup: true,
7804
7834
  });
7805
7835
  panel = this.createPanel(options, group);
7806
- group.model.openPanel(panel);
7836
+ group.model.openPanel(panel, {
7837
+ skipSetActive: options.inactive,
7838
+ skipSetGroupActive: options.inactive,
7839
+ });
7807
7840
  }
7808
7841
  else if (referenceGroup.api.location.type === 'floating' ||
7809
7842
  target === 'center') {
7810
7843
  panel = this.createPanel(options, referenceGroup);
7811
- referenceGroup.model.openPanel(panel);
7812
- this.doSetGroupAndPanelActive(referenceGroup);
7844
+ referenceGroup.model.openPanel(panel, {
7845
+ skipSetActive: options.inactive,
7846
+ skipSetGroupActive: options.inactive,
7847
+ });
7848
+ if (!options.inactive) {
7849
+ this.doSetGroupAndPanelActive(referenceGroup);
7850
+ }
7813
7851
  }
7814
7852
  else {
7815
7853
  const location = getGridLocation(referenceGroup.element);
7816
7854
  const relativeLocation = getRelativeLocation(this.gridview.orientation, location, target);
7817
7855
  const group = this.createGroupAtLocation(relativeLocation);
7818
7856
  panel = this.createPanel(options, group);
7819
- group.model.openPanel(panel);
7820
- this.doSetGroupAndPanelActive(group);
7857
+ group.model.openPanel(panel, {
7858
+ skipSetActive: options.inactive,
7859
+ skipSetGroupActive: options.inactive,
7860
+ });
7861
+ if (!options.inactive) {
7862
+ this.doSetGroupAndPanelActive(group);
7863
+ }
7821
7864
  }
7822
7865
  }
7823
7866
  else if (options.floating) {
7824
7867
  const group = this.createGroup();
7825
7868
  this._onDidAddGroup.fire(group);
7826
- const o = typeof options.floating === 'object' &&
7869
+ const coordinates = typeof options.floating === 'object' &&
7827
7870
  options.floating !== null
7828
7871
  ? options.floating
7829
7872
  : {};
7830
- this.addFloatingGroup(group, o, {
7873
+ this.addFloatingGroup(group, coordinates, {
7831
7874
  inDragMode: false,
7832
7875
  skipRemoveGroup: true,
7833
7876
  skipActiveGroup: true,
7834
7877
  });
7835
7878
  panel = this.createPanel(options, group);
7836
- group.model.openPanel(panel);
7879
+ group.model.openPanel(panel, {
7880
+ skipSetActive: options.inactive,
7881
+ skipSetGroupActive: options.inactive,
7882
+ });
7837
7883
  }
7838
7884
  else {
7839
7885
  const group = this.createGroupAtLocation();
7840
7886
  panel = this.createPanel(options, group);
7841
- group.model.openPanel(panel);
7842
- this.doSetGroupAndPanelActive(group);
7887
+ group.model.openPanel(panel, {
7888
+ skipSetActive: options.inactive,
7889
+ skipSetGroupActive: options.inactive,
7890
+ });
7891
+ if (!options.inactive) {
7892
+ this.doSetGroupAndPanelActive(group);
7893
+ }
7843
7894
  }
7844
7895
  return panel;
7845
7896
  }
@@ -7863,12 +7914,10 @@ class DockviewComponent extends BaseGrid {
7863
7914
  }
7864
7915
  }
7865
7916
  createWatermarkComponent() {
7866
- var _a;
7867
- return createComponent('watermark-id', 'watermark-name', this.options.watermarkComponent
7868
- ? { 'watermark-name': this.options.watermarkComponent }
7869
- : {}, this.options.watermarkFrameworkComponent
7870
- ? { 'watermark-name': this.options.watermarkFrameworkComponent }
7871
- : {}, (_a = this.options.frameworkComponentFactory) === null || _a === void 0 ? void 0 : _a.watermark);
7917
+ if (this.options.createWatermarkComponent) {
7918
+ return this.options.createWatermarkComponent();
7919
+ }
7920
+ return new Watermark();
7872
7921
  }
7873
7922
  updateWatermark() {
7874
7923
  var _a, _b;
@@ -8249,6 +8298,8 @@ class DockviewComponent extends BaseGrid {
8249
8298
  return;
8250
8299
  }
8251
8300
  this._onWillShowOverlay.fire(event);
8301
+ }), view.model.onUnhandledDragOverEvent((event) => {
8302
+ this._onUnhandledDragOverEvent.fire(event);
8252
8303
  }), view.model.onDidAddPanel((event) => {
8253
8304
  if (this._moving) {
8254
8305
  return;
@@ -9494,11 +9545,6 @@ class ReactWatermarkPart {
9494
9545
  this.part = new ReactPart(this.element, this.reactPortalStore, this.component, {
9495
9546
  group: parameters.group,
9496
9547
  containerApi: parameters.containerApi,
9497
- close: () => {
9498
- if (parameters.group) {
9499
- parameters.containerApi.removeGroup(parameters.group);
9500
- }
9501
- },
9502
9548
  });
9503
9549
  }
9504
9550
  focus() {
@@ -9530,9 +9576,6 @@ class ReactHeaderActionsRendererPart {
9530
9576
  get part() {
9531
9577
  return this._part;
9532
9578
  }
9533
- get group() {
9534
- return this._group;
9535
- }
9536
9579
  constructor(component, reactPortalStore, _group) {
9537
9580
  this.component = component;
9538
9581
  this.reactPortalStore = reactPortalStore;
@@ -9543,9 +9586,6 @@ class ReactHeaderActionsRendererPart {
9543
9586
  this._element.style.height = '100%';
9544
9587
  this._element.style.width = '100%';
9545
9588
  }
9546
- focus() {
9547
- // TODO
9548
- }
9549
9589
  init(parameters) {
9550
9590
  this.mutableDisposable.value = new CompositeDisposable(this._group.model.onDidAddPanel(() => {
9551
9591
  this.updatePanels();
@@ -9565,15 +9605,15 @@ class ReactHeaderActionsRendererPart {
9565
9605
  group: this._group,
9566
9606
  });
9567
9607
  }
9568
- update(event) {
9569
- var _a;
9570
- (_a = this._part) === null || _a === void 0 ? void 0 : _a.update(event.params);
9571
- }
9572
9608
  dispose() {
9573
9609
  var _a;
9574
9610
  this.mutableDisposable.dispose();
9575
9611
  (_a = this._part) === null || _a === void 0 ? void 0 : _a.dispose();
9576
9612
  }
9613
+ update(event) {
9614
+ var _a;
9615
+ (_a = this._part) === null || _a === void 0 ? void 0 : _a.update(event.params);
9616
+ }
9577
9617
  updatePanels() {
9578
9618
  this.update({ params: { panels: this._group.model.panels } });
9579
9619
  }
@@ -9601,72 +9641,72 @@ function createGroupControlElement(component, store) {
9601
9641
  : undefined;
9602
9642
  }
9603
9643
  const DEFAULT_REACT_TAB = 'props.defaultTabComponent';
9644
+ function extractCoreOptions(props) {
9645
+ const coreOptions = PROPERTY_KEYS.reduce((obj, key) => {
9646
+ if (key in props) {
9647
+ obj[key] = props[key];
9648
+ }
9649
+ return obj;
9650
+ }, {});
9651
+ return coreOptions;
9652
+ }
9604
9653
  const DockviewReact = React.forwardRef((props, ref) => {
9605
9654
  const domRef = React.useRef(null);
9606
9655
  const dockviewRef = React.useRef();
9607
9656
  const [portals, addPortal] = usePortalsLifecycle();
9608
9657
  React.useImperativeHandle(ref, () => domRef.current, []);
9658
+ const prevProps = React.useRef({});
9659
+ React.useEffect(() => {
9660
+ const changes = {};
9661
+ PROPERTY_KEYS.forEach((propKey) => {
9662
+ const key = propKey;
9663
+ const propValue = props[key];
9664
+ if (key in props && propValue !== prevProps.current[key]) {
9665
+ changes[key] = propValue;
9666
+ }
9667
+ });
9668
+ if (dockviewRef.current) {
9669
+ dockviewRef.current.updateOptions(changes);
9670
+ }
9671
+ prevProps.current = props;
9672
+ }, PROPERTY_KEYS.map((key) => props[key]));
9609
9673
  React.useEffect(() => {
9610
9674
  var _a;
9611
9675
  if (!domRef.current) {
9612
- return () => {
9613
- // noop
9614
- };
9676
+ return;
9615
9677
  }
9616
- const factory = {
9617
- content: {
9618
- createComponent: (_id, componentId, component) => {
9619
- return new ReactPanelContentPart(componentId, component, {
9620
- addPortal,
9621
- });
9622
- },
9623
- },
9624
- tab: {
9625
- createComponent: (_id, componentId, component) => {
9626
- return new ReactPanelHeaderPart(componentId, component, {
9627
- addPortal,
9628
- });
9629
- },
9630
- },
9631
- watermark: {
9632
- createComponent: (_id, componentId, component) => {
9633
- return new ReactWatermarkPart(componentId, component, {
9634
- addPortal,
9635
- });
9636
- },
9637
- },
9638
- };
9639
9678
  const frameworkTabComponents = (_a = props.tabComponents) !== null && _a !== void 0 ? _a : {};
9640
9679
  if (props.defaultTabComponent) {
9641
9680
  frameworkTabComponents[DEFAULT_REACT_TAB] =
9642
9681
  props.defaultTabComponent;
9643
9682
  }
9644
- const dockview = new DockviewComponent({
9683
+ const frameworkOptions = {
9684
+ createLeftHeaderActionComponent: createGroupControlElement(props.leftHeaderActionsComponent, { addPortal }),
9685
+ createRightHeaderActionComponent: createGroupControlElement(props.rightHeaderActionsComponent, { addPortal }),
9686
+ createPrefixHeaderActionComponent: createGroupControlElement(props.prefixHeaderActionsComponent, { addPortal }),
9687
+ createComponent: (options) => {
9688
+ return new ReactPanelContentPart(options.id, props.components[options.name], {
9689
+ addPortal,
9690
+ });
9691
+ },
9692
+ createTabComponent(options) {
9693
+ return new ReactPanelHeaderPart(options.id, frameworkTabComponents[options.name], {
9694
+ addPortal,
9695
+ });
9696
+ },
9697
+ createWatermarkComponent: props.watermarkComponent
9698
+ ? () => {
9699
+ return new ReactWatermarkPart('watermark', props.watermarkComponent, {
9700
+ addPortal,
9701
+ });
9702
+ }
9703
+ : undefined,
9645
9704
  parentElement: domRef.current,
9646
- frameworkComponentFactory: factory,
9647
- frameworkComponents: props.components,
9648
- disableAutoResizing: props.disableAutoResizing,
9649
- frameworkTabComponents,
9650
- watermarkFrameworkComponent: props.watermarkComponent,
9651
9705
  defaultTabComponent: props.defaultTabComponent
9652
9706
  ? DEFAULT_REACT_TAB
9653
9707
  : undefined,
9654
- styles: props.hideBorders
9655
- ? { separatorBorder: 'transparent' }
9656
- : undefined,
9657
- showDndOverlay: props.showDndOverlay,
9658
- createLeftHeaderActionsElement: createGroupControlElement(props.leftHeaderActionsComponent, { addPortal }),
9659
- createRightHeaderActionsElement: createGroupControlElement(props.rightHeaderActionsComponent, { addPortal }),
9660
- createPrefixHeaderActionsElement: createGroupControlElement(props.prefixHeaderActionsComponent, { addPortal }),
9661
- singleTabMode: props.singleTabMode,
9662
- disableFloatingGroups: props.disableFloatingGroups,
9663
- floatingGroupBounds: props.floatingGroupBounds,
9664
- defaultRenderer: props.defaultRenderer,
9665
- debug: props.debug,
9666
- rootOverlayModel: props.rootOverlayModel,
9667
- locked: props.locked,
9668
- disableDnd: props.disableDnd,
9669
- });
9708
+ };
9709
+ const dockview = new DockviewComponent(Object.assign(Object.assign({}, extractCoreOptions(props)), frameworkOptions));
9670
9710
  const { clientWidth, clientHeight } = domRef.current;
9671
9711
  dockview.layout(clientWidth, clientHeight);
9672
9712
  if (props.onReady) {
@@ -9677,20 +9717,6 @@ const DockviewReact = React.forwardRef((props, ref) => {
9677
9717
  dockview.dispose();
9678
9718
  };
9679
9719
  }, []);
9680
- React.useEffect(() => {
9681
- if (!dockviewRef.current) {
9682
- return;
9683
- }
9684
- dockviewRef.current.locked = !!props.locked;
9685
- }, [props.locked]);
9686
- React.useEffect(() => {
9687
- if (!dockviewRef.current) {
9688
- return;
9689
- }
9690
- dockviewRef.current.updateOptions({
9691
- disableDnd: props.disableDnd,
9692
- });
9693
- }, [props.disableDnd]);
9694
9720
  React.useEffect(() => {
9695
9721
  if (!dockviewRef.current) {
9696
9722
  return () => {
@@ -9712,63 +9738,43 @@ const DockviewReact = React.forwardRef((props, ref) => {
9712
9738
  // noop
9713
9739
  };
9714
9740
  }
9715
- const disposable = dockviewRef.current.onWillDrop((event) => {
9716
- if (props.onWillDrop) {
9717
- props.onWillDrop(event);
9741
+ const disposable = dockviewRef.current.onUnhandledDragOverEvent((event) => {
9742
+ var _a;
9743
+ if ((_a = props.showDndOverlay) === null || _a === void 0 ? void 0 : _a.call(props, event)) {
9744
+ event.accept();
9718
9745
  }
9719
9746
  });
9720
9747
  return () => {
9721
9748
  disposable.dispose();
9722
9749
  };
9723
- }, [props.onWillDrop]);
9724
- React.useEffect(() => {
9725
- if (!dockviewRef.current) {
9726
- return;
9727
- }
9728
- dockviewRef.current.updateOptions({
9729
- frameworkComponents: props.components,
9730
- });
9731
- }, [props.components]);
9732
- React.useEffect(() => {
9733
- if (!dockviewRef.current) {
9734
- return;
9735
- }
9736
- dockviewRef.current.updateOptions({
9737
- floatingGroupBounds: props.floatingGroupBounds,
9738
- });
9739
- }, [props.floatingGroupBounds]);
9740
- React.useEffect(() => {
9741
- if (!dockviewRef.current) {
9742
- return;
9743
- }
9744
- dockviewRef.current.updateOptions({
9745
- watermarkFrameworkComponent: props.watermarkComponent,
9746
- });
9747
- }, [props.watermarkComponent]);
9748
- React.useEffect(() => {
9749
- if (!dockviewRef.current) {
9750
- return;
9751
- }
9752
- dockviewRef.current.updateOptions({
9753
- showDndOverlay: props.showDndOverlay,
9754
- });
9755
9750
  }, [props.showDndOverlay]);
9756
9751
  React.useEffect(() => {
9757
9752
  if (!dockviewRef.current) {
9758
- return;
9753
+ return () => {
9754
+ // noop
9755
+ };
9759
9756
  }
9760
- dockviewRef.current.updateOptions({
9761
- frameworkTabComponents: props.tabComponents,
9757
+ const disposable = dockviewRef.current.onWillDrop((event) => {
9758
+ if (props.onWillDrop) {
9759
+ props.onWillDrop(event);
9760
+ }
9762
9761
  });
9763
- }, [props.tabComponents]);
9762
+ return () => {
9763
+ disposable.dispose();
9764
+ };
9765
+ }, [props.onWillDrop]);
9764
9766
  React.useEffect(() => {
9765
9767
  if (!dockviewRef.current) {
9766
9768
  return;
9767
9769
  }
9768
9770
  dockviewRef.current.updateOptions({
9769
- disableFloatingGroups: props.disableFloatingGroups,
9771
+ createComponent: (options) => {
9772
+ return new ReactPanelContentPart(options.id, props.components[options.name], {
9773
+ addPortal,
9774
+ });
9775
+ },
9770
9776
  });
9771
- }, [props.disableFloatingGroups]);
9777
+ }, [props.components]);
9772
9778
  React.useEffect(() => {
9773
9779
  var _a;
9774
9780
  if (!dockviewRef.current) {
@@ -9783,39 +9789,49 @@ const DockviewReact = React.forwardRef((props, ref) => {
9783
9789
  defaultTabComponent: props.defaultTabComponent
9784
9790
  ? DEFAULT_REACT_TAB
9785
9791
  : undefined,
9786
- frameworkTabComponents,
9792
+ createTabComponent(options) {
9793
+ return new ReactPanelHeaderPart(options.id, frameworkTabComponents[options.name], {
9794
+ addPortal,
9795
+ });
9796
+ },
9787
9797
  });
9788
- }, [props.defaultTabComponent]);
9798
+ }, [props.tabComponents, props.defaultTabComponent]);
9789
9799
  React.useEffect(() => {
9790
9800
  if (!dockviewRef.current) {
9791
9801
  return;
9792
9802
  }
9793
9803
  dockviewRef.current.updateOptions({
9794
- createRightHeaderActionsElement: createGroupControlElement(props.rightHeaderActionsComponent, { addPortal }),
9804
+ createWatermarkComponent: props.watermarkComponent
9805
+ ? () => {
9806
+ return new ReactWatermarkPart('watermark', props.watermarkComponent, {
9807
+ addPortal,
9808
+ });
9809
+ }
9810
+ : undefined,
9795
9811
  });
9796
- }, [props.rightHeaderActionsComponent]);
9812
+ }, [props.watermarkComponent]);
9797
9813
  React.useEffect(() => {
9798
9814
  if (!dockviewRef.current) {
9799
9815
  return;
9800
9816
  }
9801
9817
  dockviewRef.current.updateOptions({
9802
- createLeftHeaderActionsElement: createGroupControlElement(props.leftHeaderActionsComponent, { addPortal }),
9818
+ createRightHeaderActionComponent: createGroupControlElement(props.rightHeaderActionsComponent, { addPortal }),
9803
9819
  });
9804
- }, [props.leftHeaderActionsComponent]);
9820
+ }, [props.rightHeaderActionsComponent]);
9805
9821
  React.useEffect(() => {
9806
9822
  if (!dockviewRef.current) {
9807
9823
  return;
9808
9824
  }
9809
9825
  dockviewRef.current.updateOptions({
9810
- rootOverlayModel: props.rootOverlayModel,
9826
+ createLeftHeaderActionComponent: createGroupControlElement(props.leftHeaderActionsComponent, { addPortal }),
9811
9827
  });
9812
- }, [props.rootOverlayModel]);
9828
+ }, [props.leftHeaderActionsComponent]);
9813
9829
  React.useEffect(() => {
9814
9830
  if (!dockviewRef.current) {
9815
9831
  return;
9816
9832
  }
9817
9833
  dockviewRef.current.updateOptions({
9818
- createPrefixHeaderActionsElement: createGroupControlElement(props.prefixHeaderActionsComponent, { addPortal }),
9834
+ createPrefixHeaderActionComponent: createGroupControlElement(props.prefixHeaderActionsComponent, { addPortal }),
9819
9835
  });
9820
9836
  }, [props.prefixHeaderActionsComponent]);
9821
9837
  return (React.createElement("div", { className: props.className, style: { height: '100%', width: '100%' }, ref: domRef }, portals));
@@ -10140,5 +10156,5 @@ const PaneviewReact = React.forwardRef((props, ref) => {
10140
10156
  });
10141
10157
  PaneviewReact.displayName = 'PaneviewComponent';
10142
10158
 
10143
- export { BaseGrid, ContentContainer, DefaultDockviewDeserialzier, DefaultTab, DockviewApi, DockviewComponent, CompositeDisposable as DockviewCompositeDisposable, DockviewDefaultTab, DockviewDidDropEvent, Emitter as DockviewEmitter, Event as DockviewEvent, DockviewGroupPanel, DockviewGroupPanelModel, MutableDisposable as DockviewMutableDisposable, DockviewPanel, DockviewReact, DockviewWillDropEvent, DraggablePaneviewPanel, Gridview, GridviewApi, GridviewComponent, GridviewPanel, GridviewReact, LayoutPriority, LocalSelectionTransfer, Orientation, PaneFramework, PaneTransfer, PanelTransfer, Paneview, PaneviewApi, PaneviewComponent, PaneviewPanel, PaneviewReact, ReactPart, ReactPartContext, SashState, Sizing, Splitview, SplitviewApi, SplitviewComponent, SplitviewPanel, SplitviewReact, Tab, WillShowOverlayLocationEvent, createComponent, directionToPosition, getDirectionOrientation, getGridLocation, getLocationOrientation, getPaneData, getPanelData, getRelativeLocation, indexInParent, isGridBranchNode, isGroupOptionsWithGroup, isGroupOptionsWithPanel, isPanelOptionsWithGroup, isPanelOptionsWithPanel, isReactComponent, orthogonal, positionToDirection, toTarget, usePortalsLifecycle };
10159
+ export { BaseGrid, ContentContainer, DefaultDockviewDeserialzier, DefaultTab, DockviewApi, DockviewComponent, CompositeDisposable as DockviewCompositeDisposable, DockviewDefaultTab, DockviewDidDropEvent, Emitter as DockviewEmitter, Event as DockviewEvent, DockviewGroupPanel, DockviewGroupPanelModel, MutableDisposable as DockviewMutableDisposable, DockviewPanel, DockviewReact, DockviewUnhandledDragOverEvent, DockviewWillDropEvent, DraggablePaneviewPanel, Gridview, GridviewApi, GridviewComponent, GridviewPanel, GridviewReact, LayoutPriority, LocalSelectionTransfer, Orientation, PROPERTY_KEYS, PaneFramework, PaneTransfer, PanelTransfer, Paneview, PaneviewApi, PaneviewComponent, PaneviewPanel, PaneviewReact, ReactPart, ReactPartContext, SashState, Sizing, Splitview, SplitviewApi, SplitviewComponent, SplitviewPanel, SplitviewReact, Tab, WillShowOverlayLocationEvent, createComponent, directionToPosition, getDirectionOrientation, getGridLocation, getLocationOrientation, getPaneData, getPanelData, getRelativeLocation, indexInParent, isGridBranchNode, isGroupOptionsWithGroup, isGroupOptionsWithPanel, isPanelOptionsWithGroup, isPanelOptionsWithPanel, isReactComponent, orthogonal, positionToDirection, toTarget, usePortalsLifecycle };
10144
10160
  //# sourceMappingURL=dockview.esm.js.map