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
  */
@@ -2442,6 +2442,261 @@
2442
2442
  }
2443
2443
  }
2444
2444
 
2445
+ class Resizable extends CompositeDisposable {
2446
+ get element() {
2447
+ return this._element;
2448
+ }
2449
+ get disableResizing() {
2450
+ return this._disableResizing;
2451
+ }
2452
+ set disableResizing(value) {
2453
+ this._disableResizing = value;
2454
+ }
2455
+ constructor(parentElement, disableResizing = false) {
2456
+ super();
2457
+ this._disableResizing = disableResizing;
2458
+ this._element = parentElement;
2459
+ this.addDisposables(watchElementResize(this._element, (entry) => {
2460
+ if (this.isDisposed) {
2461
+ /**
2462
+ * resize is delayed through requestAnimationFrame so there is a small chance
2463
+ * the component has already been disposed of
2464
+ */
2465
+ return;
2466
+ }
2467
+ if (this.disableResizing) {
2468
+ return;
2469
+ }
2470
+ if (!this._element.offsetParent) {
2471
+ /**
2472
+ * offsetParent === null is equivalent to display: none being set on the element or one
2473
+ * of it's parents. In the display: none case the size will become (0, 0) which we do
2474
+ * not want to propagate.
2475
+ *
2476
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetParent
2477
+ *
2478
+ * You could use checkVisibility() but at the time of writing it's not supported across
2479
+ * all Browsers
2480
+ *
2481
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility
2482
+ */
2483
+ return;
2484
+ }
2485
+ if (!isInDocument(this._element)) {
2486
+ /**
2487
+ * since the event is dispatched through requestAnimationFrame there is a small chance
2488
+ * the component is no longer attached to the DOM, if that is the case the dimensions
2489
+ * are mostly likely all zero and meaningless. we should skip this case.
2490
+ */
2491
+ return;
2492
+ }
2493
+ const { width, height } = entry.contentRect;
2494
+ this.layout(width, height);
2495
+ }));
2496
+ }
2497
+ }
2498
+
2499
+ const nextLayoutId$1 = sequentialNumberGenerator();
2500
+ function toTarget(direction) {
2501
+ switch (direction) {
2502
+ case 'left':
2503
+ return 'left';
2504
+ case 'right':
2505
+ return 'right';
2506
+ case 'above':
2507
+ return 'top';
2508
+ case 'below':
2509
+ return 'bottom';
2510
+ case 'within':
2511
+ default:
2512
+ return 'center';
2513
+ }
2514
+ }
2515
+ class BaseGrid extends Resizable {
2516
+ get id() {
2517
+ return this._id;
2518
+ }
2519
+ get size() {
2520
+ return this._groups.size;
2521
+ }
2522
+ get groups() {
2523
+ return Array.from(this._groups.values()).map((_) => _.value);
2524
+ }
2525
+ get width() {
2526
+ return this.gridview.width;
2527
+ }
2528
+ get height() {
2529
+ return this.gridview.height;
2530
+ }
2531
+ get minimumHeight() {
2532
+ return this.gridview.minimumHeight;
2533
+ }
2534
+ get maximumHeight() {
2535
+ return this.gridview.maximumHeight;
2536
+ }
2537
+ get minimumWidth() {
2538
+ return this.gridview.minimumWidth;
2539
+ }
2540
+ get maximumWidth() {
2541
+ return this.gridview.maximumWidth;
2542
+ }
2543
+ get activeGroup() {
2544
+ return this._activeGroup;
2545
+ }
2546
+ get locked() {
2547
+ return this.gridview.locked;
2548
+ }
2549
+ set locked(value) {
2550
+ this.gridview.locked = value;
2551
+ }
2552
+ constructor(options) {
2553
+ super(document.createElement('div'), options.disableAutoResizing);
2554
+ this._id = nextLayoutId$1.next();
2555
+ this._groups = new Map();
2556
+ this._onDidLayoutChange = new Emitter();
2557
+ this.onDidLayoutChange = this._onDidLayoutChange.event;
2558
+ this._onDidRemove = new Emitter();
2559
+ this.onDidRemove = this._onDidRemove.event;
2560
+ this._onDidAdd = new Emitter();
2561
+ this.onDidAdd = this._onDidAdd.event;
2562
+ this._onDidActiveChange = new Emitter();
2563
+ this.onDidActiveChange = this._onDidActiveChange.event;
2564
+ this._bufferOnDidLayoutChange = new TickDelayedEvent();
2565
+ this.element.style.height = '100%';
2566
+ this.element.style.width = '100%';
2567
+ options.parentElement.appendChild(this.element);
2568
+ this.gridview = new Gridview(!!options.proportionalLayout, options.styles, options.orientation);
2569
+ this.gridview.locked = !!options.locked;
2570
+ this.element.appendChild(this.gridview.element);
2571
+ this.layout(0, 0, true); // set some elements height/widths
2572
+ this.addDisposables(Disposable.from(() => {
2573
+ var _a;
2574
+ (_a = this.element.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(this.element);
2575
+ }), this.gridview.onDidChange(() => {
2576
+ this._bufferOnDidLayoutChange.fire();
2577
+ }), exports.DockviewEvent.any(this.onDidAdd, this.onDidRemove, this.onDidActiveChange)(() => {
2578
+ this._bufferOnDidLayoutChange.fire();
2579
+ }), this._bufferOnDidLayoutChange.onEvent(() => {
2580
+ this._onDidLayoutChange.fire();
2581
+ }), this._bufferOnDidLayoutChange);
2582
+ }
2583
+ setVisible(panel, visible) {
2584
+ this.gridview.setViewVisible(getGridLocation(panel.element), visible);
2585
+ this._onDidLayoutChange.fire();
2586
+ }
2587
+ isVisible(panel) {
2588
+ return this.gridview.isViewVisible(getGridLocation(panel.element));
2589
+ }
2590
+ maximizeGroup(panel) {
2591
+ this.gridview.maximizeView(panel);
2592
+ this.doSetGroupActive(panel);
2593
+ }
2594
+ isMaximizedGroup(panel) {
2595
+ return this.gridview.maximizedView() === panel;
2596
+ }
2597
+ exitMaximizedGroup() {
2598
+ this.gridview.exitMaximizedView();
2599
+ }
2600
+ hasMaximizedGroup() {
2601
+ return this.gridview.hasMaximizedView();
2602
+ }
2603
+ get onDidMaximizedGroupChange() {
2604
+ return this.gridview.onDidMaximizedNodeChange;
2605
+ }
2606
+ doAddGroup(group, location = [0], size) {
2607
+ this.gridview.addView(group, size !== null && size !== void 0 ? size : exports.Sizing.Distribute, location);
2608
+ this._onDidAdd.fire(group);
2609
+ }
2610
+ doRemoveGroup(group, options) {
2611
+ if (!this._groups.has(group.id)) {
2612
+ throw new Error('invalid operation');
2613
+ }
2614
+ const item = this._groups.get(group.id);
2615
+ const view = this.gridview.remove(group, exports.Sizing.Distribute);
2616
+ if (item && !(options === null || options === void 0 ? void 0 : options.skipDispose)) {
2617
+ item.disposable.dispose();
2618
+ item.value.dispose();
2619
+ this._groups.delete(group.id);
2620
+ this._onDidRemove.fire(group);
2621
+ }
2622
+ if (!(options === null || options === void 0 ? void 0 : options.skipActive) && this._activeGroup === group) {
2623
+ const groups = Array.from(this._groups.values());
2624
+ this.doSetGroupActive(groups.length > 0 ? groups[0].value : undefined);
2625
+ }
2626
+ return view;
2627
+ }
2628
+ getPanel(id) {
2629
+ var _a;
2630
+ return (_a = this._groups.get(id)) === null || _a === void 0 ? void 0 : _a.value;
2631
+ }
2632
+ doSetGroupActive(group) {
2633
+ if (this._activeGroup === group) {
2634
+ return;
2635
+ }
2636
+ if (this._activeGroup) {
2637
+ this._activeGroup.setActive(false);
2638
+ }
2639
+ if (group) {
2640
+ group.setActive(true);
2641
+ }
2642
+ this._activeGroup = group;
2643
+ this._onDidActiveChange.fire(group);
2644
+ }
2645
+ removeGroup(group) {
2646
+ this.doRemoveGroup(group);
2647
+ }
2648
+ moveToNext(options) {
2649
+ var _a;
2650
+ if (!options) {
2651
+ options = {};
2652
+ }
2653
+ if (!options.group) {
2654
+ if (!this.activeGroup) {
2655
+ return;
2656
+ }
2657
+ options.group = this.activeGroup;
2658
+ }
2659
+ const location = getGridLocation(options.group.element);
2660
+ const next = (_a = this.gridview.next(location)) === null || _a === void 0 ? void 0 : _a.view;
2661
+ this.doSetGroupActive(next);
2662
+ }
2663
+ moveToPrevious(options) {
2664
+ var _a;
2665
+ if (!options) {
2666
+ options = {};
2667
+ }
2668
+ if (!options.group) {
2669
+ if (!this.activeGroup) {
2670
+ return;
2671
+ }
2672
+ options.group = this.activeGroup;
2673
+ }
2674
+ const location = getGridLocation(options.group.element);
2675
+ const next = (_a = this.gridview.previous(location)) === null || _a === void 0 ? void 0 : _a.view;
2676
+ this.doSetGroupActive(next);
2677
+ }
2678
+ layout(width, height, forceResize) {
2679
+ const different = forceResize !== null && forceResize !== void 0 ? forceResize : (width !== this.width || height !== this.height);
2680
+ if (!different) {
2681
+ return;
2682
+ }
2683
+ this.gridview.element.style.height = `${height}px`;
2684
+ this.gridview.element.style.width = `${width}px`;
2685
+ this.gridview.layout(width, height);
2686
+ }
2687
+ dispose() {
2688
+ this._onDidActiveChange.dispose();
2689
+ this._onDidAdd.dispose();
2690
+ this._onDidRemove.dispose();
2691
+ this._onDidLayoutChange.dispose();
2692
+ for (const group of this.groups) {
2693
+ group.dispose();
2694
+ }
2695
+ this.gridview.dispose();
2696
+ super.dispose();
2697
+ }
2698
+ }
2699
+
2445
2700
  class SplitviewApi {
2446
2701
  /**
2447
2702
  * The minimum size the component can reach where size is measured in the direction of orientation provided.
@@ -2984,6 +3239,9 @@
2984
3239
  get onWillDragPanel() {
2985
3240
  return this.component.onWillDragPanel;
2986
3241
  }
3242
+ get onUnhandledDragOverEvent() {
3243
+ return this.component.onUnhandledDragOverEvent;
3244
+ }
2987
3245
  /**
2988
3246
  * All panel objects.
2989
3247
  */
@@ -3121,6 +3379,67 @@
3121
3379
  }
3122
3380
  }
3123
3381
 
3382
+ class DragHandler extends CompositeDisposable {
3383
+ constructor(el) {
3384
+ super();
3385
+ this.el = el;
3386
+ this.dataDisposable = new MutableDisposable();
3387
+ this.pointerEventsDisposable = new MutableDisposable();
3388
+ this._onDragStart = new Emitter();
3389
+ this.onDragStart = this._onDragStart.event;
3390
+ this.addDisposables(this._onDragStart, this.dataDisposable, this.pointerEventsDisposable);
3391
+ this.configure();
3392
+ }
3393
+ isCancelled(_event) {
3394
+ return false;
3395
+ }
3396
+ configure() {
3397
+ this.addDisposables(this._onDragStart, addDisposableListener(this.el, 'dragstart', (event) => {
3398
+ if (event.defaultPrevented || this.isCancelled(event)) {
3399
+ event.preventDefault();
3400
+ return;
3401
+ }
3402
+ const iframes = [
3403
+ ...getElementsByTagName('iframe'),
3404
+ ...getElementsByTagName('webview'),
3405
+ ];
3406
+ this.pointerEventsDisposable.value = {
3407
+ dispose: () => {
3408
+ for (const iframe of iframes) {
3409
+ iframe.style.pointerEvents = 'auto';
3410
+ }
3411
+ },
3412
+ };
3413
+ for (const iframe of iframes) {
3414
+ iframe.style.pointerEvents = 'none';
3415
+ }
3416
+ this.el.classList.add('dv-dragged');
3417
+ setTimeout(() => this.el.classList.remove('dv-dragged'), 0);
3418
+ this.dataDisposable.value = this.getData(event);
3419
+ this._onDragStart.fire(event);
3420
+ if (event.dataTransfer) {
3421
+ event.dataTransfer.effectAllowed = 'move';
3422
+ const hasData = event.dataTransfer.items.length > 0;
3423
+ if (!hasData) {
3424
+ /**
3425
+ * Although this is not used by dockview many third party dnd libraries will check
3426
+ * dataTransfer.types to determine valid drag events.
3427
+ *
3428
+ * For example: in react-dnd if dataTransfer.types is not set then the dragStart event will be cancelled
3429
+ * through .preventDefault(). Since this is applied globally to all drag events this would break dockviews
3430
+ * dnd logic. You can see the code at
3431
+ * https://github.com/react-dnd/react-dnd/blob/main/packages/backend-html5/src/HTML5BackendImpl.ts#L542
3432
+ */
3433
+ event.dataTransfer.setData('text/plain', '__dockview_internal_drag_event__');
3434
+ }
3435
+ }
3436
+ }), addDisposableListener(this.el, 'dragend', () => {
3437
+ this.pointerEventsDisposable.dispose();
3438
+ this.dataDisposable.dispose();
3439
+ }));
3440
+ }
3441
+ }
3442
+
3124
3443
  class DragAndDropObserver extends CompositeDisposable {
3125
3444
  constructor(element, callbacks) {
3126
3445
  super();
@@ -3265,6 +3584,10 @@
3265
3584
  this.removeDropTarget();
3266
3585
  return;
3267
3586
  }
3587
+ if (!this.options.canDisplayOverlay(e, quadrant)) {
3588
+ this.removeDropTarget();
3589
+ return;
3590
+ }
3268
3591
  const willShowOverlayEvent = new WillShowOverlayEvent({
3269
3592
  nativeEvent: e,
3270
3593
  position: quadrant,
@@ -3278,16 +3601,6 @@
3278
3601
  this.removeDropTarget();
3279
3602
  return;
3280
3603
  }
3281
- if (typeof this.options.canDisplayOverlay === 'boolean') {
3282
- if (!this.options.canDisplayOverlay) {
3283
- this.removeDropTarget();
3284
- return;
3285
- }
3286
- }
3287
- else if (!this.options.canDisplayOverlay(e, quadrant)) {
3288
- this.removeDropTarget();
3289
- return;
3290
- }
3291
3604
  this.markAsUsed(e);
3292
3605
  if (!this.targetElement) {
3293
3606
  this.targetElement = document.createElement('div');
@@ -3478,1997 +3791,1758 @@
3478
3791
  return 'center';
3479
3792
  }
3480
3793
 
3481
- class ContentContainer extends CompositeDisposable {
3482
- get element() {
3483
- return this._element;
3484
- }
3485
- constructor(accessor, group) {
3794
+ class WillFocusEvent extends DockviewEvent {
3795
+ constructor() {
3486
3796
  super();
3487
- this.accessor = accessor;
3488
- this.group = group;
3489
- this.disposable = new MutableDisposable();
3490
- this._onDidFocus = new Emitter();
3491
- this.onDidFocus = this._onDidFocus.event;
3492
- this._onDidBlur = new Emitter();
3493
- this.onDidBlur = this._onDidBlur.event;
3494
- this._element = document.createElement('div');
3495
- this._element.className = 'content-container';
3496
- this._element.tabIndex = -1;
3497
- this.addDisposables(this._onDidFocus, this._onDidBlur);
3498
- this.dropTarget = new Droptarget(this.element, {
3499
- acceptedTargetZones: ['top', 'bottom', 'left', 'right', 'center'],
3500
- canDisplayOverlay: (event, position) => {
3501
- if (this.group.locked === 'no-drop-target' ||
3502
- (this.group.locked && position === 'center')) {
3503
- return false;
3504
- }
3505
- const data = getPanelData();
3506
- if (!data &&
3507
- event.shiftKey &&
3508
- this.group.location.type !== 'floating') {
3509
- return false;
3510
- }
3511
- if (data && data.viewId === this.accessor.id) {
3512
- if (data.groupId === this.group.id) {
3513
- if (position === 'center') {
3514
- // don't allow to drop on self for center position
3515
- return false;
3516
- }
3517
- if (data.panelId === null) {
3518
- // don't allow group move to drop anywhere on self
3519
- return false;
3520
- }
3521
- }
3522
- const groupHasOnePanelAndIsActiveDragElement = this.group.panels.length === 1 &&
3523
- data.groupId === this.group.id;
3524
- return !groupHasOnePanelAndIsActiveDragElement;
3525
- }
3526
- return this.group.canDisplayOverlay(event, position, 'content');
3527
- },
3528
- });
3529
- this.addDisposables(this.dropTarget);
3530
3797
  }
3531
- show() {
3532
- this.element.style.display = '';
3798
+ }
3799
+ /**
3800
+ * A core api implementation that should be used across all panel-like objects
3801
+ */
3802
+ class PanelApiImpl extends CompositeDisposable {
3803
+ get isFocused() {
3804
+ return this._isFocused;
3533
3805
  }
3534
- hide() {
3535
- this.element.style.display = 'none';
3806
+ get isActive() {
3807
+ return this._isActive;
3536
3808
  }
3537
- renderPanel(panel, options = { asActive: true }) {
3538
- const doRender = options.asActive ||
3539
- (this.panel && this.group.isPanelActive(this.panel));
3540
- if (this.panel &&
3541
- this.panel.view.content.element.parentElement === this._element) {
3542
- /**
3543
- * If the currently attached panel is mounted directly to the content then remove it
3544
- */
3545
- this._element.removeChild(this.panel.view.content.element);
3546
- }
3547
- this.panel = panel;
3548
- let container;
3549
- switch (panel.api.renderer) {
3550
- case 'onlyWhenVisibile':
3551
- this.group.renderContainer.detatch(panel);
3552
- if (this.panel) {
3553
- if (doRender) {
3554
- this._element.appendChild(this.panel.view.content.element);
3555
- }
3556
- }
3557
- container = this._element;
3558
- break;
3559
- case 'always':
3560
- if (panel.view.content.element.parentElement === this._element) {
3561
- this._element.removeChild(panel.view.content.element);
3562
- }
3563
- container = this.group.renderContainer.attach({
3564
- panel,
3565
- referenceContainer: this,
3566
- });
3567
- break;
3568
- }
3569
- if (doRender) {
3570
- const _onDidFocus = panel.view.content.onDidFocus;
3571
- const _onDidBlur = panel.view.content.onDidBlur;
3572
- const focusTracker = trackFocus(container);
3573
- const disposable = new CompositeDisposable();
3574
- disposable.addDisposables(focusTracker, focusTracker.onDidFocus(() => this._onDidFocus.fire()), focusTracker.onDidBlur(() => this._onDidBlur.fire()));
3575
- if (_onDidFocus) {
3576
- disposable.addDisposables(_onDidFocus(() => this._onDidFocus.fire()));
3577
- }
3578
- if (_onDidBlur) {
3579
- disposable.addDisposables(_onDidBlur(() => this._onDidBlur.fire()));
3580
- }
3581
- this.disposable.value = disposable;
3582
- }
3809
+ get isVisible() {
3810
+ return this._isVisible;
3583
3811
  }
3584
- openPanel(panel) {
3585
- if (this.panel === panel) {
3586
- return;
3587
- }
3588
- this.renderPanel(panel);
3812
+ get width() {
3813
+ return this._width;
3589
3814
  }
3590
- layout(_width, _height) {
3591
- // noop
3815
+ get height() {
3816
+ return this._height;
3592
3817
  }
3593
- closePanel() {
3594
- var _a;
3595
- if (this.panel) {
3596
- if (this.panel.api.renderer === 'onlyWhenVisibile') {
3597
- (_a = this.panel.view.content.element.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(this.panel.view.content.element);
3598
- }
3599
- }
3600
- this.panel = undefined;
3818
+ constructor(id, component) {
3819
+ super();
3820
+ this.id = id;
3821
+ this.component = component;
3822
+ this._isFocused = false;
3823
+ this._isActive = false;
3824
+ this._isVisible = true;
3825
+ this._width = 0;
3826
+ this._height = 0;
3827
+ this._parameters = {};
3828
+ this.panelUpdatesDisposable = new MutableDisposable();
3829
+ this._onDidDimensionChange = new Emitter();
3830
+ this.onDidDimensionsChange = this._onDidDimensionChange.event;
3831
+ this._onDidChangeFocus = new Emitter();
3832
+ this.onDidFocusChange = this._onDidChangeFocus.event;
3833
+ //
3834
+ this._onWillFocus = new Emitter();
3835
+ this.onWillFocus = this._onWillFocus.event;
3836
+ //
3837
+ this._onDidVisibilityChange = new Emitter();
3838
+ this.onDidVisibilityChange = this._onDidVisibilityChange.event;
3839
+ this._onWillVisibilityChange = new Emitter();
3840
+ this.onWillVisibilityChange = this._onWillVisibilityChange.event;
3841
+ this._onDidActiveChange = new Emitter();
3842
+ this.onDidActiveChange = this._onDidActiveChange.event;
3843
+ this._onActiveChange = new Emitter();
3844
+ this.onActiveChange = this._onActiveChange.event;
3845
+ this._onDidParametersChange = new Emitter();
3846
+ this.onDidParametersChange = this._onDidParametersChange.event;
3847
+ this.addDisposables(this.onDidFocusChange((event) => {
3848
+ this._isFocused = event.isFocused;
3849
+ }), this.onDidActiveChange((event) => {
3850
+ this._isActive = event.isActive;
3851
+ }), this.onDidVisibilityChange((event) => {
3852
+ this._isVisible = event.isVisible;
3853
+ }), this.onDidDimensionsChange((event) => {
3854
+ this._width = event.width;
3855
+ this._height = event.height;
3856
+ }), this.panelUpdatesDisposable, this._onDidDimensionChange, this._onDidChangeFocus, this._onDidVisibilityChange, this._onDidActiveChange, this._onWillFocus, this._onActiveChange, this._onWillFocus, this._onWillVisibilityChange, this._onDidParametersChange);
3601
3857
  }
3602
- dispose() {
3603
- this.disposable.dispose();
3604
- super.dispose();
3858
+ getParameters() {
3859
+ return this._parameters;
3860
+ }
3861
+ initialize(panel) {
3862
+ this.panelUpdatesDisposable.value = this._onDidParametersChange.event((parameters) => {
3863
+ this._parameters = parameters;
3864
+ panel.update({
3865
+ params: parameters,
3866
+ });
3867
+ });
3868
+ }
3869
+ setVisible(isVisible) {
3870
+ this._onWillVisibilityChange.fire({ isVisible });
3871
+ }
3872
+ setActive() {
3873
+ this._onActiveChange.fire();
3874
+ }
3875
+ updateParameters(parameters) {
3876
+ this._onDidParametersChange.fire(parameters);
3605
3877
  }
3606
3878
  }
3607
3879
 
3608
- class DragHandler extends CompositeDisposable {
3609
- constructor(el) {
3610
- super();
3611
- this.el = el;
3612
- this.dataDisposable = new MutableDisposable();
3613
- this.pointerEventsDisposable = new MutableDisposable();
3614
- this._onDragStart = new Emitter();
3615
- this.onDragStart = this._onDragStart.event;
3616
- this.addDisposables(this._onDragStart, this.dataDisposable, this.pointerEventsDisposable);
3617
- this.configure();
3880
+ class SplitviewPanelApiImpl extends PanelApiImpl {
3881
+ //
3882
+ constructor(id, component) {
3883
+ super(id, component);
3884
+ this._onDidConstraintsChangeInternal = new Emitter();
3885
+ this.onDidConstraintsChangeInternal = this._onDidConstraintsChangeInternal.event;
3886
+ //
3887
+ this._onDidConstraintsChange = new Emitter({
3888
+ replay: true,
3889
+ });
3890
+ this.onDidConstraintsChange = this._onDidConstraintsChange.event;
3891
+ //
3892
+ this._onDidSizeChange = new Emitter();
3893
+ this.onDidSizeChange = this._onDidSizeChange.event;
3894
+ this.addDisposables(this._onDidConstraintsChangeInternal, this._onDidConstraintsChange, this._onDidSizeChange);
3618
3895
  }
3619
- isCancelled(_event) {
3620
- return false;
3896
+ setConstraints(value) {
3897
+ this._onDidConstraintsChangeInternal.fire(value);
3621
3898
  }
3622
- configure() {
3623
- this.addDisposables(this._onDragStart, addDisposableListener(this.el, 'dragstart', (event) => {
3624
- if (event.defaultPrevented || this.isCancelled(event)) {
3625
- event.preventDefault();
3626
- return;
3627
- }
3628
- const iframes = [
3629
- ...getElementsByTagName('iframe'),
3630
- ...getElementsByTagName('webview'),
3631
- ];
3632
- this.pointerEventsDisposable.value = {
3633
- dispose: () => {
3634
- for (const iframe of iframes) {
3635
- iframe.style.pointerEvents = 'auto';
3636
- }
3637
- },
3638
- };
3639
- for (const iframe of iframes) {
3640
- iframe.style.pointerEvents = 'none';
3641
- }
3642
- this.el.classList.add('dv-dragged');
3643
- setTimeout(() => this.el.classList.remove('dv-dragged'), 0);
3644
- this.dataDisposable.value = this.getData(event);
3645
- this._onDragStart.fire(event);
3646
- if (event.dataTransfer) {
3647
- event.dataTransfer.effectAllowed = 'move';
3648
- const hasData = event.dataTransfer.items.length > 0;
3649
- if (!hasData) {
3650
- /**
3651
- * Although this is not used by dockview many third party dnd libraries will check
3652
- * dataTransfer.types to determine valid drag events.
3653
- *
3654
- * For example: in react-dnd if dataTransfer.types is not set then the dragStart event will be cancelled
3655
- * through .preventDefault(). Since this is applied globally to all drag events this would break dockviews
3656
- * dnd logic. You can see the code at
3657
- * https://github.com/react-dnd/react-dnd/blob/main/packages/backend-html5/src/HTML5BackendImpl.ts#L542
3658
- */
3659
- event.dataTransfer.setData('text/plain', '__dockview_internal_drag_event__');
3660
- }
3661
- }
3662
- }), addDisposableListener(this.el, 'dragend', () => {
3663
- this.pointerEventsDisposable.dispose();
3664
- this.dataDisposable.dispose();
3665
- }));
3899
+ setSize(event) {
3900
+ this._onDidSizeChange.fire(event);
3666
3901
  }
3667
3902
  }
3668
3903
 
3669
- class TabDragHandler extends DragHandler {
3670
- constructor(element, accessor, group, panel) {
3671
- super(element);
3672
- this.accessor = accessor;
3673
- this.group = group;
3674
- this.panel = panel;
3675
- this.panelTransfer = LocalSelectionTransfer.getInstance();
3904
+ class PaneviewPanelApiImpl extends SplitviewPanelApiImpl {
3905
+ set pane(pane) {
3906
+ this._pane = pane;
3676
3907
  }
3677
- getData(event) {
3678
- this.panelTransfer.setData([new PanelTransfer(this.accessor.id, this.group.id, this.panel.id)], PanelTransfer.prototype);
3679
- return {
3680
- dispose: () => {
3681
- this.panelTransfer.clearData(PanelTransfer.prototype);
3682
- },
3683
- };
3908
+ constructor(id, component) {
3909
+ super(id, component);
3910
+ this._onDidExpansionChange = new Emitter({
3911
+ replay: true,
3912
+ });
3913
+ this.onDidExpansionChange = this._onDidExpansionChange.event;
3914
+ this._onMouseEnter = new Emitter({});
3915
+ this.onMouseEnter = this._onMouseEnter.event;
3916
+ this._onMouseLeave = new Emitter({});
3917
+ this.onMouseLeave = this._onMouseLeave.event;
3918
+ this.addDisposables(this._onDidExpansionChange, this._onMouseEnter, this._onMouseLeave);
3919
+ }
3920
+ setExpanded(isExpanded) {
3921
+ var _a;
3922
+ (_a = this._pane) === null || _a === void 0 ? void 0 : _a.setExpanded(isExpanded);
3923
+ }
3924
+ get isExpanded() {
3925
+ var _a;
3926
+ return !!((_a = this._pane) === null || _a === void 0 ? void 0 : _a.isExpanded());
3684
3927
  }
3685
3928
  }
3686
- class Tab extends CompositeDisposable {
3929
+
3930
+ class BasePanelView extends CompositeDisposable {
3687
3931
  get element() {
3688
3932
  return this._element;
3689
3933
  }
3690
- constructor(panel, accessor, group) {
3934
+ get width() {
3935
+ return this._width;
3936
+ }
3937
+ get height() {
3938
+ return this._height;
3939
+ }
3940
+ get params() {
3941
+ var _a;
3942
+ return (_a = this._params) === null || _a === void 0 ? void 0 : _a.params;
3943
+ }
3944
+ constructor(id, component, api) {
3691
3945
  super();
3692
- this.panel = panel;
3693
- this.accessor = accessor;
3694
- this.group = group;
3695
- this.content = undefined;
3696
- this._onChanged = new Emitter();
3697
- this.onChanged = this._onChanged.event;
3698
- this._onDropped = new Emitter();
3699
- this.onDrop = this._onDropped.event;
3700
- this._onDragStart = new Emitter();
3701
- this.onDragStart = this._onDragStart.event;
3946
+ this.id = id;
3947
+ this.component = component;
3948
+ this.api = api;
3949
+ this._height = 0;
3950
+ this._width = 0;
3702
3951
  this._element = document.createElement('div');
3703
- this._element.className = 'tab';
3704
- this._element.tabIndex = 0;
3705
- this._element.draggable = true;
3706
- toggleClass(this.element, 'inactive-tab', true);
3707
- const dragHandler = new TabDragHandler(this._element, this.accessor, this.group, this.panel);
3708
- this.dropTarget = new Droptarget(this._element, {
3709
- acceptedTargetZones: ['center'],
3710
- canDisplayOverlay: (event, position) => {
3711
- if (this.group.locked) {
3712
- return false;
3713
- }
3714
- const data = getPanelData();
3715
- if (data && this.accessor.id === data.viewId) {
3716
- if (data.panelId === null &&
3717
- data.groupId === this.group.id) {
3718
- // don't allow group move to drop on self
3719
- return false;
3720
- }
3721
- return this.panel.id !== data.panelId;
3722
- }
3723
- return this.group.model.canDisplayOverlay(event, position, 'tab');
3724
- },
3725
- });
3726
- this.onWillShowOverlay = this.dropTarget.onWillShowOverlay;
3727
- this.addDisposables(this._onChanged, this._onDropped, this._onDragStart, dragHandler.onDragStart((event) => {
3728
- this._onDragStart.fire(event);
3729
- }), dragHandler, addDisposableListener(this._element, 'mousedown', (event) => {
3730
- if (event.defaultPrevented) {
3731
- return;
3952
+ this._element.tabIndex = -1;
3953
+ this._element.style.outline = 'none';
3954
+ this._element.style.height = '100%';
3955
+ this._element.style.width = '100%';
3956
+ this._element.style.overflow = 'hidden';
3957
+ const focusTracker = trackFocus(this._element);
3958
+ this.addDisposables(this.api, focusTracker.onDidFocus(() => {
3959
+ this.api._onDidChangeFocus.fire({ isFocused: true });
3960
+ }), focusTracker.onDidBlur(() => {
3961
+ this.api._onDidChangeFocus.fire({ isFocused: false });
3962
+ }), focusTracker);
3963
+ }
3964
+ focus() {
3965
+ const event = new WillFocusEvent();
3966
+ this.api._onWillFocus.fire(event);
3967
+ if (event.defaultPrevented) {
3968
+ return;
3969
+ }
3970
+ this._element.focus();
3971
+ }
3972
+ layout(width, height) {
3973
+ this._width = width;
3974
+ this._height = height;
3975
+ this.api._onDidDimensionChange.fire({ width, height });
3976
+ if (this.part) {
3977
+ if (this._params) {
3978
+ this.part.update(this._params.params);
3732
3979
  }
3733
- this._onChanged.fire(event);
3734
- }), this.dropTarget.onDrop((event) => {
3735
- this._onDropped.fire(event);
3736
- }), this.dropTarget);
3980
+ }
3737
3981
  }
3738
- setActive(isActive) {
3739
- toggleClass(this.element, 'active-tab', isActive);
3740
- toggleClass(this.element, 'inactive-tab', !isActive);
3982
+ init(parameters) {
3983
+ this._params = parameters;
3984
+ this.part = this.getComponent();
3741
3985
  }
3742
- setContent(part) {
3743
- if (this.content) {
3744
- this._element.removeChild(this.content.element);
3986
+ update(event) {
3987
+ var _a, _b;
3988
+ // merge the new parameters with the existing parameters
3989
+ 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) });
3990
+ /**
3991
+ * delete new keys that have a value of undefined,
3992
+ * allow values of null
3993
+ */
3994
+ for (const key of Object.keys(event.params)) {
3995
+ if (event.params[key] === undefined) {
3996
+ delete this._params.params[key];
3997
+ }
3745
3998
  }
3746
- this.content = part;
3747
- this._element.appendChild(this.content.element);
3999
+ // update the view with the updated props
4000
+ (_b = this.part) === null || _b === void 0 ? void 0 : _b.update({ params: this._params.params });
4001
+ }
4002
+ toJSON() {
4003
+ var _a, _b;
4004
+ const params = (_b = (_a = this._params) === null || _a === void 0 ? void 0 : _a.params) !== null && _b !== void 0 ? _b : {};
4005
+ return {
4006
+ id: this.id,
4007
+ component: this.component,
4008
+ params: Object.keys(params).length > 0 ? params : undefined,
4009
+ };
3748
4010
  }
3749
4011
  dispose() {
4012
+ var _a;
4013
+ this.api.dispose();
4014
+ (_a = this.part) === null || _a === void 0 ? void 0 : _a.dispose();
3750
4015
  super.dispose();
3751
4016
  }
3752
4017
  }
3753
4018
 
3754
- function addGhostImage(dataTransfer, ghostElement) {
3755
- // class dockview provides to force ghost image to be drawn on a different layer and prevent weird rendering issues
3756
- addClasses(ghostElement, 'dv-dragged');
3757
- document.body.appendChild(ghostElement);
3758
- dataTransfer.setDragImage(ghostElement, 0, 0);
3759
- setTimeout(() => {
3760
- removeClasses(ghostElement, 'dv-dragged');
3761
- ghostElement.remove();
3762
- }, 0);
3763
- }
3764
-
3765
- class GroupDragHandler extends DragHandler {
3766
- constructor(element, accessor, group) {
3767
- super(element);
3768
- this.accessor = accessor;
3769
- this.group = group;
3770
- this.panelTransfer = LocalSelectionTransfer.getInstance();
3771
- this.addDisposables(addDisposableListener(element, 'mousedown', (e) => {
3772
- if (e.shiftKey) {
3773
- /**
3774
- * You cannot call e.preventDefault() because that will prevent drag events from firing
3775
- * but we also need to stop any group overlay drag events from occuring
3776
- * Use a custom event marker that can be checked by the overlay drag events
3777
- */
3778
- quasiPreventDefault(e);
3779
- }
3780
- }, true));
4019
+ class PaneviewPanel extends BasePanelView {
4020
+ set orientation(value) {
4021
+ this._orientation = value;
3781
4022
  }
3782
- isCancelled(_event) {
3783
- if (this.group.api.location.type === 'floating' && !_event.shiftKey) {
3784
- return true;
3785
- }
3786
- return false;
4023
+ get orientation() {
4024
+ return this._orientation;
3787
4025
  }
3788
- getData(dragEvent) {
3789
- const dataTransfer = dragEvent.dataTransfer;
3790
- this.panelTransfer.setData([new PanelTransfer(this.accessor.id, this.group.id, null)], PanelTransfer.prototype);
3791
- const style = window.getComputedStyle(this.el);
3792
- const bgColor = style.getPropertyValue('--dv-activegroup-visiblepanel-tab-background-color');
3793
- const color = style.getPropertyValue('--dv-activegroup-visiblepanel-tab-color');
3794
- if (dataTransfer) {
3795
- const ghostElement = document.createElement('div');
3796
- ghostElement.style.backgroundColor = bgColor;
3797
- ghostElement.style.color = color;
3798
- ghostElement.style.padding = '2px 8px';
3799
- ghostElement.style.height = '24px';
3800
- ghostElement.style.fontSize = '11px';
3801
- ghostElement.style.lineHeight = '20px';
3802
- ghostElement.style.borderRadius = '12px';
3803
- ghostElement.style.position = 'absolute';
3804
- ghostElement.textContent = `Multiple Panels (${this.group.size})`;
3805
- addGhostImage(dataTransfer, ghostElement);
3806
- }
3807
- return {
3808
- dispose: () => {
3809
- this.panelTransfer.clearData(PanelTransfer.prototype);
3810
- },
3811
- };
4026
+ get minimumSize() {
4027
+ const headerSize = this.headerSize;
4028
+ const expanded = this.isExpanded();
4029
+ const minimumBodySize = expanded ? this._minimumBodySize : 0;
4030
+ return headerSize + minimumBodySize;
3812
4031
  }
3813
- }
3814
-
3815
- class VoidContainer extends CompositeDisposable {
3816
- get element() {
3817
- return this._element;
4032
+ get maximumSize() {
4033
+ const headerSize = this.headerSize;
4034
+ const expanded = this.isExpanded();
4035
+ const maximumBodySize = expanded ? this._maximumBodySize : 0;
4036
+ return headerSize + maximumBodySize;
3818
4037
  }
3819
- constructor(accessor, group) {
3820
- super();
3821
- this.accessor = accessor;
3822
- this.group = group;
3823
- this._onDrop = new Emitter();
3824
- this.onDrop = this._onDrop.event;
3825
- this._onDragStart = new Emitter();
3826
- this.onDragStart = this._onDragStart.event;
3827
- this._element = document.createElement('div');
3828
- this._element.className = 'void-container';
3829
- this._element.tabIndex = 0;
3830
- this._element.draggable = true;
3831
- this.addDisposables(this._onDrop, this._onDragStart, addDisposableListener(this._element, 'click', () => {
3832
- this.accessor.doSetGroupActive(this.group);
3833
- }));
3834
- const handler = new GroupDragHandler(this._element, accessor, group);
3835
- this.dropTraget = new Droptarget(this._element, {
3836
- acceptedTargetZones: ['center'],
3837
- canDisplayOverlay: (event, position) => {
3838
- var _a;
3839
- const data = getPanelData();
3840
- if (data && this.accessor.id === data.viewId) {
3841
- if (data.panelId === null &&
3842
- data.groupId === this.group.id) {
3843
- // don't allow group move to drop on self
3844
- return false;
3845
- }
3846
- // don't show the overlay if the tab being dragged is the last panel of this group
3847
- return ((_a = last(this.group.panels)) === null || _a === void 0 ? void 0 : _a.id) !== data.panelId;
3848
- }
3849
- return group.model.canDisplayOverlay(event, position, 'header_space');
3850
- },
3851
- });
3852
- this.onWillShowOverlay = this.dropTraget.onWillShowOverlay;
3853
- this.addDisposables(handler, handler.onDragStart((event) => {
3854
- this._onDragStart.fire(event);
3855
- }), this.dropTraget.onDrop((event) => {
3856
- this._onDrop.fire(event);
3857
- }), this.dropTraget);
4038
+ get size() {
4039
+ return this._size;
3858
4040
  }
3859
- }
3860
-
3861
- class TabsContainer extends CompositeDisposable {
3862
- get panels() {
3863
- return this.tabs.map((_) => _.value.panel.id);
4041
+ get orthogonalSize() {
4042
+ return this._orthogonalSize;
3864
4043
  }
3865
- get size() {
3866
- return this.tabs.length;
4044
+ set orthogonalSize(size) {
4045
+ this._orthogonalSize = size;
3867
4046
  }
3868
- get hidden() {
3869
- return this._hidden;
4047
+ get minimumBodySize() {
4048
+ return this._minimumBodySize;
3870
4049
  }
3871
- set hidden(value) {
3872
- this._hidden = value;
3873
- this.element.style.display = value ? 'none' : '';
4050
+ set minimumBodySize(value) {
4051
+ this._minimumBodySize = typeof value === 'number' ? value : 0;
3874
4052
  }
3875
- show() {
3876
- if (!this.hidden) {
3877
- this.element.style.display = '';
3878
- }
4053
+ get maximumBodySize() {
4054
+ return this._maximumBodySize;
3879
4055
  }
3880
- hide() {
3881
- this._element.style.display = 'none';
4056
+ set maximumBodySize(value) {
4057
+ this._maximumBodySize =
4058
+ typeof value === 'number' ? value : Number.POSITIVE_INFINITY;
3882
4059
  }
3883
- setRightActionsElement(element) {
3884
- if (this.rightActions === element) {
3885
- return;
3886
- }
3887
- if (this.rightActions) {
3888
- this.rightActions.remove();
3889
- this.rightActions = undefined;
3890
- }
3891
- if (element) {
3892
- this.rightActionsContainer.appendChild(element);
3893
- this.rightActions = element;
3894
- }
4060
+ get headerVisible() {
4061
+ return this._headerVisible;
3895
4062
  }
3896
- setLeftActionsElement(element) {
3897
- if (this.leftActions === element) {
4063
+ set headerVisible(value) {
4064
+ this._headerVisible = value;
4065
+ this.header.style.display = value ? '' : 'none';
4066
+ }
4067
+ constructor(id, component, headerComponent, orientation, isExpanded, isHeaderVisible) {
4068
+ super(id, component, new PaneviewPanelApiImpl(id, component));
4069
+ this.headerComponent = headerComponent;
4070
+ this._onDidChangeExpansionState = new Emitter({ replay: true });
4071
+ this.onDidChangeExpansionState = this._onDidChangeExpansionState.event;
4072
+ this._onDidChange = new Emitter();
4073
+ this.onDidChange = this._onDidChange.event;
4074
+ this.headerSize = 22;
4075
+ this._orthogonalSize = 0;
4076
+ this._size = 0;
4077
+ this._minimumBodySize = 100;
4078
+ this._maximumBodySize = Number.POSITIVE_INFINITY;
4079
+ this._isExpanded = false;
4080
+ this.expandedSize = 0;
4081
+ this.api.pane = this; // TODO cannot use 'this' before 'super'
4082
+ this.api.initialize(this);
4083
+ this._isExpanded = isExpanded;
4084
+ this._headerVisible = isHeaderVisible;
4085
+ this._onDidChangeExpansionState.fire(this.isExpanded()); // initialize value
4086
+ this._orientation = orientation;
4087
+ this.element.classList.add('pane');
4088
+ this.addDisposables(this.api.onWillVisibilityChange((event) => {
4089
+ const { isVisible } = event;
4090
+ const { accessor } = this._params;
4091
+ accessor.setVisible(this, isVisible);
4092
+ }), this.api.onDidSizeChange((event) => {
4093
+ this._onDidChange.fire({ size: event.size });
4094
+ }), addDisposableListener(this.element, 'mouseenter', (ev) => {
4095
+ this.api._onMouseEnter.fire(ev);
4096
+ }), addDisposableListener(this.element, 'mouseleave', (ev) => {
4097
+ this.api._onMouseLeave.fire(ev);
4098
+ }));
4099
+ this.addDisposables(this._onDidChangeExpansionState, this.onDidChangeExpansionState((isPanelExpanded) => {
4100
+ this.api._onDidExpansionChange.fire({
4101
+ isExpanded: isPanelExpanded,
4102
+ });
4103
+ }), this.api.onDidFocusChange((e) => {
4104
+ if (!this.header) {
4105
+ return;
4106
+ }
4107
+ if (e.isFocused) {
4108
+ addClasses(this.header, 'focused');
4109
+ }
4110
+ else {
4111
+ removeClasses(this.header, 'focused');
4112
+ }
4113
+ }));
4114
+ this.renderOnce();
4115
+ }
4116
+ setVisible(isVisible) {
4117
+ this.api._onDidVisibilityChange.fire({ isVisible });
4118
+ }
4119
+ setActive(isActive) {
4120
+ this.api._onDidActiveChange.fire({ isActive });
4121
+ }
4122
+ isExpanded() {
4123
+ return this._isExpanded;
4124
+ }
4125
+ setExpanded(expanded) {
4126
+ if (this._isExpanded === expanded) {
3898
4127
  return;
3899
4128
  }
3900
- if (this.leftActions) {
3901
- this.leftActions.remove();
3902
- this.leftActions = undefined;
4129
+ this._isExpanded = expanded;
4130
+ if (expanded) {
4131
+ if (this.animationTimer) {
4132
+ clearTimeout(this.animationTimer);
4133
+ }
4134
+ if (this.body) {
4135
+ this.element.appendChild(this.body);
4136
+ }
3903
4137
  }
3904
- if (element) {
3905
- this.leftActionsContainer.appendChild(element);
3906
- this.leftActions = element;
4138
+ else {
4139
+ this.animationTimer = setTimeout(() => {
4140
+ var _a;
4141
+ (_a = this.body) === null || _a === void 0 ? void 0 : _a.remove();
4142
+ }, 200);
3907
4143
  }
4144
+ this._onDidChange.fire(expanded ? { size: this.width } : {});
4145
+ this._onDidChangeExpansionState.fire(expanded);
3908
4146
  }
3909
- setPrefixActionsElement(element) {
3910
- if (this.preActions === element) {
3911
- return;
4147
+ layout(size, orthogonalSize) {
4148
+ this._size = size;
4149
+ this._orthogonalSize = orthogonalSize;
4150
+ const [width, height] = this.orientation === exports.Orientation.HORIZONTAL
4151
+ ? [size, orthogonalSize]
4152
+ : [orthogonalSize, size];
4153
+ if (this.isExpanded()) {
4154
+ this.expandedSize = width;
3912
4155
  }
3913
- if (this.preActions) {
3914
- this.preActions.remove();
3915
- this.preActions = undefined;
4156
+ super.layout(width, height);
4157
+ }
4158
+ init(parameters) {
4159
+ var _a, _b;
4160
+ super.init(parameters);
4161
+ if (typeof parameters.minimumBodySize === 'number') {
4162
+ this.minimumBodySize = parameters.minimumBodySize;
3916
4163
  }
3917
- if (element) {
3918
- this.preActionsContainer.appendChild(element);
3919
- this.preActions = element;
4164
+ if (typeof parameters.maximumBodySize === 'number') {
4165
+ this.maximumBodySize = parameters.maximumBodySize;
3920
4166
  }
3921
- }
3922
- get element() {
3923
- return this._element;
3924
- }
3925
- isActive(tab) {
3926
- return (this.selectedIndex > -1 &&
3927
- this.tabs[this.selectedIndex].value === tab);
3928
- }
3929
- indexOf(id) {
3930
- return this.tabs.findIndex((tab) => tab.value.panel.id === id);
3931
- }
3932
- constructor(accessor, group) {
3933
- super();
3934
- this.accessor = accessor;
3935
- this.group = group;
3936
- this.tabs = [];
3937
- this.selectedIndex = -1;
3938
- this._hidden = false;
3939
- this._onDrop = new Emitter();
3940
- this.onDrop = this._onDrop.event;
3941
- this._onTabDragStart = new Emitter();
3942
- this.onTabDragStart = this._onTabDragStart.event;
3943
- this._onGroupDragStart = new Emitter();
3944
- this.onGroupDragStart = this._onGroupDragStart.event;
3945
- this._onWillShowOverlay = new Emitter();
3946
- this.onWillShowOverlay = this._onWillShowOverlay.event;
3947
- this._element = document.createElement('div');
3948
- this._element.className = 'tabs-and-actions-container';
3949
- toggleClass(this._element, 'dv-full-width-single-tab', this.accessor.options.singleTabMode === 'fullwidth');
3950
- this.rightActionsContainer = document.createElement('div');
3951
- this.rightActionsContainer.className = 'right-actions-container';
3952
- this.leftActionsContainer = document.createElement('div');
3953
- this.leftActionsContainer.className = 'left-actions-container';
3954
- this.preActionsContainer = document.createElement('div');
3955
- this.preActionsContainer.className = 'pre-actions-container';
3956
- this.tabContainer = document.createElement('div');
3957
- this.tabContainer.className = 'tabs-container';
3958
- this.voidContainer = new VoidContainer(this.accessor, this.group);
3959
- this._element.appendChild(this.preActionsContainer);
3960
- this._element.appendChild(this.tabContainer);
3961
- this._element.appendChild(this.leftActionsContainer);
3962
- this._element.appendChild(this.voidContainer.element);
3963
- this._element.appendChild(this.rightActionsContainer);
3964
- this.addDisposables(this.accessor.onDidAddPanel((e) => {
3965
- if (e.api.group === this.group) {
3966
- toggleClass(this._element, 'dv-single-tab', this.size === 1);
3967
- }
3968
- }), this.accessor.onDidRemovePanel((e) => {
3969
- if (e.api.group === this.group) {
3970
- toggleClass(this._element, 'dv-single-tab', this.size === 1);
3971
- }
3972
- }), this._onWillShowOverlay, this._onDrop, this._onTabDragStart, this._onGroupDragStart, this.voidContainer, this.voidContainer.onDragStart((event) => {
3973
- this._onGroupDragStart.fire({
3974
- nativeEvent: event,
3975
- group: this.group,
3976
- });
3977
- }), this.voidContainer.onDrop((event) => {
3978
- this._onDrop.fire({
3979
- event: event.nativeEvent,
3980
- index: this.tabs.length,
3981
- });
3982
- }), this.voidContainer.onWillShowOverlay((event) => {
3983
- this._onWillShowOverlay.fire(new WillShowOverlayLocationEvent(event, {
3984
- kind: 'header_space',
3985
- }));
3986
- }), addDisposableListener(this.voidContainer.element, 'mousedown', (event) => {
3987
- const isFloatingGroupsEnabled = !this.accessor.options.disableFloatingGroups;
3988
- if (isFloatingGroupsEnabled &&
3989
- event.shiftKey &&
3990
- this.group.api.location.type !== 'floating') {
3991
- event.preventDefault();
3992
- const { top, left } = this.element.getBoundingClientRect();
3993
- const { top: rootTop, left: rootLeft } = this.accessor.element.getBoundingClientRect();
3994
- this.accessor.addFloatingGroup(this.group, {
3995
- x: left - rootLeft + 20,
3996
- y: top - rootTop + 20,
3997
- }, { inDragMode: true });
3998
- }
3999
- }), addDisposableListener(this.tabContainer, 'mousedown', (event) => {
4000
- if (event.defaultPrevented) {
4001
- return;
4002
- }
4003
- const isLeftClick = event.button === 0;
4004
- if (isLeftClick) {
4005
- this.accessor.doSetGroupActive(this.group);
4006
- }
4007
- }));
4008
- }
4009
- setActive(_isGroupActive) {
4010
- // noop
4011
- }
4012
- addTab(tab, index = this.tabs.length) {
4013
- if (index < 0 || index > this.tabs.length) {
4014
- throw new Error('invalid location');
4015
- }
4016
- this.tabContainer.insertBefore(tab.value.element, this.tabContainer.children[index]);
4017
- this.tabs = [
4018
- ...this.tabs.slice(0, index),
4019
- tab,
4020
- ...this.tabs.slice(index),
4021
- ];
4022
- if (this.selectedIndex < 0) {
4023
- this.selectedIndex = index;
4167
+ this.bodyPart = this.getBodyComponent();
4168
+ this.headerPart = this.getHeaderComponent();
4169
+ this.bodyPart.init(Object.assign(Object.assign({}, parameters), { api: this.api }));
4170
+ this.headerPart.init(Object.assign(Object.assign({}, parameters), { api: this.api }));
4171
+ (_a = this.body) === null || _a === void 0 ? void 0 : _a.append(this.bodyPart.element);
4172
+ (_b = this.header) === null || _b === void 0 ? void 0 : _b.append(this.headerPart.element);
4173
+ if (typeof parameters.isExpanded === 'boolean') {
4174
+ this.setExpanded(parameters.isExpanded);
4024
4175
  }
4025
4176
  }
4026
- delete(id) {
4027
- const index = this.tabs.findIndex((tab) => tab.value.panel.id === id);
4028
- const tabToRemove = this.tabs.splice(index, 1)[0];
4029
- const { value, disposable } = tabToRemove;
4030
- disposable.dispose();
4031
- value.dispose();
4032
- value.element.remove();
4033
- }
4034
- setActivePanel(panel) {
4035
- this.tabs.forEach((tab) => {
4036
- const isActivePanel = panel.id === tab.value.panel.id;
4037
- tab.value.setActive(isActivePanel);
4038
- });
4039
- }
4040
- openPanel(panel, index = this.tabs.length) {
4041
- var _a;
4042
- if (this.tabs.find((tab) => tab.value.panel.id === panel.id)) {
4043
- return;
4044
- }
4045
- const tab = new Tab(panel, this.accessor, this.group);
4046
- if (!((_a = panel.view) === null || _a === void 0 ? void 0 : _a.tab)) {
4047
- throw new Error('invalid header component');
4048
- }
4049
- tab.setContent(panel.view.tab);
4050
- const disposable = new CompositeDisposable(tab.onDragStart((event) => {
4051
- this._onTabDragStart.fire({ nativeEvent: event, panel });
4052
- }), tab.onChanged((event) => {
4053
- const isFloatingGroupsEnabled = !this.accessor.options.disableFloatingGroups;
4054
- const isFloatingWithOnePanel = this.group.api.location.type === 'floating' &&
4055
- this.size === 1;
4056
- if (isFloatingGroupsEnabled &&
4057
- !isFloatingWithOnePanel &&
4058
- event.shiftKey) {
4059
- event.preventDefault();
4060
- const panel = this.accessor.getGroupPanel(tab.panel.id);
4061
- const { top, left } = tab.element.getBoundingClientRect();
4062
- const { top: rootTop, left: rootLeft } = this.accessor.element.getBoundingClientRect();
4063
- this.accessor.addFloatingGroup(panel, {
4064
- x: left - rootLeft,
4065
- y: top - rootTop,
4066
- }, { inDragMode: true });
4067
- return;
4068
- }
4069
- const isLeftClick = event.button === 0;
4070
- if (!isLeftClick || event.defaultPrevented) {
4071
- return;
4072
- }
4073
- if (this.group.activePanel !== panel) {
4074
- this.group.model.openPanel(panel);
4075
- }
4076
- }), tab.onDrop((event) => {
4077
- this._onDrop.fire({
4078
- event: event.nativeEvent,
4079
- index: this.tabs.findIndex((x) => x.value === tab),
4080
- });
4081
- }), tab.onWillShowOverlay((event) => {
4082
- this._onWillShowOverlay.fire(new WillShowOverlayLocationEvent(event, { kind: 'tab' }));
4083
- }));
4084
- const value = { value: tab, disposable };
4085
- this.addTab(value, index);
4177
+ toJSON() {
4178
+ const params = this._params;
4179
+ return Object.assign(Object.assign({}, super.toJSON()), { headerComponent: this.headerComponent, title: params.title });
4086
4180
  }
4087
- closePanel(panel) {
4088
- this.delete(panel.id);
4181
+ renderOnce() {
4182
+ this.header = document.createElement('div');
4183
+ this.header.tabIndex = 0;
4184
+ this.header.className = 'pane-header';
4185
+ this.header.style.height = `${this.headerSize}px`;
4186
+ this.header.style.lineHeight = `${this.headerSize}px`;
4187
+ this.header.style.minHeight = `${this.headerSize}px`;
4188
+ this.header.style.maxHeight = `${this.headerSize}px`;
4189
+ this.element.appendChild(this.header);
4190
+ this.body = document.createElement('div');
4191
+ this.body.className = 'pane-body';
4192
+ this.element.appendChild(this.body);
4089
4193
  }
4090
- dispose() {
4091
- super.dispose();
4092
- for (const { value, disposable } of this.tabs) {
4093
- disposable.dispose();
4094
- value.dispose();
4095
- }
4096
- this.tabs = [];
4194
+ // TODO slightly hacky by-pass of the component to create a body and header component
4195
+ getComponent() {
4196
+ return {
4197
+ update: (params) => {
4198
+ var _a, _b;
4199
+ (_a = this.bodyPart) === null || _a === void 0 ? void 0 : _a.update({ params });
4200
+ (_b = this.headerPart) === null || _b === void 0 ? void 0 : _b.update({ params });
4201
+ },
4202
+ dispose: () => {
4203
+ var _a, _b;
4204
+ (_a = this.bodyPart) === null || _a === void 0 ? void 0 : _a.dispose();
4205
+ (_b = this.headerPart) === null || _b === void 0 ? void 0 : _b.dispose();
4206
+ },
4207
+ };
4097
4208
  }
4098
4209
  }
4099
4210
 
4100
- class DockviewDidDropEvent extends DockviewEvent {
4101
- get nativeEvent() {
4102
- return this.options.nativeEvent;
4103
- }
4104
- get position() {
4105
- return this.options.position;
4106
- }
4107
- get panel() {
4108
- return this.options.panel;
4109
- }
4110
- get group() {
4111
- return this.options.group;
4112
- }
4113
- get api() {
4114
- return this.options.api;
4115
- }
4116
- constructor(options) {
4117
- super();
4118
- this.options = options;
4119
- }
4120
- getData() {
4121
- return this.options.getData();
4122
- }
4123
- }
4124
- class DockviewWillDropEvent extends DockviewDidDropEvent {
4125
- get kind() {
4126
- return this._kind;
4127
- }
4128
- constructor(options) {
4129
- super(options);
4130
- this._kind = options.kind;
4131
- }
4132
- }
4133
- class WillShowOverlayLocationEvent {
4134
- get kind() {
4135
- return this._kind;
4136
- }
4137
- get nativeEvent() {
4138
- return this.event.nativeEvent;
4211
+ class DraggablePaneviewPanel extends PaneviewPanel {
4212
+ constructor(accessor, id, component, headerComponent, orientation, isExpanded, disableDnd) {
4213
+ super(id, component, headerComponent, orientation, isExpanded, true);
4214
+ this.accessor = accessor;
4215
+ this._onDidDrop = new Emitter();
4216
+ this.onDidDrop = this._onDidDrop.event;
4217
+ if (!disableDnd) {
4218
+ this.initDragFeatures();
4219
+ }
4139
4220
  }
4140
- get position() {
4141
- return this.event.position;
4142
- }
4143
- get defaultPrevented() {
4144
- return this.event.defaultPrevented;
4145
- }
4146
- preventDefault() {
4147
- this.event.preventDefault();
4148
- }
4149
- constructor(event, options) {
4150
- this.event = event;
4151
- this._kind = options.kind;
4152
- }
4153
- }
4154
- class DockviewGroupPanelModel extends CompositeDisposable {
4155
- get element() {
4156
- throw new Error('not supported');
4157
- }
4158
- get activePanel() {
4159
- return this._activePanel;
4160
- }
4161
- get locked() {
4162
- return this._locked;
4163
- }
4164
- set locked(value) {
4165
- this._locked = value;
4166
- toggleClass(this.container, 'locked-groupview', value === 'no-drop-target' || value);
4167
- }
4168
- get isActive() {
4169
- return this._isGroupActive;
4170
- }
4171
- get panels() {
4172
- return this._panels;
4173
- }
4174
- get size() {
4175
- return this._panels.length;
4176
- }
4177
- get isEmpty() {
4178
- return this._panels.length === 0;
4179
- }
4180
- get hasWatermark() {
4181
- return !!(this.watermark && this.container.contains(this.watermark.element));
4182
- }
4183
- get header() {
4184
- return this.tabsContainer;
4185
- }
4186
- get isContentFocused() {
4187
- if (!document.activeElement) {
4188
- return false;
4189
- }
4190
- return isAncestor(document.activeElement, this.contentContainer.element);
4191
- }
4192
- get location() {
4193
- return this._location;
4194
- }
4195
- set location(value) {
4196
- this._location = value;
4197
- toggleClass(this.container, 'dv-groupview-floating', false);
4198
- toggleClass(this.container, 'dv-groupview-popout', false);
4199
- switch (value.type) {
4200
- case 'grid':
4201
- this.contentContainer.dropTarget.setTargetZones([
4202
- 'top',
4203
- 'bottom',
4204
- 'left',
4205
- 'right',
4206
- 'center',
4207
- ]);
4208
- break;
4209
- case 'floating':
4210
- this.contentContainer.dropTarget.setTargetZones(['center']);
4211
- this.contentContainer.dropTarget.setTargetZones(value
4212
- ? ['center']
4213
- : ['top', 'bottom', 'left', 'right', 'center']);
4214
- toggleClass(this.container, 'dv-groupview-floating', true);
4215
- break;
4216
- case 'popout':
4217
- this.contentContainer.dropTarget.setTargetZones(['center']);
4218
- toggleClass(this.container, 'dv-groupview-popout', true);
4219
- break;
4220
- }
4221
- this.groupPanel.api._onDidLocationChange.fire({
4222
- location: this.location,
4223
- });
4224
- }
4225
- constructor(container, accessor, id, options, groupPanel) {
4226
- var _a;
4227
- super();
4228
- this.container = container;
4229
- this.accessor = accessor;
4230
- this.id = id;
4231
- this.options = options;
4232
- this.groupPanel = groupPanel;
4233
- this._isGroupActive = false;
4234
- this._locked = false;
4235
- this._location = { type: 'grid' };
4236
- this.mostRecentlyUsed = [];
4237
- this._onDidChange = new Emitter();
4238
- this.onDidChange = this._onDidChange.event;
4239
- this._width = 0;
4240
- this._height = 0;
4241
- this._panels = [];
4242
- this._panelDisposables = new Map();
4243
- this._onMove = new Emitter();
4244
- this.onMove = this._onMove.event;
4245
- this._onDidDrop = new Emitter();
4246
- this.onDidDrop = this._onDidDrop.event;
4247
- this._onWillDrop = new Emitter();
4248
- this.onWillDrop = this._onWillDrop.event;
4249
- this._onWillShowOverlay = new Emitter();
4250
- this.onWillShowOverlay = this._onWillShowOverlay.event;
4251
- this._onTabDragStart = new Emitter();
4252
- this.onTabDragStart = this._onTabDragStart.event;
4253
- this._onGroupDragStart = new Emitter();
4254
- this.onGroupDragStart = this._onGroupDragStart.event;
4255
- this._onDidAddPanel = new Emitter();
4256
- this.onDidAddPanel = this._onDidAddPanel.event;
4257
- this._onDidPanelTitleChange = new Emitter();
4258
- this.onDidPanelTitleChange = this._onDidPanelTitleChange.event;
4259
- this._onDidPanelParametersChange = new Emitter();
4260
- this.onDidPanelParametersChange = this._onDidPanelParametersChange.event;
4261
- this._onDidRemovePanel = new Emitter();
4262
- this.onDidRemovePanel = this._onDidRemovePanel.event;
4263
- this._onDidActivePanelChange = new Emitter();
4264
- this.onDidActivePanelChange = this._onDidActivePanelChange.event;
4265
- this._overwriteRenderContainer = null;
4266
- toggleClass(this.container, 'groupview', true);
4267
- this._api = new DockviewApi(this.accessor);
4268
- this.tabsContainer = new TabsContainer(this.accessor, this.groupPanel);
4269
- this.contentContainer = new ContentContainer(this.accessor, this);
4270
- container.append(this.tabsContainer.element, this.contentContainer.element);
4271
- this.header.hidden = !!options.hideHeader;
4272
- this.locked = (_a = options.locked) !== null && _a !== void 0 ? _a : false;
4273
- this.addDisposables(this._onTabDragStart, this._onGroupDragStart, this._onWillShowOverlay, this.tabsContainer.onTabDragStart((event) => {
4274
- this._onTabDragStart.fire(event);
4275
- }), this.tabsContainer.onGroupDragStart((event) => {
4276
- this._onGroupDragStart.fire(event);
4277
- }), this.tabsContainer.onDrop((event) => {
4278
- this.handleDropEvent('header', event.event, 'center', event.index);
4279
- }), this.contentContainer.onDidFocus(() => {
4280
- this.accessor.doSetGroupActive(this.groupPanel);
4281
- }), this.contentContainer.onDidBlur(() => {
4282
- // noop
4283
- }), this.contentContainer.dropTarget.onDrop((event) => {
4284
- this.handleDropEvent('content', event.nativeEvent, event.position);
4285
- }), this.tabsContainer.onWillShowOverlay((event) => {
4286
- this._onWillShowOverlay.fire(event);
4287
- }), this.contentContainer.dropTarget.onWillShowOverlay((event) => {
4288
- this._onWillShowOverlay.fire(new WillShowOverlayLocationEvent(event, {
4289
- kind: 'content',
4290
- }));
4291
- }), this._onMove, this._onDidChange, this._onDidDrop, this._onWillDrop, this._onDidAddPanel, this._onDidRemovePanel, this._onDidActivePanelChange);
4292
- }
4293
- focusContent() {
4294
- this.contentContainer.element.focus();
4295
- }
4296
- set renderContainer(value) {
4297
- this.panels.forEach((panel) => {
4298
- this.renderContainer.detatch(panel);
4299
- });
4300
- this._overwriteRenderContainer = value;
4301
- this.panels.forEach((panel) => {
4302
- this.rerender(panel);
4303
- });
4304
- }
4305
- get renderContainer() {
4306
- var _a;
4307
- return ((_a = this._overwriteRenderContainer) !== null && _a !== void 0 ? _a : this.accessor.overlayRenderContainer);
4308
- }
4309
- initialize() {
4310
- if (this.options.panels) {
4311
- this.options.panels.forEach((panel) => {
4312
- this.doAddPanel(panel);
4313
- });
4314
- }
4315
- if (this.options.activePanel) {
4316
- this.openPanel(this.options.activePanel);
4317
- }
4318
- // must be run after the constructor otherwise this.parent may not be
4319
- // correctly initialized
4320
- this.setActive(this.isActive, true);
4321
- this.updateContainer();
4322
- if (this.accessor.options.createRightHeaderActionsElement) {
4323
- this._rightHeaderActions =
4324
- this.accessor.options.createRightHeaderActionsElement(this.groupPanel);
4325
- this.addDisposables(this._rightHeaderActions);
4326
- this._rightHeaderActions.init({
4327
- containerApi: this._api,
4328
- api: this.groupPanel.api,
4329
- });
4330
- this.tabsContainer.setRightActionsElement(this._rightHeaderActions.element);
4331
- }
4332
- if (this.accessor.options.createLeftHeaderActionsElement) {
4333
- this._leftHeaderActions =
4334
- this.accessor.options.createLeftHeaderActionsElement(this.groupPanel);
4335
- this.addDisposables(this._leftHeaderActions);
4336
- this._leftHeaderActions.init({
4337
- containerApi: this._api,
4338
- api: this.groupPanel.api,
4339
- });
4340
- this.tabsContainer.setLeftActionsElement(this._leftHeaderActions.element);
4341
- }
4342
- if (this.accessor.options.createPrefixHeaderActionsElement) {
4343
- this._prefixHeaderActions =
4344
- this.accessor.options.createPrefixHeaderActionsElement(this.groupPanel);
4345
- this.addDisposables(this._prefixHeaderActions);
4346
- this._prefixHeaderActions.init({
4347
- containerApi: this._api,
4348
- api: this.groupPanel.api,
4349
- });
4350
- this.tabsContainer.setPrefixActionsElement(this._prefixHeaderActions.element);
4351
- }
4352
- }
4353
- rerender(panel) {
4354
- this.contentContainer.renderPanel(panel, { asActive: false });
4355
- }
4356
- indexOf(panel) {
4357
- return this.tabsContainer.indexOf(panel.id);
4358
- }
4359
- toJSON() {
4360
- var _a;
4361
- const result = {
4362
- views: this.tabsContainer.panels,
4363
- activeView: (_a = this._activePanel) === null || _a === void 0 ? void 0 : _a.id,
4364
- id: this.id,
4365
- };
4366
- if (this.locked !== false) {
4367
- result.locked = this.locked;
4368
- }
4369
- if (this.header.hidden) {
4370
- result.hideHeader = true;
4371
- }
4372
- return result;
4373
- }
4374
- moveToNext(options) {
4375
- if (!options) {
4376
- options = {};
4377
- }
4378
- if (!options.panel) {
4379
- options.panel = this.activePanel;
4380
- }
4381
- const index = options.panel ? this.panels.indexOf(options.panel) : -1;
4382
- let normalizedIndex;
4383
- if (index < this.panels.length - 1) {
4384
- normalizedIndex = index + 1;
4385
- }
4386
- else if (!options.suppressRoll) {
4387
- normalizedIndex = 0;
4388
- }
4389
- else {
4390
- return;
4391
- }
4392
- this.openPanel(this.panels[normalizedIndex]);
4393
- }
4394
- moveToPrevious(options) {
4395
- if (!options) {
4396
- options = {};
4397
- }
4398
- if (!options.panel) {
4399
- options.panel = this.activePanel;
4400
- }
4401
- if (!options.panel) {
4402
- return;
4403
- }
4404
- const index = this.panels.indexOf(options.panel);
4405
- let normalizedIndex;
4406
- if (index > 0) {
4407
- normalizedIndex = index - 1;
4408
- }
4409
- else if (!options.suppressRoll) {
4410
- normalizedIndex = this.panels.length - 1;
4411
- }
4412
- else {
4413
- return;
4414
- }
4415
- this.openPanel(this.panels[normalizedIndex]);
4416
- }
4417
- containsPanel(panel) {
4418
- return this.panels.includes(panel);
4419
- }
4420
- init(_params) {
4421
- //noop
4422
- }
4423
- update(_params) {
4424
- //noop
4425
- }
4426
- focus() {
4427
- var _a;
4428
- (_a = this._activePanel) === null || _a === void 0 ? void 0 : _a.focus();
4429
- }
4430
- openPanel(panel, options = {}) {
4431
- /**
4432
- * set the panel group
4433
- * add the panel
4434
- * check if group active
4435
- * check if panel active
4436
- */
4437
- if (typeof options.index !== 'number' ||
4438
- options.index > this.panels.length) {
4439
- options.index = this.panels.length;
4440
- }
4441
- const skipSetActive = !!options.skipSetActive;
4442
- // ensure the group is updated before we fire any events
4443
- panel.updateParentGroup(this.groupPanel, {
4444
- skipSetActive: options.skipSetActive,
4445
- });
4446
- this.doAddPanel(panel, options.index, {
4447
- skipSetActive: skipSetActive,
4448
- });
4449
- if (this._activePanel === panel) {
4450
- this.contentContainer.renderPanel(panel, { asActive: true });
4451
- return;
4452
- }
4453
- if (!skipSetActive) {
4454
- this.doSetActivePanel(panel);
4455
- }
4456
- if (!options.skipSetGroupActive) {
4457
- this.accessor.doSetGroupActive(this.groupPanel);
4458
- }
4459
- if (!options.skipSetActive) {
4460
- this.updateContainer();
4461
- }
4462
- }
4463
- removePanel(groupItemOrId, options = {
4464
- skipSetActive: false,
4465
- }) {
4466
- const id = typeof groupItemOrId === 'string'
4467
- ? groupItemOrId
4468
- : groupItemOrId.id;
4469
- const panelToRemove = this._panels.find((panel) => panel.id === id);
4470
- if (!panelToRemove) {
4471
- throw new Error('invalid operation');
4472
- }
4473
- return this._removePanel(panelToRemove, options);
4474
- }
4475
- closeAllPanels() {
4476
- if (this.panels.length > 0) {
4477
- // take a copy since we will be edting the array as we iterate through
4478
- const arrPanelCpy = [...this.panels];
4479
- for (const panel of arrPanelCpy) {
4480
- this.doClose(panel);
4481
- }
4482
- }
4483
- else {
4484
- this.accessor.removeGroup(this.groupPanel);
4485
- }
4486
- }
4487
- closePanel(panel) {
4488
- this.doClose(panel);
4489
- }
4490
- doClose(panel) {
4491
- this.accessor.removePanel(panel);
4492
- }
4493
- isPanelActive(panel) {
4494
- return this._activePanel === panel;
4495
- }
4496
- updateActions(element) {
4497
- this.tabsContainer.setRightActionsElement(element);
4498
- }
4499
- setActive(isGroupActive, force = false) {
4500
- if (!force && this.isActive === isGroupActive) {
4501
- return;
4502
- }
4503
- this._isGroupActive = isGroupActive;
4504
- toggleClass(this.container, 'active-group', isGroupActive);
4505
- toggleClass(this.container, 'inactive-group', !isGroupActive);
4506
- this.tabsContainer.setActive(this.isActive);
4507
- if (!this._activePanel && this.panels.length > 0) {
4508
- this.doSetActivePanel(this.panels[0]);
4509
- }
4510
- this.updateContainer();
4511
- }
4512
- layout(width, height) {
4513
- var _a;
4514
- this._width = width;
4515
- this._height = height;
4516
- this.contentContainer.layout(this._width, this._height);
4517
- if ((_a = this._activePanel) === null || _a === void 0 ? void 0 : _a.layout) {
4518
- this._activePanel.layout(this._width, this._height);
4519
- }
4520
- }
4521
- _removePanel(panel, options) {
4522
- const isActivePanel = this._activePanel === panel;
4523
- this.doRemovePanel(panel);
4524
- if (isActivePanel && this.panels.length > 0) {
4525
- const nextPanel = this.mostRecentlyUsed[0];
4526
- this.openPanel(nextPanel, {
4527
- skipSetActive: options.skipSetActive,
4528
- skipSetGroupActive: options.skipSetActiveGroup,
4529
- });
4530
- }
4531
- if (this._activePanel && this.panels.length === 0) {
4532
- this.doSetActivePanel(undefined);
4533
- }
4534
- if (!options.skipSetActive) {
4535
- this.updateContainer();
4536
- }
4537
- return panel;
4538
- }
4539
- doRemovePanel(panel) {
4540
- const index = this.panels.indexOf(panel);
4541
- if (this._activePanel === panel) {
4542
- this.contentContainer.closePanel();
4543
- }
4544
- this.tabsContainer.delete(panel.id);
4545
- this._panels.splice(index, 1);
4546
- if (this.mostRecentlyUsed.includes(panel)) {
4547
- this.mostRecentlyUsed.splice(this.mostRecentlyUsed.indexOf(panel), 1);
4548
- }
4549
- const disposable = this._panelDisposables.get(panel.id);
4550
- if (disposable) {
4551
- disposable.dispose();
4552
- this._panelDisposables.delete(panel.id);
4553
- }
4554
- this._onDidRemovePanel.fire({ panel });
4555
- }
4556
- doAddPanel(panel, index = this.panels.length, options = { skipSetActive: false }) {
4557
- const existingPanel = this._panels.indexOf(panel);
4558
- const hasExistingPanel = existingPanel > -1;
4559
- this.tabsContainer.show();
4560
- this.contentContainer.show();
4561
- this.tabsContainer.openPanel(panel, index);
4562
- if (!options.skipSetActive) {
4563
- this.contentContainer.openPanel(panel);
4564
- }
4565
- if (hasExistingPanel) {
4566
- // TODO - need to ensure ordering hasn't changed and if it has need to re-order this.panels
4567
- return;
4568
- }
4569
- this.updateMru(panel);
4570
- this.panels.splice(index, 0, panel);
4571
- this._panelDisposables.set(panel.id, new CompositeDisposable(panel.api.onDidTitleChange((event) => this._onDidPanelTitleChange.fire(event)), panel.api.onDidParametersChange((event) => this._onDidPanelParametersChange.fire(event))));
4572
- this._onDidAddPanel.fire({ panel });
4573
- }
4574
- doSetActivePanel(panel) {
4575
- if (this._activePanel === panel) {
4576
- return;
4577
- }
4578
- this._activePanel = panel;
4579
- if (panel) {
4580
- this.tabsContainer.setActivePanel(panel);
4581
- panel.layout(this._width, this._height);
4582
- this.updateMru(panel);
4583
- this._onDidActivePanelChange.fire({
4584
- panel,
4585
- });
4586
- }
4587
- }
4588
- updateMru(panel) {
4589
- if (this.mostRecentlyUsed.includes(panel)) {
4590
- this.mostRecentlyUsed.splice(this.mostRecentlyUsed.indexOf(panel), 1);
4591
- }
4592
- this.mostRecentlyUsed = [panel, ...this.mostRecentlyUsed];
4593
- }
4594
- updateContainer() {
4595
- var _a, _b;
4596
- toggleClass(this.container, 'empty', this.isEmpty);
4597
- this.panels.forEach((panel) => panel.runEvents());
4598
- if (this.isEmpty && !this.watermark) {
4599
- const watermark = this.accessor.createWatermarkComponent();
4600
- watermark.init({
4601
- containerApi: this._api,
4602
- group: this.groupPanel,
4603
- });
4604
- this.watermark = watermark;
4605
- addDisposableListener(this.watermark.element, 'click', () => {
4606
- if (!this.isActive) {
4607
- this.accessor.doSetGroupActive(this.groupPanel);
4608
- }
4609
- });
4610
- this.tabsContainer.hide();
4611
- this.contentContainer.element.appendChild(this.watermark.element);
4612
- this.watermark.updateParentGroup(this.groupPanel, true);
4613
- }
4614
- if (!this.isEmpty && this.watermark) {
4615
- this.watermark.element.remove();
4616
- (_b = (_a = this.watermark).dispose) === null || _b === void 0 ? void 0 : _b.call(_a);
4617
- this.watermark = undefined;
4618
- this.tabsContainer.show();
4619
- }
4620
- }
4621
- canDisplayOverlay(event, position, target) {
4622
- // custom overlay handler
4623
- if (this.accessor.options.showDndOverlay) {
4624
- return this.accessor.options.showDndOverlay({
4625
- nativeEvent: event,
4626
- target,
4627
- group: this.accessor.getPanel(this.id),
4628
- position,
4629
- getData: getPanelData,
4630
- });
4631
- }
4632
- return false;
4633
- }
4634
- handleDropEvent(type, event, position, index) {
4635
- if (this.locked === 'no-drop-target') {
4221
+ initDragFeatures() {
4222
+ if (!this.header) {
4636
4223
  return;
4637
4224
  }
4638
- function getKind() {
4639
- switch (type) {
4640
- case 'header':
4641
- return typeof index === 'number' ? 'tab' : 'header_space';
4642
- case 'content':
4643
- return 'content';
4225
+ const id = this.id;
4226
+ const accessorId = this.accessor.id;
4227
+ this.header.draggable = true;
4228
+ this.handler = new (class PaneDragHandler extends DragHandler {
4229
+ getData() {
4230
+ LocalSelectionTransfer.getInstance().setData([new PaneTransfer(accessorId, id)], PaneTransfer.prototype);
4231
+ return {
4232
+ dispose: () => {
4233
+ LocalSelectionTransfer.getInstance().clearData(PaneTransfer.prototype);
4234
+ },
4235
+ };
4644
4236
  }
4645
- }
4646
- const panel = typeof index === 'number' ? this.panels[index] : undefined;
4647
- const willDropEvent = new DockviewWillDropEvent({
4648
- nativeEvent: event,
4649
- position,
4650
- panel,
4651
- getData: () => getPanelData(),
4652
- kind: getKind(),
4653
- group: this.groupPanel,
4654
- api: this._api,
4237
+ })(this.header);
4238
+ this.target = new Droptarget(this.element, {
4239
+ acceptedTargetZones: ['top', 'bottom'],
4240
+ overlayModel: {
4241
+ activationSize: { type: 'percentage', value: 50 },
4242
+ },
4243
+ canDisplayOverlay: (event) => {
4244
+ const data = getPaneData();
4245
+ if (data) {
4246
+ if (data.paneId !== this.id &&
4247
+ data.viewId === this.accessor.id) {
4248
+ return true;
4249
+ }
4250
+ }
4251
+ if (this.accessor.options.showDndOverlay) {
4252
+ return this.accessor.options.showDndOverlay({
4253
+ nativeEvent: event,
4254
+ getData: getPaneData,
4255
+ panel: this,
4256
+ });
4257
+ }
4258
+ return false;
4259
+ },
4655
4260
  });
4656
- this._onWillDrop.fire(willDropEvent);
4657
- if (willDropEvent.defaultPrevented) {
4261
+ this.addDisposables(this._onDidDrop, this.handler, this.target, this.target.onDrop((event) => {
4262
+ this.onDrop(event);
4263
+ }));
4264
+ }
4265
+ onDrop(event) {
4266
+ const data = getPaneData();
4267
+ if (!data || data.viewId !== this.accessor.id) {
4268
+ // if there is no local drag event for this panel
4269
+ // or if the drag event was creating by another Paneview instance
4270
+ this._onDidDrop.fire(Object.assign(Object.assign({}, event), { panel: this, api: new PaneviewApi(this.accessor), getData: getPaneData }));
4658
4271
  return;
4659
4272
  }
4660
- const data = getPanelData();
4661
- if (data && data.viewId === this.accessor.id) {
4662
- if (data.panelId === null) {
4663
- // this is a group move dnd event
4664
- const { groupId } = data;
4665
- this._onMove.fire({
4666
- target: position,
4667
- groupId: groupId,
4668
- index,
4669
- });
4670
- return;
4671
- }
4672
- const fromSameGroup = this.tabsContainer.indexOf(data.panelId) !== -1;
4673
- if (fromSameGroup && this.tabsContainer.size === 1) {
4674
- return;
4675
- }
4676
- const { groupId, panelId } = data;
4677
- const isSameGroup = this.id === groupId;
4678
- if (isSameGroup && !position) {
4679
- const oldIndex = this.tabsContainer.indexOf(panelId);
4680
- if (oldIndex === index) {
4681
- return;
4682
- }
4683
- }
4684
- this._onMove.fire({
4685
- target: position,
4686
- groupId: data.groupId,
4687
- itemId: data.panelId,
4688
- index,
4689
- });
4273
+ const containerApi = this._params
4274
+ .containerApi;
4275
+ const panelId = data.paneId;
4276
+ const existingPanel = containerApi.getPanel(panelId);
4277
+ if (!existingPanel) {
4278
+ // if the panel doesn't exist
4279
+ this._onDidDrop.fire(Object.assign(Object.assign({}, event), { panel: this, getData: getPaneData, api: new PaneviewApi(this.accessor) }));
4280
+ return;
4690
4281
  }
4691
- else {
4692
- this._onDidDrop.fire(new DockviewDidDropEvent({
4693
- nativeEvent: event,
4694
- position,
4695
- panel,
4696
- getData: () => getPanelData(),
4697
- group: this.groupPanel,
4698
- api: this._api,
4699
- }));
4282
+ const allPanels = containerApi.panels;
4283
+ const fromIndex = allPanels.indexOf(existingPanel);
4284
+ let toIndex = containerApi.panels.indexOf(this);
4285
+ if (event.position === 'left' || event.position === 'top') {
4286
+ toIndex = Math.max(0, toIndex - 1);
4700
4287
  }
4701
- }
4702
- dispose() {
4703
- var _a, _b, _c;
4704
- super.dispose();
4705
- (_a = this.watermark) === null || _a === void 0 ? void 0 : _a.element.remove();
4706
- (_c = (_b = this.watermark) === null || _b === void 0 ? void 0 : _b.dispose) === null || _c === void 0 ? void 0 : _c.call(_b);
4707
- this.watermark = undefined;
4708
- for (const panel of this.panels) {
4709
- panel.dispose();
4288
+ if (event.position === 'right' || event.position === 'bottom') {
4289
+ if (fromIndex > toIndex) {
4290
+ toIndex++;
4291
+ }
4292
+ toIndex = Math.min(allPanels.length - 1, toIndex);
4710
4293
  }
4711
- this.tabsContainer.dispose();
4712
- this.contentContainer.dispose();
4294
+ containerApi.movePanel(fromIndex, toIndex);
4713
4295
  }
4714
4296
  }
4715
4297
 
4716
- class Resizable extends CompositeDisposable {
4298
+ class ContentContainer extends CompositeDisposable {
4717
4299
  get element() {
4718
4300
  return this._element;
4719
4301
  }
4720
- get disableResizing() {
4721
- return this._disableResizing;
4302
+ constructor(accessor, group) {
4303
+ super();
4304
+ this.accessor = accessor;
4305
+ this.group = group;
4306
+ this.disposable = new MutableDisposable();
4307
+ this._onDidFocus = new Emitter();
4308
+ this.onDidFocus = this._onDidFocus.event;
4309
+ this._onDidBlur = new Emitter();
4310
+ this.onDidBlur = this._onDidBlur.event;
4311
+ this._element = document.createElement('div');
4312
+ this._element.className = 'content-container';
4313
+ this._element.tabIndex = -1;
4314
+ this.addDisposables(this._onDidFocus, this._onDidBlur);
4315
+ this.dropTarget = new Droptarget(this.element, {
4316
+ acceptedTargetZones: ['top', 'bottom', 'left', 'right', 'center'],
4317
+ canDisplayOverlay: (event, position) => {
4318
+ if (this.group.locked === 'no-drop-target' ||
4319
+ (this.group.locked && position === 'center')) {
4320
+ return false;
4321
+ }
4322
+ const data = getPanelData();
4323
+ if (!data &&
4324
+ event.shiftKey &&
4325
+ this.group.location.type !== 'floating') {
4326
+ return false;
4327
+ }
4328
+ if (data && data.viewId === this.accessor.id) {
4329
+ if (data.groupId === this.group.id) {
4330
+ if (position === 'center') {
4331
+ // don't allow to drop on self for center position
4332
+ return false;
4333
+ }
4334
+ if (data.panelId === null) {
4335
+ // don't allow group move to drop anywhere on self
4336
+ return false;
4337
+ }
4338
+ }
4339
+ const groupHasOnePanelAndIsActiveDragElement = this.group.panels.length === 1 &&
4340
+ data.groupId === this.group.id;
4341
+ return !groupHasOnePanelAndIsActiveDragElement;
4342
+ }
4343
+ return this.group.canDisplayOverlay(event, position, 'content');
4344
+ },
4345
+ });
4346
+ this.addDisposables(this.dropTarget);
4722
4347
  }
4723
- set disableResizing(value) {
4724
- this._disableResizing = value;
4348
+ show() {
4349
+ this.element.style.display = '';
4725
4350
  }
4726
- constructor(parentElement, disableResizing = false) {
4727
- super();
4728
- this._disableResizing = disableResizing;
4729
- this._element = parentElement;
4730
- this.addDisposables(watchElementResize(this._element, (entry) => {
4731
- if (this.isDisposed) {
4732
- /**
4733
- * resize is delayed through requestAnimationFrame so there is a small chance
4734
- * the component has already been disposed of
4735
- */
4736
- return;
4737
- }
4738
- if (this.disableResizing) {
4739
- return;
4740
- }
4741
- if (!this._element.offsetParent) {
4742
- /**
4743
- * offsetParent === null is equivalent to display: none being set on the element or one
4744
- * of it's parents. In the display: none case the size will become (0, 0) which we do
4745
- * not want to propagate.
4746
- *
4747
- * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetParent
4748
- *
4749
- * You could use checkVisibility() but at the time of writing it's not supported across
4750
- * all Browsers
4751
- *
4752
- * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility
4753
- */
4754
- return;
4755
- }
4756
- if (!isInDocument(this._element)) {
4757
- /**
4758
- * since the event is dispatched through requestAnimationFrame there is a small chance
4759
- * the component is no longer attached to the DOM, if that is the case the dimensions
4760
- * are mostly likely all zero and meaningless. we should skip this case.
4761
- */
4762
- return;
4763
- }
4764
- const { width, height } = entry.contentRect;
4765
- this.layout(width, height);
4766
- }));
4351
+ hide() {
4352
+ this.element.style.display = 'none';
4353
+ }
4354
+ renderPanel(panel, options = { asActive: true }) {
4355
+ const doRender = options.asActive ||
4356
+ (this.panel && this.group.isPanelActive(this.panel));
4357
+ if (this.panel &&
4358
+ this.panel.view.content.element.parentElement === this._element) {
4359
+ /**
4360
+ * If the currently attached panel is mounted directly to the content then remove it
4361
+ */
4362
+ this._element.removeChild(this.panel.view.content.element);
4363
+ }
4364
+ this.panel = panel;
4365
+ let container;
4366
+ switch (panel.api.renderer) {
4367
+ case 'onlyWhenVisible':
4368
+ this.group.renderContainer.detatch(panel);
4369
+ if (this.panel) {
4370
+ if (doRender) {
4371
+ this._element.appendChild(this.panel.view.content.element);
4372
+ }
4373
+ }
4374
+ container = this._element;
4375
+ break;
4376
+ case 'always':
4377
+ if (panel.view.content.element.parentElement === this._element) {
4378
+ this._element.removeChild(panel.view.content.element);
4379
+ }
4380
+ container = this.group.renderContainer.attach({
4381
+ panel,
4382
+ referenceContainer: this,
4383
+ });
4384
+ break;
4385
+ }
4386
+ if (doRender) {
4387
+ const focusTracker = trackFocus(container);
4388
+ const disposable = new CompositeDisposable();
4389
+ disposable.addDisposables(focusTracker, focusTracker.onDidFocus(() => this._onDidFocus.fire()), focusTracker.onDidBlur(() => this._onDidBlur.fire()));
4390
+ this.disposable.value = disposable;
4391
+ }
4767
4392
  }
4768
- }
4769
-
4770
- const nextLayoutId$1 = sequentialNumberGenerator();
4771
- function toTarget(direction) {
4772
- switch (direction) {
4773
- case 'left':
4774
- return 'left';
4775
- case 'right':
4776
- return 'right';
4777
- case 'above':
4778
- return 'top';
4779
- case 'below':
4780
- return 'bottom';
4781
- case 'within':
4782
- default:
4783
- return 'center';
4393
+ openPanel(panel) {
4394
+ if (this.panel === panel) {
4395
+ return;
4396
+ }
4397
+ this.renderPanel(panel);
4784
4398
  }
4785
- }
4786
- class BaseGrid extends Resizable {
4787
- get id() {
4788
- return this._id;
4399
+ layout(_width, _height) {
4400
+ // noop
4789
4401
  }
4790
- get size() {
4791
- return this._groups.size;
4402
+ closePanel() {
4403
+ var _a;
4404
+ if (this.panel) {
4405
+ if (this.panel.api.renderer === 'onlyWhenVisible') {
4406
+ (_a = this.panel.view.content.element.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(this.panel.view.content.element);
4407
+ }
4408
+ }
4409
+ this.panel = undefined;
4792
4410
  }
4793
- get groups() {
4794
- return Array.from(this._groups.values()).map((_) => _.value);
4411
+ dispose() {
4412
+ this.disposable.dispose();
4413
+ super.dispose();
4795
4414
  }
4796
- get width() {
4797
- return this.gridview.width;
4415
+ }
4416
+
4417
+ class TabDragHandler extends DragHandler {
4418
+ constructor(element, accessor, group, panel) {
4419
+ super(element);
4420
+ this.accessor = accessor;
4421
+ this.group = group;
4422
+ this.panel = panel;
4423
+ this.panelTransfer = LocalSelectionTransfer.getInstance();
4798
4424
  }
4799
- get height() {
4800
- return this.gridview.height;
4425
+ getData(event) {
4426
+ this.panelTransfer.setData([new PanelTransfer(this.accessor.id, this.group.id, this.panel.id)], PanelTransfer.prototype);
4427
+ return {
4428
+ dispose: () => {
4429
+ this.panelTransfer.clearData(PanelTransfer.prototype);
4430
+ },
4431
+ };
4801
4432
  }
4802
- get minimumHeight() {
4803
- return this.gridview.minimumHeight;
4433
+ }
4434
+ class Tab extends CompositeDisposable {
4435
+ get element() {
4436
+ return this._element;
4804
4437
  }
4805
- get maximumHeight() {
4806
- return this.gridview.maximumHeight;
4438
+ constructor(panel, accessor, group) {
4439
+ super();
4440
+ this.panel = panel;
4441
+ this.accessor = accessor;
4442
+ this.group = group;
4443
+ this.content = undefined;
4444
+ this._onChanged = new Emitter();
4445
+ this.onChanged = this._onChanged.event;
4446
+ this._onDropped = new Emitter();
4447
+ this.onDrop = this._onDropped.event;
4448
+ this._onDragStart = new Emitter();
4449
+ this.onDragStart = this._onDragStart.event;
4450
+ this._element = document.createElement('div');
4451
+ this._element.className = 'tab';
4452
+ this._element.tabIndex = 0;
4453
+ this._element.draggable = true;
4454
+ toggleClass(this.element, 'inactive-tab', true);
4455
+ const dragHandler = new TabDragHandler(this._element, this.accessor, this.group, this.panel);
4456
+ this.dropTarget = new Droptarget(this._element, {
4457
+ acceptedTargetZones: ['center'],
4458
+ canDisplayOverlay: (event, position) => {
4459
+ if (this.group.locked) {
4460
+ return false;
4461
+ }
4462
+ const data = getPanelData();
4463
+ if (data && this.accessor.id === data.viewId) {
4464
+ if (data.panelId === null &&
4465
+ data.groupId === this.group.id) {
4466
+ // don't allow group move to drop on self
4467
+ return false;
4468
+ }
4469
+ return this.panel.id !== data.panelId;
4470
+ }
4471
+ return this.group.model.canDisplayOverlay(event, position, 'tab');
4472
+ },
4473
+ });
4474
+ this.onWillShowOverlay = this.dropTarget.onWillShowOverlay;
4475
+ this.addDisposables(this._onChanged, this._onDropped, this._onDragStart, dragHandler.onDragStart((event) => {
4476
+ this._onDragStart.fire(event);
4477
+ }), dragHandler, addDisposableListener(this._element, 'mousedown', (event) => {
4478
+ if (event.defaultPrevented) {
4479
+ return;
4480
+ }
4481
+ this._onChanged.fire(event);
4482
+ }), this.dropTarget.onDrop((event) => {
4483
+ this._onDropped.fire(event);
4484
+ }), this.dropTarget);
4807
4485
  }
4808
- get minimumWidth() {
4809
- return this.gridview.minimumWidth;
4486
+ setActive(isActive) {
4487
+ toggleClass(this.element, 'active-tab', isActive);
4488
+ toggleClass(this.element, 'inactive-tab', !isActive);
4810
4489
  }
4811
- get maximumWidth() {
4812
- return this.gridview.maximumWidth;
4490
+ setContent(part) {
4491
+ if (this.content) {
4492
+ this._element.removeChild(this.content.element);
4493
+ }
4494
+ this.content = part;
4495
+ this._element.appendChild(this.content.element);
4813
4496
  }
4814
- get activeGroup() {
4815
- return this._activeGroup;
4497
+ dispose() {
4498
+ super.dispose();
4816
4499
  }
4817
- get locked() {
4818
- return this.gridview.locked;
4500
+ }
4501
+
4502
+ function addGhostImage(dataTransfer, ghostElement) {
4503
+ // class dockview provides to force ghost image to be drawn on a different layer and prevent weird rendering issues
4504
+ addClasses(ghostElement, 'dv-dragged');
4505
+ document.body.appendChild(ghostElement);
4506
+ dataTransfer.setDragImage(ghostElement, 0, 0);
4507
+ setTimeout(() => {
4508
+ removeClasses(ghostElement, 'dv-dragged');
4509
+ ghostElement.remove();
4510
+ }, 0);
4511
+ }
4512
+
4513
+ class GroupDragHandler extends DragHandler {
4514
+ constructor(element, accessor, group) {
4515
+ super(element);
4516
+ this.accessor = accessor;
4517
+ this.group = group;
4518
+ this.panelTransfer = LocalSelectionTransfer.getInstance();
4519
+ this.addDisposables(addDisposableListener(element, 'mousedown', (e) => {
4520
+ if (e.shiftKey) {
4521
+ /**
4522
+ * You cannot call e.preventDefault() because that will prevent drag events from firing
4523
+ * but we also need to stop any group overlay drag events from occuring
4524
+ * Use a custom event marker that can be checked by the overlay drag events
4525
+ */
4526
+ quasiPreventDefault(e);
4527
+ }
4528
+ }, true));
4819
4529
  }
4820
- set locked(value) {
4821
- this.gridview.locked = value;
4530
+ isCancelled(_event) {
4531
+ if (this.group.api.location.type === 'floating' && !_event.shiftKey) {
4532
+ return true;
4533
+ }
4534
+ return false;
4822
4535
  }
4823
- constructor(options) {
4824
- super(document.createElement('div'), options.disableAutoResizing);
4825
- this._id = nextLayoutId$1.next();
4826
- this._groups = new Map();
4827
- this._onDidLayoutChange = new Emitter();
4828
- this.onDidLayoutChange = this._onDidLayoutChange.event;
4829
- this._onDidRemove = new Emitter();
4830
- this.onDidRemove = this._onDidRemove.event;
4831
- this._onDidAdd = new Emitter();
4832
- this.onDidAdd = this._onDidAdd.event;
4833
- this._onDidActiveChange = new Emitter();
4834
- this.onDidActiveChange = this._onDidActiveChange.event;
4835
- this._bufferOnDidLayoutChange = new TickDelayedEvent();
4836
- this.element.style.height = '100%';
4837
- this.element.style.width = '100%';
4838
- options.parentElement.appendChild(this.element);
4839
- this.gridview = new Gridview(!!options.proportionalLayout, options.styles, options.orientation);
4840
- this.gridview.locked = !!options.locked;
4841
- this.element.appendChild(this.gridview.element);
4842
- this.layout(0, 0, true); // set some elements height/widths
4843
- this.addDisposables(Disposable.from(() => {
4844
- var _a;
4845
- (_a = this.element.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(this.element);
4846
- }), this.gridview.onDidChange(() => {
4847
- this._bufferOnDidLayoutChange.fire();
4848
- }), exports.DockviewEvent.any(this.onDidAdd, this.onDidRemove, this.onDidActiveChange)(() => {
4849
- this._bufferOnDidLayoutChange.fire();
4850
- }), this._bufferOnDidLayoutChange.onEvent(() => {
4851
- this._onDidLayoutChange.fire();
4852
- }), this._bufferOnDidLayoutChange);
4536
+ getData(dragEvent) {
4537
+ const dataTransfer = dragEvent.dataTransfer;
4538
+ this.panelTransfer.setData([new PanelTransfer(this.accessor.id, this.group.id, null)], PanelTransfer.prototype);
4539
+ const style = window.getComputedStyle(this.el);
4540
+ const bgColor = style.getPropertyValue('--dv-activegroup-visiblepanel-tab-background-color');
4541
+ const color = style.getPropertyValue('--dv-activegroup-visiblepanel-tab-color');
4542
+ if (dataTransfer) {
4543
+ const ghostElement = document.createElement('div');
4544
+ ghostElement.style.backgroundColor = bgColor;
4545
+ ghostElement.style.color = color;
4546
+ ghostElement.style.padding = '2px 8px';
4547
+ ghostElement.style.height = '24px';
4548
+ ghostElement.style.fontSize = '11px';
4549
+ ghostElement.style.lineHeight = '20px';
4550
+ ghostElement.style.borderRadius = '12px';
4551
+ ghostElement.style.position = 'absolute';
4552
+ ghostElement.textContent = `Multiple Panels (${this.group.size})`;
4553
+ addGhostImage(dataTransfer, ghostElement);
4554
+ }
4555
+ return {
4556
+ dispose: () => {
4557
+ this.panelTransfer.clearData(PanelTransfer.prototype);
4558
+ },
4559
+ };
4853
4560
  }
4854
- setVisible(panel, visible) {
4855
- this.gridview.setViewVisible(getGridLocation(panel.element), visible);
4856
- this._onDidLayoutChange.fire();
4561
+ }
4562
+
4563
+ class VoidContainer extends CompositeDisposable {
4564
+ get element() {
4565
+ return this._element;
4857
4566
  }
4858
- isVisible(panel) {
4859
- return this.gridview.isViewVisible(getGridLocation(panel.element));
4567
+ constructor(accessor, group) {
4568
+ super();
4569
+ this.accessor = accessor;
4570
+ this.group = group;
4571
+ this._onDrop = new Emitter();
4572
+ this.onDrop = this._onDrop.event;
4573
+ this._onDragStart = new Emitter();
4574
+ this.onDragStart = this._onDragStart.event;
4575
+ this._element = document.createElement('div');
4576
+ this._element.className = 'void-container';
4577
+ this._element.tabIndex = 0;
4578
+ this._element.draggable = true;
4579
+ this.addDisposables(this._onDrop, this._onDragStart, addDisposableListener(this._element, 'click', () => {
4580
+ this.accessor.doSetGroupActive(this.group);
4581
+ }));
4582
+ const handler = new GroupDragHandler(this._element, accessor, group);
4583
+ this.dropTraget = new Droptarget(this._element, {
4584
+ acceptedTargetZones: ['center'],
4585
+ canDisplayOverlay: (event, position) => {
4586
+ var _a;
4587
+ const data = getPanelData();
4588
+ if (data && this.accessor.id === data.viewId) {
4589
+ if (data.panelId === null &&
4590
+ data.groupId === this.group.id) {
4591
+ // don't allow group move to drop on self
4592
+ return false;
4593
+ }
4594
+ // don't show the overlay if the tab being dragged is the last panel of this group
4595
+ return ((_a = last(this.group.panels)) === null || _a === void 0 ? void 0 : _a.id) !== data.panelId;
4596
+ }
4597
+ return group.model.canDisplayOverlay(event, position, 'header_space');
4598
+ },
4599
+ });
4600
+ this.onWillShowOverlay = this.dropTraget.onWillShowOverlay;
4601
+ this.addDisposables(handler, handler.onDragStart((event) => {
4602
+ this._onDragStart.fire(event);
4603
+ }), this.dropTraget.onDrop((event) => {
4604
+ this._onDrop.fire(event);
4605
+ }), this.dropTraget);
4860
4606
  }
4861
- maximizeGroup(panel) {
4862
- this.gridview.maximizeView(panel);
4863
- this.doSetGroupActive(panel);
4607
+ }
4608
+
4609
+ class TabsContainer extends CompositeDisposable {
4610
+ get panels() {
4611
+ return this.tabs.map((_) => _.value.panel.id);
4864
4612
  }
4865
- isMaximizedGroup(panel) {
4866
- return this.gridview.maximizedView() === panel;
4613
+ get size() {
4614
+ return this.tabs.length;
4867
4615
  }
4868
- exitMaximizedGroup() {
4869
- this.gridview.exitMaximizedView();
4616
+ get hidden() {
4617
+ return this._hidden;
4870
4618
  }
4871
- hasMaximizedGroup() {
4872
- return this.gridview.hasMaximizedView();
4619
+ set hidden(value) {
4620
+ this._hidden = value;
4621
+ this.element.style.display = value ? 'none' : '';
4873
4622
  }
4874
- get onDidMaximizedGroupChange() {
4875
- return this.gridview.onDidMaximizedNodeChange;
4623
+ show() {
4624
+ if (!this.hidden) {
4625
+ this.element.style.display = '';
4626
+ }
4876
4627
  }
4877
- doAddGroup(group, location = [0], size) {
4878
- this.gridview.addView(group, size !== null && size !== void 0 ? size : exports.Sizing.Distribute, location);
4879
- this._onDidAdd.fire(group);
4628
+ hide() {
4629
+ this._element.style.display = 'none';
4880
4630
  }
4881
- doRemoveGroup(group, options) {
4882
- if (!this._groups.has(group.id)) {
4883
- throw new Error('invalid operation');
4631
+ setRightActionsElement(element) {
4632
+ if (this.rightActions === element) {
4633
+ return;
4884
4634
  }
4885
- const item = this._groups.get(group.id);
4886
- const view = this.gridview.remove(group, exports.Sizing.Distribute);
4887
- if (item && !(options === null || options === void 0 ? void 0 : options.skipDispose)) {
4888
- item.disposable.dispose();
4889
- item.value.dispose();
4890
- this._groups.delete(group.id);
4891
- this._onDidRemove.fire(group);
4635
+ if (this.rightActions) {
4636
+ this.rightActions.remove();
4637
+ this.rightActions = undefined;
4892
4638
  }
4893
- if (!(options === null || options === void 0 ? void 0 : options.skipActive) && this._activeGroup === group) {
4894
- const groups = Array.from(this._groups.values());
4895
- this.doSetGroupActive(groups.length > 0 ? groups[0].value : undefined);
4639
+ if (element) {
4640
+ this.rightActionsContainer.appendChild(element);
4641
+ this.rightActions = element;
4896
4642
  }
4897
- return view;
4898
4643
  }
4899
- getPanel(id) {
4900
- var _a;
4901
- return (_a = this._groups.get(id)) === null || _a === void 0 ? void 0 : _a.value;
4644
+ setLeftActionsElement(element) {
4645
+ if (this.leftActions === element) {
4646
+ return;
4647
+ }
4648
+ if (this.leftActions) {
4649
+ this.leftActions.remove();
4650
+ this.leftActions = undefined;
4651
+ }
4652
+ if (element) {
4653
+ this.leftActionsContainer.appendChild(element);
4654
+ this.leftActions = element;
4655
+ }
4902
4656
  }
4903
- doSetGroupActive(group) {
4904
- if (this._activeGroup === group) {
4657
+ setPrefixActionsElement(element) {
4658
+ if (this.preActions === element) {
4905
4659
  return;
4906
4660
  }
4907
- if (this._activeGroup) {
4908
- this._activeGroup.setActive(false);
4661
+ if (this.preActions) {
4662
+ this.preActions.remove();
4663
+ this.preActions = undefined;
4909
4664
  }
4910
- if (group) {
4911
- group.setActive(true);
4665
+ if (element) {
4666
+ this.preActionsContainer.appendChild(element);
4667
+ this.preActions = element;
4912
4668
  }
4913
- this._activeGroup = group;
4914
- this._onDidActiveChange.fire(group);
4915
4669
  }
4916
- removeGroup(group) {
4917
- this.doRemoveGroup(group);
4670
+ get element() {
4671
+ return this._element;
4918
4672
  }
4919
- moveToNext(options) {
4673
+ isActive(tab) {
4674
+ return (this.selectedIndex > -1 &&
4675
+ this.tabs[this.selectedIndex].value === tab);
4676
+ }
4677
+ indexOf(id) {
4678
+ return this.tabs.findIndex((tab) => tab.value.panel.id === id);
4679
+ }
4680
+ constructor(accessor, group) {
4681
+ super();
4682
+ this.accessor = accessor;
4683
+ this.group = group;
4684
+ this.tabs = [];
4685
+ this.selectedIndex = -1;
4686
+ this._hidden = false;
4687
+ this._onDrop = new Emitter();
4688
+ this.onDrop = this._onDrop.event;
4689
+ this._onTabDragStart = new Emitter();
4690
+ this.onTabDragStart = this._onTabDragStart.event;
4691
+ this._onGroupDragStart = new Emitter();
4692
+ this.onGroupDragStart = this._onGroupDragStart.event;
4693
+ this._onWillShowOverlay = new Emitter();
4694
+ this.onWillShowOverlay = this._onWillShowOverlay.event;
4695
+ this._element = document.createElement('div');
4696
+ this._element.className = 'tabs-and-actions-container';
4697
+ toggleClass(this._element, 'dv-full-width-single-tab', this.accessor.options.singleTabMode === 'fullwidth');
4698
+ this.rightActionsContainer = document.createElement('div');
4699
+ this.rightActionsContainer.className = 'right-actions-container';
4700
+ this.leftActionsContainer = document.createElement('div');
4701
+ this.leftActionsContainer.className = 'left-actions-container';
4702
+ this.preActionsContainer = document.createElement('div');
4703
+ this.preActionsContainer.className = 'pre-actions-container';
4704
+ this.tabContainer = document.createElement('div');
4705
+ this.tabContainer.className = 'tabs-container';
4706
+ this.voidContainer = new VoidContainer(this.accessor, this.group);
4707
+ this._element.appendChild(this.preActionsContainer);
4708
+ this._element.appendChild(this.tabContainer);
4709
+ this._element.appendChild(this.leftActionsContainer);
4710
+ this._element.appendChild(this.voidContainer.element);
4711
+ this._element.appendChild(this.rightActionsContainer);
4712
+ this.addDisposables(this.accessor.onDidAddPanel((e) => {
4713
+ if (e.api.group === this.group) {
4714
+ toggleClass(this._element, 'dv-single-tab', this.size === 1);
4715
+ }
4716
+ }), this.accessor.onDidRemovePanel((e) => {
4717
+ if (e.api.group === this.group) {
4718
+ toggleClass(this._element, 'dv-single-tab', this.size === 1);
4719
+ }
4720
+ }), this._onWillShowOverlay, this._onDrop, this._onTabDragStart, this._onGroupDragStart, this.voidContainer, this.voidContainer.onDragStart((event) => {
4721
+ this._onGroupDragStart.fire({
4722
+ nativeEvent: event,
4723
+ group: this.group,
4724
+ });
4725
+ }), this.voidContainer.onDrop((event) => {
4726
+ this._onDrop.fire({
4727
+ event: event.nativeEvent,
4728
+ index: this.tabs.length,
4729
+ });
4730
+ }), this.voidContainer.onWillShowOverlay((event) => {
4731
+ this._onWillShowOverlay.fire(new WillShowOverlayLocationEvent(event, {
4732
+ kind: 'header_space',
4733
+ panel: this.group.activePanel,
4734
+ api: this.accessor.api,
4735
+ group: this.group,
4736
+ getData: getPanelData,
4737
+ }));
4738
+ }), addDisposableListener(this.voidContainer.element, 'mousedown', (event) => {
4739
+ const isFloatingGroupsEnabled = !this.accessor.options.disableFloatingGroups;
4740
+ if (isFloatingGroupsEnabled &&
4741
+ event.shiftKey &&
4742
+ this.group.api.location.type !== 'floating') {
4743
+ event.preventDefault();
4744
+ const { top, left } = this.element.getBoundingClientRect();
4745
+ const { top: rootTop, left: rootLeft } = this.accessor.element.getBoundingClientRect();
4746
+ this.accessor.addFloatingGroup(this.group, {
4747
+ x: left - rootLeft + 20,
4748
+ y: top - rootTop + 20,
4749
+ }, { inDragMode: true });
4750
+ }
4751
+ }), addDisposableListener(this.tabContainer, 'mousedown', (event) => {
4752
+ if (event.defaultPrevented) {
4753
+ return;
4754
+ }
4755
+ const isLeftClick = event.button === 0;
4756
+ if (isLeftClick) {
4757
+ this.accessor.doSetGroupActive(this.group);
4758
+ }
4759
+ }));
4760
+ }
4761
+ setActive(_isGroupActive) {
4762
+ // noop
4763
+ }
4764
+ addTab(tab, index = this.tabs.length) {
4765
+ if (index < 0 || index > this.tabs.length) {
4766
+ throw new Error('invalid location');
4767
+ }
4768
+ this.tabContainer.insertBefore(tab.value.element, this.tabContainer.children[index]);
4769
+ this.tabs = [
4770
+ ...this.tabs.slice(0, index),
4771
+ tab,
4772
+ ...this.tabs.slice(index),
4773
+ ];
4774
+ if (this.selectedIndex < 0) {
4775
+ this.selectedIndex = index;
4776
+ }
4777
+ }
4778
+ delete(id) {
4779
+ const index = this.tabs.findIndex((tab) => tab.value.panel.id === id);
4780
+ const tabToRemove = this.tabs.splice(index, 1)[0];
4781
+ const { value, disposable } = tabToRemove;
4782
+ disposable.dispose();
4783
+ value.dispose();
4784
+ value.element.remove();
4785
+ }
4786
+ setActivePanel(panel) {
4787
+ this.tabs.forEach((tab) => {
4788
+ const isActivePanel = panel.id === tab.value.panel.id;
4789
+ tab.value.setActive(isActivePanel);
4790
+ });
4791
+ }
4792
+ openPanel(panel, index = this.tabs.length) {
4920
4793
  var _a;
4921
- if (!options) {
4922
- options = {};
4794
+ if (this.tabs.find((tab) => tab.value.panel.id === panel.id)) {
4795
+ return;
4923
4796
  }
4924
- if (!options.group) {
4925
- if (!this.activeGroup) {
4797
+ const tab = new Tab(panel, this.accessor, this.group);
4798
+ if (!((_a = panel.view) === null || _a === void 0 ? void 0 : _a.tab)) {
4799
+ throw new Error('invalid header component');
4800
+ }
4801
+ tab.setContent(panel.view.tab);
4802
+ const disposable = new CompositeDisposable(tab.onDragStart((event) => {
4803
+ this._onTabDragStart.fire({ nativeEvent: event, panel });
4804
+ }), tab.onChanged((event) => {
4805
+ const isFloatingGroupsEnabled = !this.accessor.options.disableFloatingGroups;
4806
+ const isFloatingWithOnePanel = this.group.api.location.type === 'floating' &&
4807
+ this.size === 1;
4808
+ if (isFloatingGroupsEnabled &&
4809
+ !isFloatingWithOnePanel &&
4810
+ event.shiftKey) {
4811
+ event.preventDefault();
4812
+ const panel = this.accessor.getGroupPanel(tab.panel.id);
4813
+ const { top, left } = tab.element.getBoundingClientRect();
4814
+ const { top: rootTop, left: rootLeft } = this.accessor.element.getBoundingClientRect();
4815
+ this.accessor.addFloatingGroup(panel, {
4816
+ x: left - rootLeft,
4817
+ y: top - rootTop,
4818
+ }, { inDragMode: true });
4926
4819
  return;
4927
4820
  }
4928
- options.group = this.activeGroup;
4929
- }
4930
- const location = getGridLocation(options.group.element);
4931
- const next = (_a = this.gridview.next(location)) === null || _a === void 0 ? void 0 : _a.view;
4932
- this.doSetGroupActive(next);
4933
- }
4934
- moveToPrevious(options) {
4935
- var _a;
4936
- if (!options) {
4937
- options = {};
4938
- }
4939
- if (!options.group) {
4940
- if (!this.activeGroup) {
4821
+ const isLeftClick = event.button === 0;
4822
+ if (!isLeftClick || event.defaultPrevented) {
4941
4823
  return;
4942
4824
  }
4943
- options.group = this.activeGroup;
4944
- }
4945
- const location = getGridLocation(options.group.element);
4946
- const next = (_a = this.gridview.previous(location)) === null || _a === void 0 ? void 0 : _a.view;
4947
- this.doSetGroupActive(next);
4825
+ if (this.group.activePanel !== panel) {
4826
+ this.group.model.openPanel(panel);
4827
+ }
4828
+ }), tab.onDrop((event) => {
4829
+ this._onDrop.fire({
4830
+ event: event.nativeEvent,
4831
+ index: this.tabs.findIndex((x) => x.value === tab),
4832
+ });
4833
+ }), tab.onWillShowOverlay((event) => {
4834
+ this._onWillShowOverlay.fire(new WillShowOverlayLocationEvent(event, {
4835
+ kind: 'tab',
4836
+ panel: this.group.activePanel,
4837
+ api: this.accessor.api,
4838
+ group: this.group,
4839
+ getData: getPanelData,
4840
+ }));
4841
+ }));
4842
+ const value = { value: tab, disposable };
4843
+ this.addTab(value, index);
4948
4844
  }
4949
- layout(width, height, forceResize) {
4950
- const different = forceResize !== null && forceResize !== void 0 ? forceResize : (width !== this.width || height !== this.height);
4951
- if (!different) {
4952
- return;
4953
- }
4954
- this.gridview.element.style.height = `${height}px`;
4955
- this.gridview.element.style.width = `${width}px`;
4956
- this.gridview.layout(width, height);
4845
+ closePanel(panel) {
4846
+ this.delete(panel.id);
4957
4847
  }
4958
4848
  dispose() {
4959
- this._onDidActiveChange.dispose();
4960
- this._onDidAdd.dispose();
4961
- this._onDidRemove.dispose();
4962
- this._onDidLayoutChange.dispose();
4963
- for (const group of this.groups) {
4964
- group.dispose();
4965
- }
4966
- this.gridview.dispose();
4967
4849
  super.dispose();
4850
+ for (const { value, disposable } of this.tabs) {
4851
+ disposable.dispose();
4852
+ value.dispose();
4853
+ }
4854
+ this.tabs = [];
4968
4855
  }
4969
4856
  }
4970
4857
 
4971
- class WillFocusEvent extends DockviewEvent {
4972
- constructor() {
4973
- super();
4858
+ class DockviewUnhandledDragOverEvent {
4859
+ get isAccepted() {
4860
+ return this._isAccepted;
4861
+ }
4862
+ constructor(nativeEvent, target, position, getData, group) {
4863
+ this.nativeEvent = nativeEvent;
4864
+ this.target = target;
4865
+ this.position = position;
4866
+ this.getData = getData;
4867
+ this.group = group;
4868
+ this._isAccepted = false;
4869
+ }
4870
+ accept() {
4871
+ this._isAccepted = true;
4974
4872
  }
4975
4873
  }
4976
- /**
4977
- * A core api implementation that should be used across all panel-like objects
4978
- */
4979
- class PanelApiImpl extends CompositeDisposable {
4980
- get isFocused() {
4981
- return this._isFocused;
4874
+ const PROPERTY_KEYS = (() => {
4875
+ /**
4876
+ * by readong the keys from an empty value object TypeScript will error
4877
+ * when we add or remove new properties to `DockviewOptions`
4878
+ */
4879
+ const properties = {
4880
+ disableAutoResizing: undefined,
4881
+ hideBorders: undefined,
4882
+ singleTabMode: undefined,
4883
+ disableFloatingGroups: undefined,
4884
+ floatingGroupBounds: undefined,
4885
+ popoutUrl: undefined,
4886
+ defaultRenderer: undefined,
4887
+ debug: undefined,
4888
+ rootOverlayModel: undefined,
4889
+ locked: undefined,
4890
+ disableDnd: undefined,
4891
+ };
4892
+ return Object.keys(properties);
4893
+ })();
4894
+ function isPanelOptionsWithPanel(data) {
4895
+ if (data.referencePanel) {
4896
+ return true;
4982
4897
  }
4983
- get isActive() {
4984
- return this._isActive;
4898
+ return false;
4899
+ }
4900
+ function isPanelOptionsWithGroup(data) {
4901
+ if (data.referenceGroup) {
4902
+ return true;
4985
4903
  }
4986
- get isVisible() {
4987
- return this._isVisible;
4904
+ return false;
4905
+ }
4906
+ function isGroupOptionsWithPanel(data) {
4907
+ if (data.referencePanel) {
4908
+ return true;
4988
4909
  }
4989
- get width() {
4990
- return this._width;
4910
+ return false;
4911
+ }
4912
+ function isGroupOptionsWithGroup(data) {
4913
+ if (data.referenceGroup) {
4914
+ return true;
4991
4915
  }
4992
- get height() {
4993
- return this._height;
4916
+ return false;
4917
+ }
4918
+
4919
+ class DockviewDidDropEvent extends DockviewEvent {
4920
+ get nativeEvent() {
4921
+ return this.options.nativeEvent;
4994
4922
  }
4995
- constructor(id, component) {
4996
- super();
4997
- this.id = id;
4998
- this.component = component;
4999
- this._isFocused = false;
5000
- this._isActive = false;
5001
- this._isVisible = true;
5002
- this._width = 0;
5003
- this._height = 0;
5004
- this._parameters = {};
5005
- this.panelUpdatesDisposable = new MutableDisposable();
5006
- this._onDidDimensionChange = new Emitter();
5007
- this.onDidDimensionsChange = this._onDidDimensionChange.event;
5008
- this._onDidChangeFocus = new Emitter();
5009
- this.onDidFocusChange = this._onDidChangeFocus.event;
5010
- //
5011
- this._onWillFocus = new Emitter();
5012
- this.onWillFocus = this._onWillFocus.event;
5013
- //
5014
- this._onDidVisibilityChange = new Emitter();
5015
- this.onDidVisibilityChange = this._onDidVisibilityChange.event;
5016
- this._onWillVisibilityChange = new Emitter();
5017
- this.onWillVisibilityChange = this._onWillVisibilityChange.event;
5018
- this._onDidActiveChange = new Emitter();
5019
- this.onDidActiveChange = this._onDidActiveChange.event;
5020
- this._onActiveChange = new Emitter();
5021
- this.onActiveChange = this._onActiveChange.event;
5022
- this._onDidParametersChange = new Emitter();
5023
- this.onDidParametersChange = this._onDidParametersChange.event;
5024
- this.addDisposables(this.onDidFocusChange((event) => {
5025
- this._isFocused = event.isFocused;
5026
- }), this.onDidActiveChange((event) => {
5027
- this._isActive = event.isActive;
5028
- }), this.onDidVisibilityChange((event) => {
5029
- this._isVisible = event.isVisible;
5030
- }), this.onDidDimensionsChange((event) => {
5031
- this._width = event.width;
5032
- this._height = event.height;
5033
- }), this.panelUpdatesDisposable, this._onDidDimensionChange, this._onDidChangeFocus, this._onDidVisibilityChange, this._onDidActiveChange, this._onWillFocus, this._onActiveChange, this._onWillFocus, this._onWillVisibilityChange, this._onDidParametersChange);
4923
+ get position() {
4924
+ return this.options.position;
5034
4925
  }
5035
- getParameters() {
5036
- return this._parameters;
4926
+ get panel() {
4927
+ return this.options.panel;
5037
4928
  }
5038
- initialize(panel) {
5039
- this.panelUpdatesDisposable.value = this._onDidParametersChange.event((parameters) => {
5040
- this._parameters = parameters;
5041
- panel.update({
5042
- params: parameters,
5043
- });
5044
- });
4929
+ get group() {
4930
+ return this.options.group;
5045
4931
  }
5046
- setVisible(isVisible) {
5047
- this._onWillVisibilityChange.fire({ isVisible });
4932
+ get api() {
4933
+ return this.options.api;
5048
4934
  }
5049
- setActive() {
5050
- this._onActiveChange.fire();
4935
+ constructor(options) {
4936
+ super();
4937
+ this.options = options;
5051
4938
  }
5052
- updateParameters(parameters) {
5053
- this._onDidParametersChange.fire(parameters);
4939
+ getData() {
4940
+ return this.options.getData();
5054
4941
  }
5055
4942
  }
5056
-
5057
- class SplitviewPanelApiImpl extends PanelApiImpl {
5058
- //
5059
- constructor(id, component) {
5060
- super(id, component);
5061
- this._onDidConstraintsChangeInternal = new Emitter();
5062
- this.onDidConstraintsChangeInternal = this._onDidConstraintsChangeInternal.event;
5063
- //
5064
- this._onDidConstraintsChange = new Emitter({
5065
- replay: true,
5066
- });
5067
- this.onDidConstraintsChange = this._onDidConstraintsChange.event;
5068
- //
5069
- this._onDidSizeChange = new Emitter();
5070
- this.onDidSizeChange = this._onDidSizeChange.event;
5071
- this.addDisposables(this._onDidConstraintsChangeInternal, this._onDidConstraintsChange, this._onDidSizeChange);
5072
- }
5073
- setConstraints(value) {
5074
- this._onDidConstraintsChangeInternal.fire(value);
4943
+ class DockviewWillDropEvent extends DockviewDidDropEvent {
4944
+ get kind() {
4945
+ return this._kind;
5075
4946
  }
5076
- setSize(event) {
5077
- this._onDidSizeChange.fire(event);
4947
+ constructor(options) {
4948
+ super(options);
4949
+ this._kind = options.kind;
5078
4950
  }
5079
4951
  }
5080
-
5081
- class PaneviewPanelApiImpl extends SplitviewPanelApiImpl {
5082
- set pane(pane) {
5083
- this._pane = pane;
4952
+ class WillShowOverlayLocationEvent {
4953
+ get kind() {
4954
+ return this.options.kind;
5084
4955
  }
5085
- constructor(id, component) {
5086
- super(id, component);
5087
- this._onDidExpansionChange = new Emitter({
5088
- replay: true,
5089
- });
5090
- this.onDidExpansionChange = this._onDidExpansionChange.event;
5091
- this._onMouseEnter = new Emitter({});
5092
- this.onMouseEnter = this._onMouseEnter.event;
5093
- this._onMouseLeave = new Emitter({});
5094
- this.onMouseLeave = this._onMouseLeave.event;
5095
- this.addDisposables(this._onDidExpansionChange, this._onMouseEnter, this._onMouseLeave);
4956
+ get nativeEvent() {
4957
+ return this.event.nativeEvent;
5096
4958
  }
5097
- setExpanded(isExpanded) {
5098
- var _a;
5099
- (_a = this._pane) === null || _a === void 0 ? void 0 : _a.setExpanded(isExpanded);
4959
+ get position() {
4960
+ return this.event.position;
5100
4961
  }
5101
- get isExpanded() {
5102
- var _a;
5103
- return !!((_a = this._pane) === null || _a === void 0 ? void 0 : _a.isExpanded());
4962
+ get defaultPrevented() {
4963
+ return this.event.defaultPrevented;
4964
+ }
4965
+ get panel() {
4966
+ return this.options.panel;
4967
+ }
4968
+ get api() {
4969
+ return this.options.api;
4970
+ }
4971
+ get group() {
4972
+ return this.options.group;
4973
+ }
4974
+ preventDefault() {
4975
+ this.event.preventDefault();
4976
+ }
4977
+ getData() {
4978
+ return this.options.getData();
4979
+ }
4980
+ constructor(event, options) {
4981
+ this.event = event;
4982
+ this.options = options;
5104
4983
  }
5105
4984
  }
5106
-
5107
- class BasePanelView extends CompositeDisposable {
4985
+ class DockviewGroupPanelModel extends CompositeDisposable {
5108
4986
  get element() {
5109
- return this._element;
4987
+ throw new Error('not supported');
5110
4988
  }
5111
- get width() {
5112
- return this._width;
4989
+ get activePanel() {
4990
+ return this._activePanel;
5113
4991
  }
5114
- get height() {
5115
- return this._height;
4992
+ get locked() {
4993
+ return this._locked;
5116
4994
  }
5117
- get params() {
5118
- var _a;
5119
- return (_a = this._params) === null || _a === void 0 ? void 0 : _a.params;
4995
+ set locked(value) {
4996
+ this._locked = value;
4997
+ toggleClass(this.container, 'locked-groupview', value === 'no-drop-target' || value);
5120
4998
  }
5121
- constructor(id, component, api) {
5122
- super();
5123
- this.id = id;
5124
- this.component = component;
5125
- this.api = api;
5126
- this._height = 0;
5127
- this._width = 0;
5128
- this._element = document.createElement('div');
5129
- this._element.tabIndex = -1;
5130
- this._element.style.outline = 'none';
5131
- this._element.style.height = '100%';
5132
- this._element.style.width = '100%';
5133
- this._element.style.overflow = 'hidden';
5134
- const focusTracker = trackFocus(this._element);
5135
- this.addDisposables(this.api, focusTracker.onDidFocus(() => {
5136
- this.api._onDidChangeFocus.fire({ isFocused: true });
5137
- }), focusTracker.onDidBlur(() => {
5138
- this.api._onDidChangeFocus.fire({ isFocused: false });
5139
- }), focusTracker);
4999
+ get isActive() {
5000
+ return this._isGroupActive;
5140
5001
  }
5141
- focus() {
5142
- const event = new WillFocusEvent();
5143
- this.api._onWillFocus.fire(event);
5144
- if (event.defaultPrevented) {
5145
- return;
5146
- }
5147
- this._element.focus();
5002
+ get panels() {
5003
+ return this._panels;
5148
5004
  }
5149
- layout(width, height) {
5150
- this._width = width;
5151
- this._height = height;
5152
- this.api._onDidDimensionChange.fire({ width, height });
5153
- if (this.part) {
5154
- if (this._params) {
5155
- this.part.update(this._params.params);
5156
- }
5157
- }
5005
+ get size() {
5006
+ return this._panels.length;
5158
5007
  }
5159
- init(parameters) {
5160
- this._params = parameters;
5161
- this.part = this.getComponent();
5008
+ get isEmpty() {
5009
+ return this._panels.length === 0;
5162
5010
  }
5163
- update(event) {
5164
- var _a, _b;
5165
- // merge the new parameters with the existing parameters
5166
- 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) });
5167
- /**
5168
- * delete new keys that have a value of undefined,
5169
- * allow values of null
5170
- */
5171
- for (const key of Object.keys(event.params)) {
5172
- if (event.params[key] === undefined) {
5173
- delete this._params.params[key];
5174
- }
5011
+ get hasWatermark() {
5012
+ return !!(this.watermark && this.container.contains(this.watermark.element));
5013
+ }
5014
+ get header() {
5015
+ return this.tabsContainer;
5016
+ }
5017
+ get isContentFocused() {
5018
+ if (!document.activeElement) {
5019
+ return false;
5175
5020
  }
5176
- // update the view with the updated props
5177
- (_b = this.part) === null || _b === void 0 ? void 0 : _b.update({ params: this._params.params });
5021
+ return isAncestor(document.activeElement, this.contentContainer.element);
5178
5022
  }
5179
- toJSON() {
5180
- var _a, _b;
5181
- const params = (_b = (_a = this._params) === null || _a === void 0 ? void 0 : _a.params) !== null && _b !== void 0 ? _b : {};
5182
- return {
5183
- id: this.id,
5184
- component: this.component,
5185
- params: Object.keys(params).length > 0 ? params : undefined,
5186
- };
5023
+ get location() {
5024
+ return this._location;
5187
5025
  }
5188
- dispose() {
5026
+ set location(value) {
5027
+ this._location = value;
5028
+ toggleClass(this.container, 'dv-groupview-floating', false);
5029
+ toggleClass(this.container, 'dv-groupview-popout', false);
5030
+ switch (value.type) {
5031
+ case 'grid':
5032
+ this.contentContainer.dropTarget.setTargetZones([
5033
+ 'top',
5034
+ 'bottom',
5035
+ 'left',
5036
+ 'right',
5037
+ 'center',
5038
+ ]);
5039
+ break;
5040
+ case 'floating':
5041
+ this.contentContainer.dropTarget.setTargetZones(['center']);
5042
+ this.contentContainer.dropTarget.setTargetZones(value
5043
+ ? ['center']
5044
+ : ['top', 'bottom', 'left', 'right', 'center']);
5045
+ toggleClass(this.container, 'dv-groupview-floating', true);
5046
+ break;
5047
+ case 'popout':
5048
+ this.contentContainer.dropTarget.setTargetZones(['center']);
5049
+ toggleClass(this.container, 'dv-groupview-popout', true);
5050
+ break;
5051
+ }
5052
+ this.groupPanel.api._onDidLocationChange.fire({
5053
+ location: this.location,
5054
+ });
5055
+ }
5056
+ constructor(container, accessor, id, options, groupPanel) {
5189
5057
  var _a;
5190
- this.api.dispose();
5191
- (_a = this.part) === null || _a === void 0 ? void 0 : _a.dispose();
5192
- super.dispose();
5058
+ super();
5059
+ this.container = container;
5060
+ this.accessor = accessor;
5061
+ this.id = id;
5062
+ this.options = options;
5063
+ this.groupPanel = groupPanel;
5064
+ this._isGroupActive = false;
5065
+ this._locked = false;
5066
+ this._location = { type: 'grid' };
5067
+ this.mostRecentlyUsed = [];
5068
+ this._onDidChange = new Emitter();
5069
+ this.onDidChange = this._onDidChange.event;
5070
+ this._width = 0;
5071
+ this._height = 0;
5072
+ this._panels = [];
5073
+ this._panelDisposables = new Map();
5074
+ this._onMove = new Emitter();
5075
+ this.onMove = this._onMove.event;
5076
+ this._onDidDrop = new Emitter();
5077
+ this.onDidDrop = this._onDidDrop.event;
5078
+ this._onWillDrop = new Emitter();
5079
+ this.onWillDrop = this._onWillDrop.event;
5080
+ this._onWillShowOverlay = new Emitter();
5081
+ this.onWillShowOverlay = this._onWillShowOverlay.event;
5082
+ this._onTabDragStart = new Emitter();
5083
+ this.onTabDragStart = this._onTabDragStart.event;
5084
+ this._onGroupDragStart = new Emitter();
5085
+ this.onGroupDragStart = this._onGroupDragStart.event;
5086
+ this._onDidAddPanel = new Emitter();
5087
+ this.onDidAddPanel = this._onDidAddPanel.event;
5088
+ this._onDidPanelTitleChange = new Emitter();
5089
+ this.onDidPanelTitleChange = this._onDidPanelTitleChange.event;
5090
+ this._onDidPanelParametersChange = new Emitter();
5091
+ this.onDidPanelParametersChange = this._onDidPanelParametersChange.event;
5092
+ this._onDidRemovePanel = new Emitter();
5093
+ this.onDidRemovePanel = this._onDidRemovePanel.event;
5094
+ this._onDidActivePanelChange = new Emitter();
5095
+ this.onDidActivePanelChange = this._onDidActivePanelChange.event;
5096
+ this._onUnhandledDragOverEvent = new Emitter();
5097
+ this.onUnhandledDragOverEvent = this._onUnhandledDragOverEvent.event;
5098
+ this._overwriteRenderContainer = null;
5099
+ toggleClass(this.container, 'groupview', true);
5100
+ this._api = new DockviewApi(this.accessor);
5101
+ this.tabsContainer = new TabsContainer(this.accessor, this.groupPanel);
5102
+ this.contentContainer = new ContentContainer(this.accessor, this);
5103
+ container.append(this.tabsContainer.element, this.contentContainer.element);
5104
+ this.header.hidden = !!options.hideHeader;
5105
+ this.locked = (_a = options.locked) !== null && _a !== void 0 ? _a : false;
5106
+ this.addDisposables(this._onTabDragStart, this._onGroupDragStart, this._onWillShowOverlay, this.tabsContainer.onTabDragStart((event) => {
5107
+ this._onTabDragStart.fire(event);
5108
+ }), this.tabsContainer.onGroupDragStart((event) => {
5109
+ this._onGroupDragStart.fire(event);
5110
+ }), this.tabsContainer.onDrop((event) => {
5111
+ this.handleDropEvent('header', event.event, 'center', event.index);
5112
+ }), this.contentContainer.onDidFocus(() => {
5113
+ this.accessor.doSetGroupActive(this.groupPanel);
5114
+ }), this.contentContainer.onDidBlur(() => {
5115
+ // noop
5116
+ }), this.contentContainer.dropTarget.onDrop((event) => {
5117
+ this.handleDropEvent('content', event.nativeEvent, event.position);
5118
+ }), this.tabsContainer.onWillShowOverlay((event) => {
5119
+ this._onWillShowOverlay.fire(event);
5120
+ }), this.contentContainer.dropTarget.onWillShowOverlay((event) => {
5121
+ this._onWillShowOverlay.fire(new WillShowOverlayLocationEvent(event, {
5122
+ kind: 'content',
5123
+ panel: this.activePanel,
5124
+ api: this._api,
5125
+ group: this.groupPanel,
5126
+ getData: getPanelData,
5127
+ }));
5128
+ }), this._onMove, this._onDidChange, this._onDidDrop, this._onWillDrop, this._onDidAddPanel, this._onDidRemovePanel, this._onDidActivePanelChange, this._onUnhandledDragOverEvent);
5193
5129
  }
5194
- }
5195
-
5196
- class PaneviewPanel extends BasePanelView {
5197
- set orientation(value) {
5198
- this._orientation = value;
5130
+ focusContent() {
5131
+ this.contentContainer.element.focus();
5199
5132
  }
5200
- get orientation() {
5201
- return this._orientation;
5133
+ set renderContainer(value) {
5134
+ this.panels.forEach((panel) => {
5135
+ this.renderContainer.detatch(panel);
5136
+ });
5137
+ this._overwriteRenderContainer = value;
5138
+ this.panels.forEach((panel) => {
5139
+ this.rerender(panel);
5140
+ });
5141
+ }
5142
+ get renderContainer() {
5143
+ var _a;
5144
+ return ((_a = this._overwriteRenderContainer) !== null && _a !== void 0 ? _a : this.accessor.overlayRenderContainer);
5145
+ }
5146
+ initialize() {
5147
+ if (this.options.panels) {
5148
+ this.options.panels.forEach((panel) => {
5149
+ this.doAddPanel(panel);
5150
+ });
5151
+ }
5152
+ if (this.options.activePanel) {
5153
+ this.openPanel(this.options.activePanel);
5154
+ }
5155
+ // must be run after the constructor otherwise this.parent may not be
5156
+ // correctly initialized
5157
+ this.setActive(this.isActive, true);
5158
+ this.updateContainer();
5159
+ if (this.accessor.options.createRightHeaderActionComponent) {
5160
+ this._rightHeaderActions =
5161
+ this.accessor.options.createRightHeaderActionComponent(this.groupPanel);
5162
+ this.addDisposables(this._rightHeaderActions);
5163
+ this._rightHeaderActions.init({
5164
+ containerApi: this._api,
5165
+ api: this.groupPanel.api,
5166
+ group: this.groupPanel,
5167
+ });
5168
+ this.tabsContainer.setRightActionsElement(this._rightHeaderActions.element);
5169
+ }
5170
+ if (this.accessor.options.createLeftHeaderActionComponent) {
5171
+ this._leftHeaderActions =
5172
+ this.accessor.options.createLeftHeaderActionComponent(this.groupPanel);
5173
+ this.addDisposables(this._leftHeaderActions);
5174
+ this._leftHeaderActions.init({
5175
+ containerApi: this._api,
5176
+ api: this.groupPanel.api,
5177
+ group: this.groupPanel,
5178
+ });
5179
+ this.tabsContainer.setLeftActionsElement(this._leftHeaderActions.element);
5180
+ }
5181
+ if (this.accessor.options.createPrefixHeaderActionComponent) {
5182
+ this._prefixHeaderActions =
5183
+ this.accessor.options.createPrefixHeaderActionComponent(this.groupPanel);
5184
+ this.addDisposables(this._prefixHeaderActions);
5185
+ this._prefixHeaderActions.init({
5186
+ containerApi: this._api,
5187
+ api: this.groupPanel.api,
5188
+ group: this.groupPanel,
5189
+ });
5190
+ this.tabsContainer.setPrefixActionsElement(this._prefixHeaderActions.element);
5191
+ }
5202
5192
  }
5203
- get minimumSize() {
5204
- const headerSize = this.headerSize;
5205
- const expanded = this.isExpanded();
5206
- const minimumBodySize = expanded ? this._minimumBodySize : 0;
5207
- return headerSize + minimumBodySize;
5193
+ rerender(panel) {
5194
+ this.contentContainer.renderPanel(panel, { asActive: false });
5208
5195
  }
5209
- get maximumSize() {
5210
- const headerSize = this.headerSize;
5211
- const expanded = this.isExpanded();
5212
- const maximumBodySize = expanded ? this._maximumBodySize : 0;
5213
- return headerSize + maximumBodySize;
5196
+ indexOf(panel) {
5197
+ return this.tabsContainer.indexOf(panel.id);
5214
5198
  }
5215
- get size() {
5216
- return this._size;
5199
+ toJSON() {
5200
+ var _a;
5201
+ const result = {
5202
+ views: this.tabsContainer.panels,
5203
+ activeView: (_a = this._activePanel) === null || _a === void 0 ? void 0 : _a.id,
5204
+ id: this.id,
5205
+ };
5206
+ if (this.locked !== false) {
5207
+ result.locked = this.locked;
5208
+ }
5209
+ if (this.header.hidden) {
5210
+ result.hideHeader = true;
5211
+ }
5212
+ return result;
5217
5213
  }
5218
- get orthogonalSize() {
5219
- return this._orthogonalSize;
5214
+ moveToNext(options) {
5215
+ if (!options) {
5216
+ options = {};
5217
+ }
5218
+ if (!options.panel) {
5219
+ options.panel = this.activePanel;
5220
+ }
5221
+ const index = options.panel ? this.panels.indexOf(options.panel) : -1;
5222
+ let normalizedIndex;
5223
+ if (index < this.panels.length - 1) {
5224
+ normalizedIndex = index + 1;
5225
+ }
5226
+ else if (!options.suppressRoll) {
5227
+ normalizedIndex = 0;
5228
+ }
5229
+ else {
5230
+ return;
5231
+ }
5232
+ this.openPanel(this.panels[normalizedIndex]);
5220
5233
  }
5221
- set orthogonalSize(size) {
5222
- this._orthogonalSize = size;
5234
+ moveToPrevious(options) {
5235
+ if (!options) {
5236
+ options = {};
5237
+ }
5238
+ if (!options.panel) {
5239
+ options.panel = this.activePanel;
5240
+ }
5241
+ if (!options.panel) {
5242
+ return;
5243
+ }
5244
+ const index = this.panels.indexOf(options.panel);
5245
+ let normalizedIndex;
5246
+ if (index > 0) {
5247
+ normalizedIndex = index - 1;
5248
+ }
5249
+ else if (!options.suppressRoll) {
5250
+ normalizedIndex = this.panels.length - 1;
5251
+ }
5252
+ else {
5253
+ return;
5254
+ }
5255
+ this.openPanel(this.panels[normalizedIndex]);
5223
5256
  }
5224
- get minimumBodySize() {
5225
- return this._minimumBodySize;
5257
+ containsPanel(panel) {
5258
+ return this.panels.includes(panel);
5226
5259
  }
5227
- set minimumBodySize(value) {
5228
- this._minimumBodySize = typeof value === 'number' ? value : 0;
5260
+ init(_params) {
5261
+ //noop
5229
5262
  }
5230
- get maximumBodySize() {
5231
- return this._maximumBodySize;
5263
+ update(_params) {
5264
+ //noop
5232
5265
  }
5233
- set maximumBodySize(value) {
5234
- this._maximumBodySize =
5235
- typeof value === 'number' ? value : Number.POSITIVE_INFINITY;
5266
+ focus() {
5267
+ var _a;
5268
+ (_a = this._activePanel) === null || _a === void 0 ? void 0 : _a.focus();
5236
5269
  }
5237
- get headerVisible() {
5238
- return this._headerVisible;
5270
+ openPanel(panel, options = {}) {
5271
+ /**
5272
+ * set the panel group
5273
+ * add the panel
5274
+ * check if group active
5275
+ * check if panel active
5276
+ */
5277
+ if (typeof options.index !== 'number' ||
5278
+ options.index > this.panels.length) {
5279
+ options.index = this.panels.length;
5280
+ }
5281
+ const skipSetActive = !!options.skipSetActive;
5282
+ // ensure the group is updated before we fire any events
5283
+ panel.updateParentGroup(this.groupPanel, {
5284
+ skipSetActive: options.skipSetActive,
5285
+ });
5286
+ this.doAddPanel(panel, options.index, {
5287
+ skipSetActive: skipSetActive,
5288
+ });
5289
+ if (this._activePanel === panel) {
5290
+ this.contentContainer.renderPanel(panel, { asActive: true });
5291
+ return;
5292
+ }
5293
+ if (!skipSetActive) {
5294
+ this.doSetActivePanel(panel);
5295
+ }
5296
+ if (!options.skipSetGroupActive) {
5297
+ this.accessor.doSetGroupActive(this.groupPanel);
5298
+ }
5299
+ if (!options.skipSetActive) {
5300
+ this.updateContainer();
5301
+ }
5239
5302
  }
5240
- set headerVisible(value) {
5241
- this._headerVisible = value;
5242
- this.header.style.display = value ? '' : 'none';
5303
+ removePanel(groupItemOrId, options = {
5304
+ skipSetActive: false,
5305
+ }) {
5306
+ const id = typeof groupItemOrId === 'string'
5307
+ ? groupItemOrId
5308
+ : groupItemOrId.id;
5309
+ const panelToRemove = this._panels.find((panel) => panel.id === id);
5310
+ if (!panelToRemove) {
5311
+ throw new Error('invalid operation');
5312
+ }
5313
+ return this._removePanel(panelToRemove, options);
5243
5314
  }
5244
- constructor(id, component, headerComponent, orientation, isExpanded, isHeaderVisible) {
5245
- super(id, component, new PaneviewPanelApiImpl(id, component));
5246
- this.headerComponent = headerComponent;
5247
- this._onDidChangeExpansionState = new Emitter({ replay: true });
5248
- this.onDidChangeExpansionState = this._onDidChangeExpansionState.event;
5249
- this._onDidChange = new Emitter();
5250
- this.onDidChange = this._onDidChange.event;
5251
- this.headerSize = 22;
5252
- this._orthogonalSize = 0;
5253
- this._size = 0;
5254
- this._minimumBodySize = 100;
5255
- this._maximumBodySize = Number.POSITIVE_INFINITY;
5256
- this._isExpanded = false;
5257
- this.expandedSize = 0;
5258
- this.api.pane = this; // TODO cannot use 'this' before 'super'
5259
- this.api.initialize(this);
5260
- this._isExpanded = isExpanded;
5261
- this._headerVisible = isHeaderVisible;
5262
- this._onDidChangeExpansionState.fire(this.isExpanded()); // initialize value
5263
- this._orientation = orientation;
5264
- this.element.classList.add('pane');
5265
- this.addDisposables(this.api.onWillVisibilityChange((event) => {
5266
- const { isVisible } = event;
5267
- const { accessor } = this._params;
5268
- accessor.setVisible(this, isVisible);
5269
- }), this.api.onDidSizeChange((event) => {
5270
- this._onDidChange.fire({ size: event.size });
5271
- }), addDisposableListener(this.element, 'mouseenter', (ev) => {
5272
- this.api._onMouseEnter.fire(ev);
5273
- }), addDisposableListener(this.element, 'mouseleave', (ev) => {
5274
- this.api._onMouseLeave.fire(ev);
5275
- }));
5276
- this.addDisposables(this._onDidChangeExpansionState, this.onDidChangeExpansionState((isPanelExpanded) => {
5277
- this.api._onDidExpansionChange.fire({
5278
- isExpanded: isPanelExpanded,
5279
- });
5280
- }), this.api.onDidFocusChange((e) => {
5281
- if (!this.header) {
5282
- return;
5283
- }
5284
- if (e.isFocused) {
5285
- addClasses(this.header, 'focused');
5286
- }
5287
- else {
5288
- removeClasses(this.header, 'focused');
5315
+ closeAllPanels() {
5316
+ if (this.panels.length > 0) {
5317
+ // take a copy since we will be edting the array as we iterate through
5318
+ const arrPanelCpy = [...this.panels];
5319
+ for (const panel of arrPanelCpy) {
5320
+ this.doClose(panel);
5289
5321
  }
5290
- }));
5291
- this.renderOnce();
5322
+ }
5323
+ else {
5324
+ this.accessor.removeGroup(this.groupPanel);
5325
+ }
5292
5326
  }
5293
- setVisible(isVisible) {
5294
- this.api._onDidVisibilityChange.fire({ isVisible });
5327
+ closePanel(panel) {
5328
+ this.doClose(panel);
5295
5329
  }
5296
- setActive(isActive) {
5297
- this.api._onDidActiveChange.fire({ isActive });
5330
+ doClose(panel) {
5331
+ this.accessor.removePanel(panel);
5298
5332
  }
5299
- isExpanded() {
5300
- return this._isExpanded;
5333
+ isPanelActive(panel) {
5334
+ return this._activePanel === panel;
5301
5335
  }
5302
- setExpanded(expanded) {
5303
- if (this._isExpanded === expanded) {
5336
+ updateActions(element) {
5337
+ this.tabsContainer.setRightActionsElement(element);
5338
+ }
5339
+ setActive(isGroupActive, force = false) {
5340
+ if (!force && this.isActive === isGroupActive) {
5304
5341
  return;
5305
5342
  }
5306
- this._isExpanded = expanded;
5307
- if (expanded) {
5308
- if (this.animationTimer) {
5309
- clearTimeout(this.animationTimer);
5310
- }
5311
- if (this.body) {
5312
- this.element.appendChild(this.body);
5313
- }
5343
+ this._isGroupActive = isGroupActive;
5344
+ toggleClass(this.container, 'active-group', isGroupActive);
5345
+ toggleClass(this.container, 'inactive-group', !isGroupActive);
5346
+ this.tabsContainer.setActive(this.isActive);
5347
+ if (!this._activePanel && this.panels.length > 0) {
5348
+ this.doSetActivePanel(this.panels[0]);
5314
5349
  }
5315
- else {
5316
- this.animationTimer = setTimeout(() => {
5317
- var _a;
5318
- (_a = this.body) === null || _a === void 0 ? void 0 : _a.remove();
5319
- }, 200);
5350
+ this.updateContainer();
5351
+ }
5352
+ layout(width, height) {
5353
+ var _a;
5354
+ this._width = width;
5355
+ this._height = height;
5356
+ this.contentContainer.layout(this._width, this._height);
5357
+ if ((_a = this._activePanel) === null || _a === void 0 ? void 0 : _a.layout) {
5358
+ this._activePanel.layout(this._width, this._height);
5320
5359
  }
5321
- this._onDidChange.fire(expanded ? { size: this.width } : {});
5322
- this._onDidChangeExpansionState.fire(expanded);
5323
5360
  }
5324
- layout(size, orthogonalSize) {
5325
- this._size = size;
5326
- this._orthogonalSize = orthogonalSize;
5327
- const [width, height] = this.orientation === exports.Orientation.HORIZONTAL
5328
- ? [size, orthogonalSize]
5329
- : [orthogonalSize, size];
5330
- if (this.isExpanded()) {
5331
- this.expandedSize = width;
5361
+ _removePanel(panel, options) {
5362
+ const isActivePanel = this._activePanel === panel;
5363
+ this.doRemovePanel(panel);
5364
+ if (isActivePanel && this.panels.length > 0) {
5365
+ const nextPanel = this.mostRecentlyUsed[0];
5366
+ this.openPanel(nextPanel, {
5367
+ skipSetActive: options.skipSetActive,
5368
+ skipSetGroupActive: options.skipSetActiveGroup,
5369
+ });
5332
5370
  }
5333
- super.layout(width, height);
5371
+ if (this._activePanel && this.panels.length === 0) {
5372
+ this.doSetActivePanel(undefined);
5373
+ }
5374
+ if (!options.skipSetActive) {
5375
+ this.updateContainer();
5376
+ }
5377
+ return panel;
5334
5378
  }
5335
- init(parameters) {
5336
- var _a, _b;
5337
- super.init(parameters);
5338
- if (typeof parameters.minimumBodySize === 'number') {
5339
- this.minimumBodySize = parameters.minimumBodySize;
5379
+ doRemovePanel(panel) {
5380
+ const index = this.panels.indexOf(panel);
5381
+ if (this._activePanel === panel) {
5382
+ this.contentContainer.closePanel();
5340
5383
  }
5341
- if (typeof parameters.maximumBodySize === 'number') {
5342
- this.maximumBodySize = parameters.maximumBodySize;
5384
+ this.tabsContainer.delete(panel.id);
5385
+ this._panels.splice(index, 1);
5386
+ if (this.mostRecentlyUsed.includes(panel)) {
5387
+ const index = this.mostRecentlyUsed.indexOf(panel);
5388
+ this.mostRecentlyUsed.splice(index, 1);
5343
5389
  }
5344
- this.bodyPart = this.getBodyComponent();
5345
- this.headerPart = this.getHeaderComponent();
5346
- this.bodyPart.init(Object.assign(Object.assign({}, parameters), { api: this.api }));
5347
- this.headerPart.init(Object.assign(Object.assign({}, parameters), { api: this.api }));
5348
- (_a = this.body) === null || _a === void 0 ? void 0 : _a.append(this.bodyPart.element);
5349
- (_b = this.header) === null || _b === void 0 ? void 0 : _b.append(this.headerPart.element);
5350
- if (typeof parameters.isExpanded === 'boolean') {
5351
- this.setExpanded(parameters.isExpanded);
5390
+ const disposable = this._panelDisposables.get(panel.id);
5391
+ if (disposable) {
5392
+ disposable.dispose();
5393
+ this._panelDisposables.delete(panel.id);
5352
5394
  }
5395
+ this._onDidRemovePanel.fire({ panel });
5353
5396
  }
5354
- toJSON() {
5355
- const params = this._params;
5356
- return Object.assign(Object.assign({}, super.toJSON()), { headerComponent: this.headerComponent, title: params.title });
5397
+ doAddPanel(panel, index = this.panels.length, options = { skipSetActive: false }) {
5398
+ const existingPanel = this._panels.indexOf(panel);
5399
+ const hasExistingPanel = existingPanel > -1;
5400
+ this.tabsContainer.show();
5401
+ this.contentContainer.show();
5402
+ this.tabsContainer.openPanel(panel, index);
5403
+ if (!options.skipSetActive) {
5404
+ this.contentContainer.openPanel(panel);
5405
+ }
5406
+ if (hasExistingPanel) {
5407
+ // TODO - need to ensure ordering hasn't changed and if it has need to re-order this.panels
5408
+ return;
5409
+ }
5410
+ this.updateMru(panel);
5411
+ this.panels.splice(index, 0, panel);
5412
+ this._panelDisposables.set(panel.id, new CompositeDisposable(panel.api.onDidTitleChange((event) => this._onDidPanelTitleChange.fire(event)), panel.api.onDidParametersChange((event) => this._onDidPanelParametersChange.fire(event))));
5413
+ this._onDidAddPanel.fire({ panel });
5357
5414
  }
5358
- renderOnce() {
5359
- this.header = document.createElement('div');
5360
- this.header.tabIndex = 0;
5361
- this.header.className = 'pane-header';
5362
- this.header.style.height = `${this.headerSize}px`;
5363
- this.header.style.lineHeight = `${this.headerSize}px`;
5364
- this.header.style.minHeight = `${this.headerSize}px`;
5365
- this.header.style.maxHeight = `${this.headerSize}px`;
5366
- this.element.appendChild(this.header);
5367
- this.body = document.createElement('div');
5368
- this.body.className = 'pane-body';
5369
- this.element.appendChild(this.body);
5415
+ doSetActivePanel(panel) {
5416
+ if (this._activePanel === panel) {
5417
+ return;
5418
+ }
5419
+ this._activePanel = panel;
5420
+ if (panel) {
5421
+ this.tabsContainer.setActivePanel(panel);
5422
+ panel.layout(this._width, this._height);
5423
+ this.updateMru(panel);
5424
+ this._onDidActivePanelChange.fire({
5425
+ panel,
5426
+ });
5427
+ }
5370
5428
  }
5371
- // TODO slightly hacky by-pass of the component to create a body and header component
5372
- getComponent() {
5373
- return {
5374
- update: (params) => {
5375
- var _a, _b;
5376
- (_a = this.bodyPart) === null || _a === void 0 ? void 0 : _a.update({ params });
5377
- (_b = this.headerPart) === null || _b === void 0 ? void 0 : _b.update({ params });
5378
- },
5379
- dispose: () => {
5380
- var _a, _b;
5381
- (_a = this.bodyPart) === null || _a === void 0 ? void 0 : _a.dispose();
5382
- (_b = this.headerPart) === null || _b === void 0 ? void 0 : _b.dispose();
5383
- },
5384
- };
5429
+ updateMru(panel) {
5430
+ if (this.mostRecentlyUsed.includes(panel)) {
5431
+ this.mostRecentlyUsed.splice(this.mostRecentlyUsed.indexOf(panel), 1);
5432
+ }
5433
+ this.mostRecentlyUsed = [panel, ...this.mostRecentlyUsed];
5385
5434
  }
5386
- }
5387
-
5388
- class DraggablePaneviewPanel extends PaneviewPanel {
5389
- constructor(accessor, id, component, headerComponent, orientation, isExpanded, disableDnd) {
5390
- super(id, component, headerComponent, orientation, isExpanded, true);
5391
- this.accessor = accessor;
5392
- this._onDidDrop = new Emitter();
5393
- this.onDidDrop = this._onDidDrop.event;
5394
- if (!disableDnd) {
5395
- this.initDragFeatures();
5435
+ updateContainer() {
5436
+ var _a, _b;
5437
+ toggleClass(this.container, 'empty', this.isEmpty);
5438
+ this.panels.forEach((panel) => panel.runEvents());
5439
+ if (this.isEmpty && !this.watermark) {
5440
+ const watermark = this.accessor.createWatermarkComponent();
5441
+ watermark.init({
5442
+ containerApi: this._api,
5443
+ group: this.groupPanel,
5444
+ });
5445
+ this.watermark = watermark;
5446
+ addDisposableListener(this.watermark.element, 'click', () => {
5447
+ if (!this.isActive) {
5448
+ this.accessor.doSetGroupActive(this.groupPanel);
5449
+ }
5450
+ });
5451
+ this.tabsContainer.hide();
5452
+ this.contentContainer.element.appendChild(this.watermark.element);
5453
+ this.watermark.updateParentGroup(this.groupPanel, true);
5454
+ }
5455
+ if (!this.isEmpty && this.watermark) {
5456
+ this.watermark.element.remove();
5457
+ (_b = (_a = this.watermark).dispose) === null || _b === void 0 ? void 0 : _b.call(_a);
5458
+ this.watermark = undefined;
5459
+ this.tabsContainer.show();
5396
5460
  }
5397
5461
  }
5398
- initDragFeatures() {
5399
- if (!this.header) {
5462
+ canDisplayOverlay(event, position, target) {
5463
+ const firedEvent = new DockviewUnhandledDragOverEvent(event, target, position, getPanelData, this.accessor.getPanel(this.id));
5464
+ this._onUnhandledDragOverEvent.fire(firedEvent);
5465
+ return firedEvent.isAccepted;
5466
+ }
5467
+ handleDropEvent(type, event, position, index) {
5468
+ if (this.locked === 'no-drop-target') {
5400
5469
  return;
5401
5470
  }
5402
- const id = this.id;
5403
- const accessorId = this.accessor.id;
5404
- this.header.draggable = true;
5405
- this.handler = new (class PaneDragHandler extends DragHandler {
5406
- getData() {
5407
- LocalSelectionTransfer.getInstance().setData([new PaneTransfer(accessorId, id)], PaneTransfer.prototype);
5408
- return {
5409
- dispose: () => {
5410
- LocalSelectionTransfer.getInstance().clearData(PaneTransfer.prototype);
5411
- },
5412
- };
5471
+ function getKind() {
5472
+ switch (type) {
5473
+ case 'header':
5474
+ return typeof index === 'number' ? 'tab' : 'header_space';
5475
+ case 'content':
5476
+ return 'content';
5413
5477
  }
5414
- })(this.header);
5415
- this.target = new Droptarget(this.element, {
5416
- acceptedTargetZones: ['top', 'bottom'],
5417
- overlayModel: {
5418
- activationSize: { type: 'percentage', value: 50 },
5419
- },
5420
- canDisplayOverlay: (event) => {
5421
- const data = getPaneData();
5422
- if (data) {
5423
- if (data.paneId !== this.id &&
5424
- data.viewId === this.accessor.id) {
5425
- return true;
5426
- }
5427
- }
5428
- if (this.accessor.options.showDndOverlay) {
5429
- return this.accessor.options.showDndOverlay({
5430
- nativeEvent: event,
5431
- getData: getPaneData,
5432
- panel: this,
5433
- });
5434
- }
5435
- return false;
5436
- },
5478
+ }
5479
+ const panel = typeof index === 'number' ? this.panels[index] : undefined;
5480
+ const willDropEvent = new DockviewWillDropEvent({
5481
+ nativeEvent: event,
5482
+ position,
5483
+ panel,
5484
+ getData: () => getPanelData(),
5485
+ kind: getKind(),
5486
+ group: this.groupPanel,
5487
+ api: this._api,
5437
5488
  });
5438
- this.addDisposables(this._onDidDrop, this.handler, this.target, this.target.onDrop((event) => {
5439
- this.onDrop(event);
5440
- }));
5441
- }
5442
- onDrop(event) {
5443
- const data = getPaneData();
5444
- if (!data || data.viewId !== this.accessor.id) {
5445
- // if there is no local drag event for this panel
5446
- // or if the drag event was creating by another Paneview instance
5447
- this._onDidDrop.fire(Object.assign(Object.assign({}, event), { panel: this, api: new PaneviewApi(this.accessor), getData: getPaneData }));
5489
+ this._onWillDrop.fire(willDropEvent);
5490
+ if (willDropEvent.defaultPrevented) {
5448
5491
  return;
5449
5492
  }
5450
- const containerApi = this._params
5451
- .containerApi;
5452
- const panelId = data.paneId;
5453
- const existingPanel = containerApi.getPanel(panelId);
5454
- if (!existingPanel) {
5455
- // if the panel doesn't exist
5456
- this._onDidDrop.fire(Object.assign(Object.assign({}, event), { panel: this, getData: getPaneData, api: new PaneviewApi(this.accessor) }));
5457
- return;
5493
+ const data = getPanelData();
5494
+ if (data && data.viewId === this.accessor.id) {
5495
+ if (data.panelId === null) {
5496
+ // this is a group move dnd event
5497
+ const { groupId } = data;
5498
+ this._onMove.fire({
5499
+ target: position,
5500
+ groupId: groupId,
5501
+ index,
5502
+ });
5503
+ return;
5504
+ }
5505
+ const fromSameGroup = this.tabsContainer.indexOf(data.panelId) !== -1;
5506
+ if (fromSameGroup && this.tabsContainer.size === 1) {
5507
+ return;
5508
+ }
5509
+ const { groupId, panelId } = data;
5510
+ const isSameGroup = this.id === groupId;
5511
+ if (isSameGroup && !position) {
5512
+ const oldIndex = this.tabsContainer.indexOf(panelId);
5513
+ if (oldIndex === index) {
5514
+ return;
5515
+ }
5516
+ }
5517
+ this._onMove.fire({
5518
+ target: position,
5519
+ groupId: data.groupId,
5520
+ itemId: data.panelId,
5521
+ index,
5522
+ });
5458
5523
  }
5459
- const allPanels = containerApi.panels;
5460
- const fromIndex = allPanels.indexOf(existingPanel);
5461
- let toIndex = containerApi.panels.indexOf(this);
5462
- if (event.position === 'left' || event.position === 'top') {
5463
- toIndex = Math.max(0, toIndex - 1);
5524
+ else {
5525
+ this._onDidDrop.fire(new DockviewDidDropEvent({
5526
+ nativeEvent: event,
5527
+ position,
5528
+ panel,
5529
+ getData: () => getPanelData(),
5530
+ group: this.groupPanel,
5531
+ api: this._api,
5532
+ }));
5464
5533
  }
5465
- if (event.position === 'right' || event.position === 'bottom') {
5466
- if (fromIndex > toIndex) {
5467
- toIndex++;
5468
- }
5469
- toIndex = Math.min(allPanels.length - 1, toIndex);
5534
+ }
5535
+ dispose() {
5536
+ var _a, _b, _c;
5537
+ super.dispose();
5538
+ (_a = this.watermark) === null || _a === void 0 ? void 0 : _a.element.remove();
5539
+ (_c = (_b = this.watermark) === null || _b === void 0 ? void 0 : _b.dispose) === null || _c === void 0 ? void 0 : _c.call(_b);
5540
+ this.watermark = undefined;
5541
+ for (const panel of this.panels) {
5542
+ panel.dispose();
5470
5543
  }
5471
- containerApi.movePanel(fromIndex, toIndex);
5544
+ this.tabsContainer.dispose();
5545
+ this.contentContainer.dispose();
5472
5546
  }
5473
5547
  }
5474
5548
 
@@ -5655,9 +5729,12 @@
5655
5729
  constructor(id, accessor) {
5656
5730
  super(id, '__dockviewgroup__');
5657
5731
  this.accessor = accessor;
5732
+ this._mutableDisposable = new MutableDisposable();
5658
5733
  this._onDidLocationChange = new Emitter();
5659
5734
  this.onDidLocationChange = this._onDidLocationChange.event;
5660
- this.addDisposables(this._onDidLocationChange);
5735
+ this._onDidActivePanelChange = new Emitter();
5736
+ this.onDidActivePanelChange = this._onDidActivePanelChange.event;
5737
+ this.addDisposables(this._onDidLocationChange, this._onDidActivePanelChange, this._mutableDisposable);
5661
5738
  }
5662
5739
  close() {
5663
5740
  if (!this._group) {
@@ -5715,6 +5792,19 @@
5715
5792
  }
5716
5793
  initialize(group) {
5717
5794
  this._group = group;
5795
+ /**
5796
+ * TODO: Annoying initialization order caveat
5797
+ *
5798
+ * Due to the order on initialization we know that the model isn't defined until later in the same stack-frame of setup.
5799
+ * By queuing a microtask we can ensure the setup is completed within the same stack-frame, but after everything else has
5800
+ * finished ensuring the `model` is defined.
5801
+ */
5802
+ queueMicrotask(() => {
5803
+ this._mutableDisposable.value =
5804
+ this._group.model.onDidActivePanelChange((event) => {
5805
+ this._onDidActivePanelChange.fire(event);
5806
+ });
5807
+ });
5718
5808
  }
5719
5809
  }
5720
5810
 
@@ -5775,31 +5865,6 @@
5775
5865
  }
5776
5866
  }
5777
5867
 
5778
- function isPanelOptionsWithPanel(data) {
5779
- if (data.referencePanel) {
5780
- return true;
5781
- }
5782
- return false;
5783
- }
5784
- function isPanelOptionsWithGroup(data) {
5785
- if (data.referenceGroup) {
5786
- return true;
5787
- }
5788
- return false;
5789
- }
5790
- function isGroupOptionsWithPanel(data) {
5791
- if (data.referencePanel) {
5792
- return true;
5793
- }
5794
- return false;
5795
- }
5796
- function isGroupOptionsWithGroup(data) {
5797
- if (data.referenceGroup) {
5798
- return true;
5799
- }
5800
- return false;
5801
- }
5802
-
5803
5868
  class DockviewPanelApiImpl extends GridviewPanelApiImpl {
5804
5869
  get location() {
5805
5870
  return this.group.api.location;
@@ -6167,7 +6232,7 @@
6167
6232
  this._tab = this.createTabComponent(this.id, tabComponent);
6168
6233
  }
6169
6234
  init(params) {
6170
- this.content.init(Object.assign(Object.assign({}, params), { tab: this.tab }));
6235
+ this.content.init(params);
6171
6236
  this.tab.init(params);
6172
6237
  }
6173
6238
  updateParentGroup(_group, _isPanelVisible) {
@@ -6188,20 +6253,29 @@
6188
6253
  (_d = (_c = this.tab).dispose) === null || _d === void 0 ? void 0 : _d.call(_c);
6189
6254
  }
6190
6255
  createContentComponent(id, componentName) {
6191
- var _a, _b;
6192
- 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);
6256
+ return this.accessor.options.createComponent({
6257
+ id,
6258
+ name: componentName,
6259
+ });
6193
6260
  }
6194
6261
  createTabComponent(id, componentName) {
6195
- var _a, _b;
6196
- if (componentName) {
6197
- 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());
6198
- }
6199
- else if (this.accessor.options.defaultTabComponent) {
6200
- 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());
6201
- }
6202
- else {
6203
- return new DefaultTab();
6262
+ const name = componentName !== null && componentName !== void 0 ? componentName : this.accessor.options.defaultTabComponent;
6263
+ if (name) {
6264
+ if (this.accessor.options.createTabComponent) {
6265
+ const component = this.accessor.options.createTabComponent({
6266
+ id,
6267
+ name,
6268
+ });
6269
+ if (component) {
6270
+ return component;
6271
+ }
6272
+ else {
6273
+ return new DefaultTab();
6274
+ }
6275
+ }
6276
+ console.warn(`dockview: tabComponent '${componentName}' was not found. falling back to the default tab.`);
6204
6277
  }
6278
+ return new DefaultTab();
6205
6279
  }
6206
6280
  }
6207
6281
 
@@ -6932,14 +7006,19 @@
6932
7006
  }
6933
7007
  get renderer() {
6934
7008
  var _a;
6935
- return (_a = this.options.defaultRenderer) !== null && _a !== void 0 ? _a : 'onlyWhenVisibile';
7009
+ return (_a = this.options.defaultRenderer) !== null && _a !== void 0 ? _a : 'onlyWhenVisible';
7010
+ }
7011
+ get api() {
7012
+ return this._api;
6936
7013
  }
6937
7014
  constructor(options) {
6938
- var _a, _b;
7015
+ var _a;
6939
7016
  super({
6940
7017
  proportionalLayout: true,
6941
- orientation: (_a = options.orientation) !== null && _a !== void 0 ? _a : exports.Orientation.HORIZONTAL,
6942
- styles: options.styles,
7018
+ orientation: exports.Orientation.HORIZONTAL,
7019
+ styles: options.hideBorders
7020
+ ? { separatorBorder: 'transparent' }
7021
+ : undefined,
6943
7022
  parentElement: options.parentElement,
6944
7023
  disableAutoResizing: options.disableAutoResizing,
6945
7024
  locked: options.locked,
@@ -6957,6 +7036,8 @@
6957
7036
  this.onWillDrop = this._onWillDrop.event;
6958
7037
  this._onWillShowOverlay = new Emitter();
6959
7038
  this.onWillShowOverlay = this._onWillShowOverlay.event;
7039
+ this._onUnhandledDragOverEvent = new Emitter();
7040
+ this.onUnhandledDragOverEvent = this._onUnhandledDragOverEvent.event;
6960
7041
  this._onDidRemovePanel = new Emitter();
6961
7042
  this.onDidRemovePanel = this._onDidRemovePanel.event;
6962
7043
  this._onDidAddPanel = new Emitter();
@@ -6982,7 +7063,7 @@
6982
7063
  this.overlayRenderContainer = new OverlayRenderContainer(gready);
6983
7064
  toggleClass(this.gridview.element, 'dv-dockview', true);
6984
7065
  toggleClass(this.element, 'dv-debug', !!options.debug);
6985
- 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) => {
7066
+ 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) => {
6986
7067
  if (!this._moving) {
6987
7068
  this._onDidAddGroup.fire(event);
6988
7069
  }
@@ -7009,22 +7090,6 @@
7009
7090
  }
7010
7091
  }));
7011
7092
  this._options = options;
7012
- if (!this.options.components) {
7013
- this.options.components = {};
7014
- }
7015
- if (!this.options.frameworkComponents) {
7016
- this.options.frameworkComponents = {};
7017
- }
7018
- if (!this.options.frameworkTabComponents) {
7019
- this.options.frameworkTabComponents = {};
7020
- }
7021
- if (!this.options.tabComponents) {
7022
- this.options.tabComponents = {};
7023
- }
7024
- if (!this.options.watermarkComponent &&
7025
- !this.options.watermarkFrameworkComponent) {
7026
- this.options.watermarkComponent = Watermark;
7027
- }
7028
7093
  this._rootDropTarget = new Droptarget(this.element, {
7029
7094
  canDisplayOverlay: (event, position) => {
7030
7095
  const data = getPanelData();
@@ -7039,26 +7104,20 @@
7039
7104
  }
7040
7105
  return true;
7041
7106
  }
7042
- if (this.options.showDndOverlay) {
7043
- if (position === 'center' && this.gridview.length !== 0) {
7044
- /**
7045
- * for external events only show the four-corner drag overlays, disable
7046
- * the center position so that external drag events can fall through to the group
7047
- * and panel drop target handlers
7048
- */
7049
- return false;
7050
- }
7051
- return this.options.showDndOverlay({
7052
- nativeEvent: event,
7053
- position: position,
7054
- target: 'edge',
7055
- getData: getPanelData,
7056
- });
7107
+ if (position === 'center' && this.gridview.length !== 0) {
7108
+ /**
7109
+ * for external events only show the four-corner drag overlays, disable
7110
+ * the center position so that external drag events can fall through to the group
7111
+ * and panel drop target handlers
7112
+ */
7113
+ return false;
7057
7114
  }
7058
- return false;
7115
+ const firedEvent = new DockviewUnhandledDragOverEvent(event, 'edge', position, getPanelData);
7116
+ this._onUnhandledDragOverEvent.fire(firedEvent);
7117
+ return firedEvent.isAccepted;
7059
7118
  },
7060
7119
  acceptedTargetZones: ['top', 'bottom', 'left', 'right', 'center'],
7061
- overlayModel: (_b = this.options.rootOverlayModel) !== null && _b !== void 0 ? _b : DEFAULT_ROOT_OVERLAY_MODEL,
7120
+ overlayModel: (_a = this.options.rootOverlayModel) !== null && _a !== void 0 ? _a : DEFAULT_ROOT_OVERLAY_MODEL,
7062
7121
  });
7063
7122
  this.addDisposables(this._rootDropTarget, this._rootDropTarget.onWillShowOverlay((event) => {
7064
7123
  if (this.gridview.length > 0 && event.position === 'center') {
@@ -7067,6 +7126,10 @@
7067
7126
  }
7068
7127
  this._onWillShowOverlay.fire(new WillShowOverlayLocationEvent(event, {
7069
7128
  kind: 'edge',
7129
+ panel: undefined,
7130
+ api: this._api,
7131
+ group: undefined,
7132
+ getData: getPanelData,
7070
7133
  }));
7071
7134
  }), this._rootDropTarget.onDrop((event) => {
7072
7135
  var _a;
@@ -7278,7 +7341,7 @@
7278
7341
  skipDispose: true,
7279
7342
  skipSetActiveGroup: true,
7280
7343
  }));
7281
- group.model.openPanel(item, { skipSetGroupActive: true });
7344
+ this.movingLock(() => group.model.openPanel(item, { skipSetGroupActive: true }));
7282
7345
  }
7283
7346
  else {
7284
7347
  group = item;
@@ -7351,7 +7414,7 @@
7351
7414
  // this is either a resize or a move
7352
7415
  // to inform the panels .layout(...) the group with it's current size
7353
7416
  // don't care about resize since the above watcher handles that
7354
- group.layout(group.height, group.width);
7417
+ group.layout(group.width, group.height);
7355
7418
  }), overlay.onDidChangeEnd(() => {
7356
7419
  this._bufferOnDidLayoutChange.fire();
7357
7420
  }), group.onDidChange((event) => {
@@ -7406,16 +7469,11 @@
7406
7469
  }
7407
7470
  updateOptions(options) {
7408
7471
  var _a, _b;
7409
- const changed_orientation = typeof options.orientation === 'string' &&
7410
- this.gridview.orientation !== options.orientation;
7411
- const changed_floatingGroupBounds = options.floatingGroupBounds !== undefined &&
7472
+ const changed_floatingGroupBounds = 'floatingGroupBounds' in options &&
7412
7473
  options.floatingGroupBounds !== this.options.floatingGroupBounds;
7413
- const changed_rootOverlayOptions = options.rootOverlayModel !== undefined &&
7474
+ const changed_rootOverlayOptions = 'rootOverlayModel' in options &&
7414
7475
  options.rootOverlayModel !== this.options.rootOverlayModel;
7415
7476
  this._options = Object.assign(Object.assign({}, this.options), options);
7416
- if (changed_orientation) {
7417
- this.gridview.orientation = options.orientation;
7418
- }
7419
7477
  if (changed_floatingGroupBounds) {
7420
7478
  for (const group of this._floatingGroups) {
7421
7479
  switch (this.options.floatingGroupBounds) {
@@ -7703,7 +7761,7 @@
7703
7761
  ? this.getGroupPanel(options.position.referencePanel)
7704
7762
  : options.position.referencePanel;
7705
7763
  if (!referencePanel) {
7706
- throw new Error(`referencePanel ${options.position.referencePanel} does not exist`);
7764
+ throw new Error(`referencePanel '${options.position.referencePanel}' does not exist`);
7707
7765
  }
7708
7766
  referenceGroup = this.findGroup(referencePanel);
7709
7767
  }
@@ -7713,14 +7771,19 @@
7713
7771
  ? (_a = this._groups.get(options.position.referenceGroup)) === null || _a === void 0 ? void 0 : _a.value
7714
7772
  : options.position.referenceGroup;
7715
7773
  if (!referenceGroup) {
7716
- throw new Error(`referencePanel ${options.position.referenceGroup} does not exist`);
7774
+ throw new Error(`referenceGroup '${options.position.referenceGroup}' does not exist`);
7717
7775
  }
7718
7776
  }
7719
7777
  else {
7720
7778
  const group = this.orthogonalize(directionToPosition(options.position.direction));
7721
7779
  const panel = this.createPanel(options, group);
7722
- group.model.openPanel(panel);
7723
- this.doSetGroupAndPanelActive(group);
7780
+ group.model.openPanel(panel, {
7781
+ skipSetActive: options.inactive,
7782
+ skipSetGroupActive: options.inactive,
7783
+ });
7784
+ if (!options.inactive) {
7785
+ this.doSetGroupAndPanelActive(group);
7786
+ }
7724
7787
  return panel;
7725
7788
  }
7726
7789
  }
@@ -7743,43 +7806,64 @@
7743
7806
  skipActiveGroup: true,
7744
7807
  });
7745
7808
  panel = this.createPanel(options, group);
7746
- group.model.openPanel(panel);
7809
+ group.model.openPanel(panel, {
7810
+ skipSetActive: options.inactive,
7811
+ skipSetGroupActive: options.inactive,
7812
+ });
7747
7813
  }
7748
7814
  else if (referenceGroup.api.location.type === 'floating' ||
7749
7815
  target === 'center') {
7750
7816
  panel = this.createPanel(options, referenceGroup);
7751
- referenceGroup.model.openPanel(panel);
7752
- this.doSetGroupAndPanelActive(referenceGroup);
7817
+ referenceGroup.model.openPanel(panel, {
7818
+ skipSetActive: options.inactive,
7819
+ skipSetGroupActive: options.inactive,
7820
+ });
7821
+ if (!options.inactive) {
7822
+ this.doSetGroupAndPanelActive(referenceGroup);
7823
+ }
7753
7824
  }
7754
7825
  else {
7755
7826
  const location = getGridLocation(referenceGroup.element);
7756
7827
  const relativeLocation = getRelativeLocation(this.gridview.orientation, location, target);
7757
7828
  const group = this.createGroupAtLocation(relativeLocation);
7758
7829
  panel = this.createPanel(options, group);
7759
- group.model.openPanel(panel);
7760
- this.doSetGroupAndPanelActive(group);
7830
+ group.model.openPanel(panel, {
7831
+ skipSetActive: options.inactive,
7832
+ skipSetGroupActive: options.inactive,
7833
+ });
7834
+ if (!options.inactive) {
7835
+ this.doSetGroupAndPanelActive(group);
7836
+ }
7761
7837
  }
7762
7838
  }
7763
7839
  else if (options.floating) {
7764
7840
  const group = this.createGroup();
7765
7841
  this._onDidAddGroup.fire(group);
7766
- const o = typeof options.floating === 'object' &&
7842
+ const coordinates = typeof options.floating === 'object' &&
7767
7843
  options.floating !== null
7768
7844
  ? options.floating
7769
7845
  : {};
7770
- this.addFloatingGroup(group, o, {
7846
+ this.addFloatingGroup(group, coordinates, {
7771
7847
  inDragMode: false,
7772
7848
  skipRemoveGroup: true,
7773
7849
  skipActiveGroup: true,
7774
7850
  });
7775
7851
  panel = this.createPanel(options, group);
7776
- group.model.openPanel(panel);
7852
+ group.model.openPanel(panel, {
7853
+ skipSetActive: options.inactive,
7854
+ skipSetGroupActive: options.inactive,
7855
+ });
7777
7856
  }
7778
7857
  else {
7779
7858
  const group = this.createGroupAtLocation();
7780
7859
  panel = this.createPanel(options, group);
7781
- group.model.openPanel(panel);
7782
- this.doSetGroupAndPanelActive(group);
7860
+ group.model.openPanel(panel, {
7861
+ skipSetActive: options.inactive,
7862
+ skipSetGroupActive: options.inactive,
7863
+ });
7864
+ if (!options.inactive) {
7865
+ this.doSetGroupAndPanelActive(group);
7866
+ }
7783
7867
  }
7784
7868
  return panel;
7785
7869
  }
@@ -7803,12 +7887,10 @@
7803
7887
  }
7804
7888
  }
7805
7889
  createWatermarkComponent() {
7806
- var _a;
7807
- return createComponent('watermark-id', 'watermark-name', this.options.watermarkComponent
7808
- ? { 'watermark-name': this.options.watermarkComponent }
7809
- : {}, this.options.watermarkFrameworkComponent
7810
- ? { 'watermark-name': this.options.watermarkFrameworkComponent }
7811
- : {}, (_a = this.options.frameworkComponentFactory) === null || _a === void 0 ? void 0 : _a.watermark);
7890
+ if (this.options.createWatermarkComponent) {
7891
+ return this.options.createWatermarkComponent();
7892
+ }
7893
+ return new Watermark();
7812
7894
  }
7813
7895
  updateWatermark() {
7814
7896
  var _a, _b;
@@ -8189,6 +8271,8 @@
8189
8271
  return;
8190
8272
  }
8191
8273
  this._onWillShowOverlay.fire(event);
8274
+ }), view.model.onUnhandledDragOverEvent((event) => {
8275
+ this._onUnhandledDragOverEvent.fire(event);
8192
8276
  }), view.model.onDidAddPanel((event) => {
8193
8277
  if (this._moving) {
8194
8278
  return;
@@ -9434,11 +9518,6 @@
9434
9518
  this.part = new ReactPart(this.element, this.reactPortalStore, this.component, {
9435
9519
  group: parameters.group,
9436
9520
  containerApi: parameters.containerApi,
9437
- close: () => {
9438
- if (parameters.group) {
9439
- parameters.containerApi.removeGroup(parameters.group);
9440
- }
9441
- },
9442
9521
  });
9443
9522
  }
9444
9523
  focus() {
@@ -9470,9 +9549,6 @@
9470
9549
  get part() {
9471
9550
  return this._part;
9472
9551
  }
9473
- get group() {
9474
- return this._group;
9475
- }
9476
9552
  constructor(component, reactPortalStore, _group) {
9477
9553
  this.component = component;
9478
9554
  this.reactPortalStore = reactPortalStore;
@@ -9483,9 +9559,6 @@
9483
9559
  this._element.style.height = '100%';
9484
9560
  this._element.style.width = '100%';
9485
9561
  }
9486
- focus() {
9487
- // TODO
9488
- }
9489
9562
  init(parameters) {
9490
9563
  this.mutableDisposable.value = new CompositeDisposable(this._group.model.onDidAddPanel(() => {
9491
9564
  this.updatePanels();
@@ -9505,15 +9578,15 @@
9505
9578
  group: this._group,
9506
9579
  });
9507
9580
  }
9508
- update(event) {
9509
- var _a;
9510
- (_a = this._part) === null || _a === void 0 ? void 0 : _a.update(event.params);
9511
- }
9512
9581
  dispose() {
9513
9582
  var _a;
9514
9583
  this.mutableDisposable.dispose();
9515
9584
  (_a = this._part) === null || _a === void 0 ? void 0 : _a.dispose();
9516
9585
  }
9586
+ update(event) {
9587
+ var _a;
9588
+ (_a = this._part) === null || _a === void 0 ? void 0 : _a.update(event.params);
9589
+ }
9517
9590
  updatePanels() {
9518
9591
  this.update({ params: { panels: this._group.model.panels } });
9519
9592
  }
@@ -9541,72 +9614,72 @@
9541
9614
  : undefined;
9542
9615
  }
9543
9616
  const DEFAULT_REACT_TAB = 'props.defaultTabComponent';
9617
+ function extractCoreOptions(props) {
9618
+ const coreOptions = PROPERTY_KEYS.reduce((obj, key) => {
9619
+ if (key in props) {
9620
+ obj[key] = props[key];
9621
+ }
9622
+ return obj;
9623
+ }, {});
9624
+ return coreOptions;
9625
+ }
9544
9626
  const DockviewReact = React.forwardRef((props, ref) => {
9545
9627
  const domRef = React.useRef(null);
9546
9628
  const dockviewRef = React.useRef();
9547
9629
  const [portals, addPortal] = usePortalsLifecycle();
9548
9630
  React.useImperativeHandle(ref, () => domRef.current, []);
9631
+ const prevProps = React.useRef({});
9632
+ React.useEffect(() => {
9633
+ const changes = {};
9634
+ PROPERTY_KEYS.forEach((propKey) => {
9635
+ const key = propKey;
9636
+ const propValue = props[key];
9637
+ if (key in props && propValue !== prevProps.current[key]) {
9638
+ changes[key] = propValue;
9639
+ }
9640
+ });
9641
+ if (dockviewRef.current) {
9642
+ dockviewRef.current.updateOptions(changes);
9643
+ }
9644
+ prevProps.current = props;
9645
+ }, PROPERTY_KEYS.map((key) => props[key]));
9549
9646
  React.useEffect(() => {
9550
9647
  var _a;
9551
9648
  if (!domRef.current) {
9552
- return () => {
9553
- // noop
9554
- };
9649
+ return;
9555
9650
  }
9556
- const factory = {
9557
- content: {
9558
- createComponent: (_id, componentId, component) => {
9559
- return new ReactPanelContentPart(componentId, component, {
9560
- addPortal,
9561
- });
9562
- },
9563
- },
9564
- tab: {
9565
- createComponent: (_id, componentId, component) => {
9566
- return new ReactPanelHeaderPart(componentId, component, {
9567
- addPortal,
9568
- });
9569
- },
9570
- },
9571
- watermark: {
9572
- createComponent: (_id, componentId, component) => {
9573
- return new ReactWatermarkPart(componentId, component, {
9574
- addPortal,
9575
- });
9576
- },
9577
- },
9578
- };
9579
9651
  const frameworkTabComponents = (_a = props.tabComponents) !== null && _a !== void 0 ? _a : {};
9580
9652
  if (props.defaultTabComponent) {
9581
9653
  frameworkTabComponents[DEFAULT_REACT_TAB] =
9582
9654
  props.defaultTabComponent;
9583
9655
  }
9584
- const dockview = new DockviewComponent({
9656
+ const frameworkOptions = {
9657
+ createLeftHeaderActionComponent: createGroupControlElement(props.leftHeaderActionsComponent, { addPortal }),
9658
+ createRightHeaderActionComponent: createGroupControlElement(props.rightHeaderActionsComponent, { addPortal }),
9659
+ createPrefixHeaderActionComponent: createGroupControlElement(props.prefixHeaderActionsComponent, { addPortal }),
9660
+ createComponent: (options) => {
9661
+ return new ReactPanelContentPart(options.id, props.components[options.name], {
9662
+ addPortal,
9663
+ });
9664
+ },
9665
+ createTabComponent(options) {
9666
+ return new ReactPanelHeaderPart(options.id, frameworkTabComponents[options.name], {
9667
+ addPortal,
9668
+ });
9669
+ },
9670
+ createWatermarkComponent: props.watermarkComponent
9671
+ ? () => {
9672
+ return new ReactWatermarkPart('watermark', props.watermarkComponent, {
9673
+ addPortal,
9674
+ });
9675
+ }
9676
+ : undefined,
9585
9677
  parentElement: domRef.current,
9586
- frameworkComponentFactory: factory,
9587
- frameworkComponents: props.components,
9588
- disableAutoResizing: props.disableAutoResizing,
9589
- frameworkTabComponents,
9590
- watermarkFrameworkComponent: props.watermarkComponent,
9591
9678
  defaultTabComponent: props.defaultTabComponent
9592
9679
  ? DEFAULT_REACT_TAB
9593
9680
  : undefined,
9594
- styles: props.hideBorders
9595
- ? { separatorBorder: 'transparent' }
9596
- : undefined,
9597
- showDndOverlay: props.showDndOverlay,
9598
- createLeftHeaderActionsElement: createGroupControlElement(props.leftHeaderActionsComponent, { addPortal }),
9599
- createRightHeaderActionsElement: createGroupControlElement(props.rightHeaderActionsComponent, { addPortal }),
9600
- createPrefixHeaderActionsElement: createGroupControlElement(props.prefixHeaderActionsComponent, { addPortal }),
9601
- singleTabMode: props.singleTabMode,
9602
- disableFloatingGroups: props.disableFloatingGroups,
9603
- floatingGroupBounds: props.floatingGroupBounds,
9604
- defaultRenderer: props.defaultRenderer,
9605
- debug: props.debug,
9606
- rootOverlayModel: props.rootOverlayModel,
9607
- locked: props.locked,
9608
- disableDnd: props.disableDnd,
9609
- });
9681
+ };
9682
+ const dockview = new DockviewComponent(Object.assign(Object.assign({}, extractCoreOptions(props)), frameworkOptions));
9610
9683
  const { clientWidth, clientHeight } = domRef.current;
9611
9684
  dockview.layout(clientWidth, clientHeight);
9612
9685
  if (props.onReady) {
@@ -9617,20 +9690,6 @@
9617
9690
  dockview.dispose();
9618
9691
  };
9619
9692
  }, []);
9620
- React.useEffect(() => {
9621
- if (!dockviewRef.current) {
9622
- return;
9623
- }
9624
- dockviewRef.current.locked = !!props.locked;
9625
- }, [props.locked]);
9626
- React.useEffect(() => {
9627
- if (!dockviewRef.current) {
9628
- return;
9629
- }
9630
- dockviewRef.current.updateOptions({
9631
- disableDnd: props.disableDnd,
9632
- });
9633
- }, [props.disableDnd]);
9634
9693
  React.useEffect(() => {
9635
9694
  if (!dockviewRef.current) {
9636
9695
  return () => {
@@ -9652,63 +9711,43 @@
9652
9711
  // noop
9653
9712
  };
9654
9713
  }
9655
- const disposable = dockviewRef.current.onWillDrop((event) => {
9656
- if (props.onWillDrop) {
9657
- props.onWillDrop(event);
9714
+ const disposable = dockviewRef.current.onUnhandledDragOverEvent((event) => {
9715
+ var _a;
9716
+ if ((_a = props.showDndOverlay) === null || _a === void 0 ? void 0 : _a.call(props, event)) {
9717
+ event.accept();
9658
9718
  }
9659
9719
  });
9660
9720
  return () => {
9661
9721
  disposable.dispose();
9662
9722
  };
9663
- }, [props.onWillDrop]);
9664
- React.useEffect(() => {
9665
- if (!dockviewRef.current) {
9666
- return;
9667
- }
9668
- dockviewRef.current.updateOptions({
9669
- frameworkComponents: props.components,
9670
- });
9671
- }, [props.components]);
9672
- React.useEffect(() => {
9673
- if (!dockviewRef.current) {
9674
- return;
9675
- }
9676
- dockviewRef.current.updateOptions({
9677
- floatingGroupBounds: props.floatingGroupBounds,
9678
- });
9679
- }, [props.floatingGroupBounds]);
9680
- React.useEffect(() => {
9681
- if (!dockviewRef.current) {
9682
- return;
9683
- }
9684
- dockviewRef.current.updateOptions({
9685
- watermarkFrameworkComponent: props.watermarkComponent,
9686
- });
9687
- }, [props.watermarkComponent]);
9688
- React.useEffect(() => {
9689
- if (!dockviewRef.current) {
9690
- return;
9691
- }
9692
- dockviewRef.current.updateOptions({
9693
- showDndOverlay: props.showDndOverlay,
9694
- });
9695
9723
  }, [props.showDndOverlay]);
9696
9724
  React.useEffect(() => {
9697
9725
  if (!dockviewRef.current) {
9698
- return;
9726
+ return () => {
9727
+ // noop
9728
+ };
9699
9729
  }
9700
- dockviewRef.current.updateOptions({
9701
- frameworkTabComponents: props.tabComponents,
9730
+ const disposable = dockviewRef.current.onWillDrop((event) => {
9731
+ if (props.onWillDrop) {
9732
+ props.onWillDrop(event);
9733
+ }
9702
9734
  });
9703
- }, [props.tabComponents]);
9735
+ return () => {
9736
+ disposable.dispose();
9737
+ };
9738
+ }, [props.onWillDrop]);
9704
9739
  React.useEffect(() => {
9705
9740
  if (!dockviewRef.current) {
9706
9741
  return;
9707
9742
  }
9708
9743
  dockviewRef.current.updateOptions({
9709
- disableFloatingGroups: props.disableFloatingGroups,
9744
+ createComponent: (options) => {
9745
+ return new ReactPanelContentPart(options.id, props.components[options.name], {
9746
+ addPortal,
9747
+ });
9748
+ },
9710
9749
  });
9711
- }, [props.disableFloatingGroups]);
9750
+ }, [props.components]);
9712
9751
  React.useEffect(() => {
9713
9752
  var _a;
9714
9753
  if (!dockviewRef.current) {
@@ -9723,39 +9762,49 @@
9723
9762
  defaultTabComponent: props.defaultTabComponent
9724
9763
  ? DEFAULT_REACT_TAB
9725
9764
  : undefined,
9726
- frameworkTabComponents,
9765
+ createTabComponent(options) {
9766
+ return new ReactPanelHeaderPart(options.id, frameworkTabComponents[options.name], {
9767
+ addPortal,
9768
+ });
9769
+ },
9727
9770
  });
9728
- }, [props.defaultTabComponent]);
9771
+ }, [props.tabComponents, props.defaultTabComponent]);
9729
9772
  React.useEffect(() => {
9730
9773
  if (!dockviewRef.current) {
9731
9774
  return;
9732
9775
  }
9733
9776
  dockviewRef.current.updateOptions({
9734
- createRightHeaderActionsElement: createGroupControlElement(props.rightHeaderActionsComponent, { addPortal }),
9777
+ createWatermarkComponent: props.watermarkComponent
9778
+ ? () => {
9779
+ return new ReactWatermarkPart('watermark', props.watermarkComponent, {
9780
+ addPortal,
9781
+ });
9782
+ }
9783
+ : undefined,
9735
9784
  });
9736
- }, [props.rightHeaderActionsComponent]);
9785
+ }, [props.watermarkComponent]);
9737
9786
  React.useEffect(() => {
9738
9787
  if (!dockviewRef.current) {
9739
9788
  return;
9740
9789
  }
9741
9790
  dockviewRef.current.updateOptions({
9742
- createLeftHeaderActionsElement: createGroupControlElement(props.leftHeaderActionsComponent, { addPortal }),
9791
+ createRightHeaderActionComponent: createGroupControlElement(props.rightHeaderActionsComponent, { addPortal }),
9743
9792
  });
9744
- }, [props.leftHeaderActionsComponent]);
9793
+ }, [props.rightHeaderActionsComponent]);
9745
9794
  React.useEffect(() => {
9746
9795
  if (!dockviewRef.current) {
9747
9796
  return;
9748
9797
  }
9749
9798
  dockviewRef.current.updateOptions({
9750
- rootOverlayModel: props.rootOverlayModel,
9799
+ createLeftHeaderActionComponent: createGroupControlElement(props.leftHeaderActionsComponent, { addPortal }),
9751
9800
  });
9752
- }, [props.rootOverlayModel]);
9801
+ }, [props.leftHeaderActionsComponent]);
9753
9802
  React.useEffect(() => {
9754
9803
  if (!dockviewRef.current) {
9755
9804
  return;
9756
9805
  }
9757
9806
  dockviewRef.current.updateOptions({
9758
- createPrefixHeaderActionsElement: createGroupControlElement(props.prefixHeaderActionsComponent, { addPortal }),
9807
+ createPrefixHeaderActionComponent: createGroupControlElement(props.prefixHeaderActionsComponent, { addPortal }),
9759
9808
  });
9760
9809
  }, [props.prefixHeaderActionsComponent]);
9761
9810
  return (React.createElement("div", { className: props.className, style: { height: '100%', width: '100%' }, ref: domRef }, portals));
@@ -10095,6 +10144,7 @@
10095
10144
  exports.DockviewMutableDisposable = MutableDisposable;
10096
10145
  exports.DockviewPanel = DockviewPanel;
10097
10146
  exports.DockviewReact = DockviewReact;
10147
+ exports.DockviewUnhandledDragOverEvent = DockviewUnhandledDragOverEvent;
10098
10148
  exports.DockviewWillDropEvent = DockviewWillDropEvent;
10099
10149
  exports.DraggablePaneviewPanel = DraggablePaneviewPanel;
10100
10150
  exports.Gridview = Gridview;
@@ -10103,6 +10153,7 @@
10103
10153
  exports.GridviewPanel = GridviewPanel;
10104
10154
  exports.GridviewReact = GridviewReact;
10105
10155
  exports.LocalSelectionTransfer = LocalSelectionTransfer;
10156
+ exports.PROPERTY_KEYS = PROPERTY_KEYS;
10106
10157
  exports.PaneFramework = PaneFramework;
10107
10158
  exports.PaneTransfer = PaneTransfer;
10108
10159
  exports.PanelTransfer = PanelTransfer;