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