dockview-core 1.12.0 → 1.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/dist/cjs/api/component.api.d.ts +2 -1
  2. package/dist/cjs/api/component.api.js +7 -0
  3. package/dist/cjs/api/dockviewGroupPanelApi.d.ts +5 -1
  4. package/dist/cjs/api/dockviewGroupPanelApi.js +19 -1
  5. package/dist/cjs/dnd/droptarget.d.ts +1 -1
  6. package/dist/cjs/dnd/droptarget.js +4 -10
  7. package/dist/cjs/dockview/components/panel/content.js +0 -8
  8. package/dist/cjs/dockview/dockviewComponent.d.ts +6 -4
  9. package/dist/cjs/dockview/dockviewComponent.js +71 -67
  10. package/dist/cjs/dockview/dockviewGroupPanelModel.d.ts +3 -0
  11. package/dist/cjs/dockview/dockviewGroupPanelModel.js +18 -19
  12. package/dist/cjs/dockview/dockviewPanelModel.js +21 -24
  13. package/dist/cjs/dockview/framework.d.ts +38 -0
  14. package/dist/cjs/dockview/framework.js +2 -0
  15. package/dist/cjs/dockview/options.d.ts +68 -46
  16. package/dist/cjs/dockview/options.js +43 -1
  17. package/dist/cjs/dockview/types.d.ts +4 -10
  18. package/dist/cjs/framwork.d.ts +4 -0
  19. package/dist/cjs/framwork.js +2 -0
  20. package/dist/cjs/index.d.ts +2 -1
  21. package/dist/cjs/index.js +1 -1
  22. package/dist/dockview-core.amd.js +1973 -1920
  23. package/dist/dockview-core.amd.js.map +1 -1
  24. package/dist/dockview-core.amd.min.js +2 -2
  25. package/dist/dockview-core.amd.min.js.map +1 -1
  26. package/dist/dockview-core.amd.min.noStyle.js +2 -2
  27. package/dist/dockview-core.amd.min.noStyle.js.map +1 -1
  28. package/dist/dockview-core.amd.noStyle.js +1973 -1920
  29. package/dist/dockview-core.amd.noStyle.js.map +1 -1
  30. package/dist/dockview-core.cjs.js +1973 -1920
  31. package/dist/dockview-core.cjs.js.map +1 -1
  32. package/dist/dockview-core.esm.js +1972 -1921
  33. package/dist/dockview-core.esm.js.map +1 -1
  34. package/dist/dockview-core.esm.min.js +2 -2
  35. package/dist/dockview-core.esm.min.js.map +1 -1
  36. package/dist/dockview-core.js +1973 -1920
  37. package/dist/dockview-core.js.map +1 -1
  38. package/dist/dockview-core.min.js +2 -2
  39. package/dist/dockview-core.min.js.map +1 -1
  40. package/dist/dockview-core.min.noStyle.js +2 -2
  41. package/dist/dockview-core.min.noStyle.js.map +1 -1
  42. package/dist/dockview-core.noStyle.js +1973 -1920
  43. package/dist/dockview-core.noStyle.js.map +1 -1
  44. package/dist/esm/api/component.api.d.ts +2 -1
  45. package/dist/esm/api/component.api.js +3 -0
  46. package/dist/esm/api/dockviewGroupPanelApi.d.ts +5 -1
  47. package/dist/esm/api/dockviewGroupPanelApi.js +18 -1
  48. package/dist/esm/dnd/droptarget.d.ts +1 -1
  49. package/dist/esm/dnd/droptarget.js +4 -10
  50. package/dist/esm/dockview/components/panel/content.js +0 -8
  51. package/dist/esm/dockview/dockviewComponent.d.ts +6 -4
  52. package/dist/esm/dockview/dockviewComponent.js +70 -68
  53. package/dist/esm/dockview/dockviewGroupPanelModel.d.ts +3 -0
  54. package/dist/esm/dockview/dockviewGroupPanelModel.js +18 -19
  55. package/dist/esm/dockview/dockviewPanelModel.js +21 -13
  56. package/dist/esm/dockview/framework.d.ts +38 -0
  57. package/dist/esm/dockview/framework.js +1 -0
  58. package/dist/esm/dockview/options.d.ts +68 -46
  59. package/dist/esm/dockview/options.js +36 -0
  60. package/dist/esm/dockview/types.d.ts +4 -10
  61. package/dist/esm/framwork.d.ts +4 -0
  62. package/dist/esm/framwork.js +1 -0
  63. package/dist/esm/index.d.ts +2 -1
  64. package/dist/esm/index.js +1 -1
  65. package/package.json +2 -2
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * dockview-core
3
- * @version 1.12.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,2023 +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 'onlyWhenVisible':
3551
- this.group.renderContainer.detatch(panel);
3552
- if (this.panel) {
3553
- if (doRender) {
3554
- this._element.appendChild(this.panel.view.content.element);
3555
- }
3556
- }
3557
- container = this._element;
3558
- break;
3559
- case 'always':
3560
- if (panel.view.content.element.parentElement === this._element) {
3561
- this._element.removeChild(panel.view.content.element);
3562
- }
3563
- container = this.group.renderContainer.attach({
3564
- panel,
3565
- referenceContainer: this,
3566
- });
3567
- break;
3568
- }
3569
- if (doRender) {
3570
- const _onDidFocus = panel.view.content.onDidFocus;
3571
- const _onDidBlur = panel.view.content.onDidBlur;
3572
- const focusTracker = trackFocus(container);
3573
- const disposable = new CompositeDisposable();
3574
- disposable.addDisposables(focusTracker, focusTracker.onDidFocus(() => this._onDidFocus.fire()), focusTracker.onDidBlur(() => this._onDidBlur.fire()));
3575
- if (_onDidFocus) {
3576
- disposable.addDisposables(_onDidFocus(() => this._onDidFocus.fire()));
3577
- }
3578
- if (_onDidBlur) {
3579
- disposable.addDisposables(_onDidBlur(() => this._onDidBlur.fire()));
3580
- }
3581
- this.disposable.value = disposable;
3582
- }
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 === 'onlyWhenVisible') {
3597
- (_a = this.panel.view.content.element.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(this.panel.view.content.element);
3598
- }
3599
- }
3600
- this.panel = undefined;
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) {
4060
+ get headerVisible() {
4061
+ return this._headerVisible;
4062
+ }
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) {
3885
4127
  return;
3886
4128
  }
3887
- if (this.rightActions) {
3888
- this.rightActions.remove();
3889
- this.rightActions = 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
+ }
3890
4137
  }
3891
- if (element) {
3892
- this.rightActionsContainer.appendChild(element);
3893
- this.rightActions = element;
4138
+ else {
4139
+ this.animationTimer = setTimeout(() => {
4140
+ var _a;
4141
+ (_a = this.body) === null || _a === void 0 ? void 0 : _a.remove();
4142
+ }, 200);
3894
4143
  }
4144
+ this._onDidChange.fire(expanded ? { size: this.width } : {});
4145
+ this._onDidChangeExpansionState.fire(expanded);
3895
4146
  }
3896
- setLeftActionsElement(element) {
3897
- if (this.leftActions === element) {
3898
- return;
3899
- }
3900
- if (this.leftActions) {
3901
- this.leftActions.remove();
3902
- this.leftActions = undefined;
3903
- }
3904
- if (element) {
3905
- this.leftActionsContainer.appendChild(element);
3906
- this.leftActions = element;
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;
3907
4155
  }
4156
+ super.layout(width, height);
3908
4157
  }
3909
- setPrefixActionsElement(element) {
3910
- if (this.preActions === element) {
3911
- return;
4158
+ init(parameters) {
4159
+ var _a, _b;
4160
+ super.init(parameters);
4161
+ if (typeof parameters.minimumBodySize === 'number') {
4162
+ this.minimumBodySize = parameters.minimumBodySize;
3912
4163
  }
3913
- if (this.preActions) {
3914
- this.preActions.remove();
3915
- this.preActions = undefined;
4164
+ if (typeof parameters.maximumBodySize === 'number') {
4165
+ this.maximumBodySize = parameters.maximumBodySize;
3916
4166
  }
3917
- if (element) {
3918
- this.preActionsContainer.appendChild(element);
3919
- this.preActions = element;
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);
3920
4175
  }
3921
4176
  }
3922
- get element() {
3923
- return this._element;
4177
+ toJSON() {
4178
+ const params = this._params;
4179
+ return Object.assign(Object.assign({}, super.toJSON()), { headerComponent: this.headerComponent, title: params.title });
3924
4180
  }
3925
- isActive(tab) {
3926
- return (this.selectedIndex > -1 &&
3927
- this.tabs[this.selectedIndex].value === tab);
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);
3928
4193
  }
3929
- indexOf(id) {
3930
- return this.tabs.findIndex((tab) => tab.value.panel.id === id);
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
+ };
3931
4208
  }
3932
- constructor(accessor, group) {
3933
- super();
4209
+ }
4210
+
4211
+ class DraggablePaneviewPanel extends PaneviewPanel {
4212
+ constructor(accessor, id, component, headerComponent, orientation, isExpanded, disableDnd) {
4213
+ super(id, component, headerComponent, orientation, isExpanded, true);
3934
4214
  this.accessor = accessor;
3935
- this.group = group;
3936
- this.tabs = [];
3937
- this.selectedIndex = -1;
3938
- this._hidden = false;
3939
- this._onDrop = new Emitter();
3940
- this.onDrop = this._onDrop.event;
3941
- this._onTabDragStart = new Emitter();
3942
- this.onTabDragStart = this._onTabDragStart.event;
3943
- this._onGroupDragStart = new Emitter();
3944
- this.onGroupDragStart = this._onGroupDragStart.event;
3945
- this._onWillShowOverlay = new Emitter();
3946
- this.onWillShowOverlay = this._onWillShowOverlay.event;
3947
- this._element = document.createElement('div');
3948
- this._element.className = 'tabs-and-actions-container';
3949
- toggleClass(this._element, 'dv-full-width-single-tab', this.accessor.options.singleTabMode === 'fullwidth');
3950
- this.rightActionsContainer = document.createElement('div');
3951
- this.rightActionsContainer.className = 'right-actions-container';
3952
- this.leftActionsContainer = document.createElement('div');
3953
- this.leftActionsContainer.className = 'left-actions-container';
3954
- this.preActionsContainer = document.createElement('div');
3955
- this.preActionsContainer.className = 'pre-actions-container';
3956
- this.tabContainer = document.createElement('div');
3957
- this.tabContainer.className = 'tabs-container';
3958
- this.voidContainer = new VoidContainer(this.accessor, this.group);
3959
- this._element.appendChild(this.preActionsContainer);
3960
- this._element.appendChild(this.tabContainer);
3961
- this._element.appendChild(this.leftActionsContainer);
3962
- this._element.appendChild(this.voidContainer.element);
3963
- this._element.appendChild(this.rightActionsContainer);
3964
- this.addDisposables(this.accessor.onDidAddPanel((e) => {
3965
- if (e.api.group === this.group) {
3966
- toggleClass(this._element, 'dv-single-tab', this.size === 1);
3967
- }
3968
- }), this.accessor.onDidRemovePanel((e) => {
3969
- if (e.api.group === this.group) {
3970
- toggleClass(this._element, 'dv-single-tab', this.size === 1);
3971
- }
3972
- }), this._onWillShowOverlay, this._onDrop, this._onTabDragStart, this._onGroupDragStart, this.voidContainer, this.voidContainer.onDragStart((event) => {
3973
- this._onGroupDragStart.fire({
3974
- nativeEvent: event,
3975
- group: this.group,
3976
- });
3977
- }), this.voidContainer.onDrop((event) => {
3978
- this._onDrop.fire({
3979
- event: event.nativeEvent,
3980
- index: this.tabs.length,
3981
- });
3982
- }), this.voidContainer.onWillShowOverlay((event) => {
3983
- this._onWillShowOverlay.fire(new WillShowOverlayLocationEvent(event, {
3984
- kind: 'header_space',
3985
- panel: this.group.activePanel,
3986
- api: this.accessor.api,
3987
- group: this.group,
3988
- getData: getPanelData,
3989
- }));
3990
- }), addDisposableListener(this.voidContainer.element, 'mousedown', (event) => {
3991
- const isFloatingGroupsEnabled = !this.accessor.options.disableFloatingGroups;
3992
- if (isFloatingGroupsEnabled &&
3993
- event.shiftKey &&
3994
- this.group.api.location.type !== 'floating') {
3995
- event.preventDefault();
3996
- const { top, left } = this.element.getBoundingClientRect();
3997
- const { top: rootTop, left: rootLeft } = this.accessor.element.getBoundingClientRect();
3998
- this.accessor.addFloatingGroup(this.group, {
3999
- x: left - rootLeft + 20,
4000
- y: top - rootTop + 20,
4001
- }, { inDragMode: true });
4002
- }
4003
- }), addDisposableListener(this.tabContainer, 'mousedown', (event) => {
4004
- if (event.defaultPrevented) {
4005
- return;
4006
- }
4007
- const isLeftClick = event.button === 0;
4008
- if (isLeftClick) {
4009
- this.accessor.doSetGroupActive(this.group);
4010
- }
4011
- }));
4012
- }
4013
- setActive(_isGroupActive) {
4014
- // noop
4015
- }
4016
- addTab(tab, index = this.tabs.length) {
4017
- if (index < 0 || index > this.tabs.length) {
4018
- throw new Error('invalid location');
4019
- }
4020
- this.tabContainer.insertBefore(tab.value.element, this.tabContainer.children[index]);
4021
- this.tabs = [
4022
- ...this.tabs.slice(0, index),
4023
- tab,
4024
- ...this.tabs.slice(index),
4025
- ];
4026
- if (this.selectedIndex < 0) {
4027
- this.selectedIndex = index;
4215
+ this._onDidDrop = new Emitter();
4216
+ this.onDidDrop = this._onDidDrop.event;
4217
+ if (!disableDnd) {
4218
+ this.initDragFeatures();
4028
4219
  }
4029
4220
  }
4030
- delete(id) {
4031
- const index = this.tabs.findIndex((tab) => tab.value.panel.id === id);
4032
- const tabToRemove = this.tabs.splice(index, 1)[0];
4033
- const { value, disposable } = tabToRemove;
4034
- disposable.dispose();
4035
- value.dispose();
4036
- value.element.remove();
4037
- }
4038
- setActivePanel(panel) {
4039
- this.tabs.forEach((tab) => {
4040
- const isActivePanel = panel.id === tab.value.panel.id;
4041
- tab.value.setActive(isActivePanel);
4221
+ initDragFeatures() {
4222
+ if (!this.header) {
4223
+ return;
4224
+ }
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
+ };
4236
+ }
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
+ },
4042
4260
  });
4261
+ this.addDisposables(this._onDidDrop, this.handler, this.target, this.target.onDrop((event) => {
4262
+ this.onDrop(event);
4263
+ }));
4043
4264
  }
4044
- openPanel(panel, index = this.tabs.length) {
4045
- var _a;
4046
- if (this.tabs.find((tab) => tab.value.panel.id === panel.id)) {
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 }));
4047
4271
  return;
4048
4272
  }
4049
- const tab = new Tab(panel, this.accessor, this.group);
4050
- if (!((_a = panel.view) === null || _a === void 0 ? void 0 : _a.tab)) {
4051
- throw new Error('invalid header component');
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;
4052
4281
  }
4053
- tab.setContent(panel.view.tab);
4054
- const disposable = new CompositeDisposable(tab.onDragStart((event) => {
4055
- this._onTabDragStart.fire({ nativeEvent: event, panel });
4056
- }), tab.onChanged((event) => {
4057
- const isFloatingGroupsEnabled = !this.accessor.options.disableFloatingGroups;
4058
- const isFloatingWithOnePanel = this.group.api.location.type === 'floating' &&
4059
- this.size === 1;
4060
- if (isFloatingGroupsEnabled &&
4061
- !isFloatingWithOnePanel &&
4062
- event.shiftKey) {
4063
- event.preventDefault();
4064
- const panel = this.accessor.getGroupPanel(tab.panel.id);
4065
- const { top, left } = tab.element.getBoundingClientRect();
4066
- const { top: rootTop, left: rootLeft } = this.accessor.element.getBoundingClientRect();
4067
- this.accessor.addFloatingGroup(panel, {
4068
- x: left - rootLeft,
4069
- y: top - rootTop,
4070
- }, { inDragMode: true });
4071
- return;
4072
- }
4073
- const isLeftClick = event.button === 0;
4074
- if (!isLeftClick || event.defaultPrevented) {
4075
- return;
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);
4287
+ }
4288
+ if (event.position === 'right' || event.position === 'bottom') {
4289
+ if (fromIndex > toIndex) {
4290
+ toIndex++;
4076
4291
  }
4077
- if (this.group.activePanel !== panel) {
4078
- this.group.model.openPanel(panel);
4079
- }
4080
- }), tab.onDrop((event) => {
4081
- this._onDrop.fire({
4082
- event: event.nativeEvent,
4083
- index: this.tabs.findIndex((x) => x.value === tab),
4084
- });
4085
- }), tab.onWillShowOverlay((event) => {
4086
- this._onWillShowOverlay.fire(new WillShowOverlayLocationEvent(event, {
4087
- kind: 'tab',
4088
- panel: this.group.activePanel,
4089
- api: this.accessor.api,
4090
- group: this.group,
4091
- getData: getPanelData,
4092
- }));
4093
- }));
4094
- const value = { value: tab, disposable };
4095
- this.addTab(value, index);
4096
- }
4097
- closePanel(panel) {
4098
- this.delete(panel.id);
4099
- }
4100
- dispose() {
4101
- super.dispose();
4102
- for (const { value, disposable } of this.tabs) {
4103
- disposable.dispose();
4104
- value.dispose();
4292
+ toIndex = Math.min(allPanels.length - 1, toIndex);
4105
4293
  }
4106
- this.tabs = [];
4294
+ containerApi.movePanel(fromIndex, toIndex);
4107
4295
  }
4108
4296
  }
4109
4297
 
4110
- class DockviewDidDropEvent extends DockviewEvent {
4111
- get nativeEvent() {
4112
- return this.options.nativeEvent;
4298
+ class ContentContainer extends CompositeDisposable {
4299
+ get element() {
4300
+ return this._element;
4113
4301
  }
4114
- get position() {
4115
- return this.options.position;
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);
4116
4347
  }
4117
- get panel() {
4118
- return this.options.panel;
4348
+ show() {
4349
+ this.element.style.display = '';
4119
4350
  }
4120
- get group() {
4121
- return this.options.group;
4351
+ hide() {
4352
+ this.element.style.display = 'none';
4122
4353
  }
4123
- get api() {
4124
- return this.options.api;
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
+ }
4125
4392
  }
4126
- constructor(options) {
4127
- super();
4128
- this.options = options;
4393
+ openPanel(panel) {
4394
+ if (this.panel === panel) {
4395
+ return;
4396
+ }
4397
+ this.renderPanel(panel);
4129
4398
  }
4130
- getData() {
4131
- return this.options.getData();
4399
+ layout(_width, _height) {
4400
+ // noop
4132
4401
  }
4133
- }
4134
- class DockviewWillDropEvent extends DockviewDidDropEvent {
4135
- get kind() {
4136
- return this._kind;
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;
4137
4410
  }
4138
- constructor(options) {
4139
- super(options);
4140
- this._kind = options.kind;
4411
+ dispose() {
4412
+ this.disposable.dispose();
4413
+ super.dispose();
4141
4414
  }
4142
4415
  }
4143
- class WillShowOverlayLocationEvent {
4144
- get kind() {
4145
- return this.options.kind;
4146
- }
4147
- get nativeEvent() {
4148
- return this.event.nativeEvent;
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();
4149
4424
  }
4150
- get position() {
4151
- return this.event.position;
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
+ };
4152
4432
  }
4153
- get defaultPrevented() {
4154
- return this.event.defaultPrevented;
4433
+ }
4434
+ class Tab extends CompositeDisposable {
4435
+ get element() {
4436
+ return this._element;
4155
4437
  }
4156
- get panel() {
4157
- return this.options.panel;
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);
4158
4485
  }
4159
- get api() {
4160
- return this.options.api;
4486
+ setActive(isActive) {
4487
+ toggleClass(this.element, 'active-tab', isActive);
4488
+ toggleClass(this.element, 'inactive-tab', !isActive);
4161
4489
  }
4162
- get group() {
4163
- return this.options.group;
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);
4164
4496
  }
4165
- preventDefault() {
4166
- this.event.preventDefault();
4167
- }
4168
- getData() {
4169
- return this.options.getData();
4170
- }
4171
- constructor(event, options) {
4172
- this.event = event;
4173
- this.options = options;
4497
+ dispose() {
4498
+ super.dispose();
4174
4499
  }
4175
4500
  }
4176
- class DockviewGroupPanelModel extends CompositeDisposable {
4177
- get element() {
4178
- throw new Error('not supported');
4179
- }
4180
- get activePanel() {
4181
- return this._activePanel;
4182
- }
4183
- get locked() {
4184
- return this._locked;
4185
- }
4186
- set locked(value) {
4187
- this._locked = value;
4188
- toggleClass(this.container, 'locked-groupview', value === 'no-drop-target' || value);
4189
- }
4190
- get isActive() {
4191
- return this._isGroupActive;
4192
- }
4193
- get panels() {
4194
- return this._panels;
4195
- }
4196
- get size() {
4197
- return this._panels.length;
4198
- }
4199
- get isEmpty() {
4200
- return this._panels.length === 0;
4201
- }
4202
- get hasWatermark() {
4203
- return !!(this.watermark && this.container.contains(this.watermark.element));
4204
- }
4205
- get header() {
4206
- return this.tabsContainer;
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));
4207
4529
  }
4208
- get isContentFocused() {
4209
- if (!document.activeElement) {
4210
- return false;
4530
+ isCancelled(_event) {
4531
+ if (this.group.api.location.type === 'floating' && !_event.shiftKey) {
4532
+ return true;
4211
4533
  }
4212
- return isAncestor(document.activeElement, this.contentContainer.element);
4213
- }
4214
- get location() {
4215
- return this._location;
4534
+ return false;
4216
4535
  }
4217
- set location(value) {
4218
- this._location = value;
4219
- toggleClass(this.container, 'dv-groupview-floating', false);
4220
- toggleClass(this.container, 'dv-groupview-popout', false);
4221
- switch (value.type) {
4222
- case 'grid':
4223
- this.contentContainer.dropTarget.setTargetZones([
4224
- 'top',
4225
- 'bottom',
4226
- 'left',
4227
- 'right',
4228
- 'center',
4229
- ]);
4230
- break;
4231
- case 'floating':
4232
- this.contentContainer.dropTarget.setTargetZones(['center']);
4233
- this.contentContainer.dropTarget.setTargetZones(value
4234
- ? ['center']
4235
- : ['top', 'bottom', 'left', 'right', 'center']);
4236
- toggleClass(this.container, 'dv-groupview-floating', true);
4237
- break;
4238
- case 'popout':
4239
- this.contentContainer.dropTarget.setTargetZones(['center']);
4240
- toggleClass(this.container, 'dv-groupview-popout', true);
4241
- break;
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);
4242
4554
  }
4243
- this.groupPanel.api._onDidLocationChange.fire({
4244
- location: this.location,
4245
- });
4555
+ return {
4556
+ dispose: () => {
4557
+ this.panelTransfer.clearData(PanelTransfer.prototype);
4558
+ },
4559
+ };
4246
4560
  }
4247
- constructor(container, accessor, id, options, groupPanel) {
4248
- var _a;
4561
+ }
4562
+
4563
+ class VoidContainer extends CompositeDisposable {
4564
+ get element() {
4565
+ return this._element;
4566
+ }
4567
+ constructor(accessor, group) {
4249
4568
  super();
4250
- this.container = container;
4251
4569
  this.accessor = accessor;
4252
- this.id = id;
4253
- this.options = options;
4254
- this.groupPanel = groupPanel;
4255
- this._isGroupActive = false;
4256
- this._locked = false;
4257
- this._location = { type: 'grid' };
4258
- this.mostRecentlyUsed = [];
4259
- this._onDidChange = new Emitter();
4260
- this.onDidChange = this._onDidChange.event;
4261
- this._width = 0;
4262
- this._height = 0;
4263
- this._panels = [];
4264
- this._panelDisposables = new Map();
4265
- this._onMove = new Emitter();
4266
- this.onMove = this._onMove.event;
4267
- this._onDidDrop = new Emitter();
4268
- this.onDidDrop = this._onDidDrop.event;
4269
- this._onWillDrop = new Emitter();
4270
- this.onWillDrop = this._onWillDrop.event;
4271
- this._onWillShowOverlay = new Emitter();
4272
- this.onWillShowOverlay = this._onWillShowOverlay.event;
4273
- this._onTabDragStart = new Emitter();
4274
- this.onTabDragStart = this._onTabDragStart.event;
4275
- this._onGroupDragStart = new Emitter();
4276
- this.onGroupDragStart = this._onGroupDragStart.event;
4277
- this._onDidAddPanel = new Emitter();
4278
- this.onDidAddPanel = this._onDidAddPanel.event;
4279
- this._onDidPanelTitleChange = new Emitter();
4280
- this.onDidPanelTitleChange = this._onDidPanelTitleChange.event;
4281
- this._onDidPanelParametersChange = new Emitter();
4282
- this.onDidPanelParametersChange = this._onDidPanelParametersChange.event;
4283
- this._onDidRemovePanel = new Emitter();
4284
- this.onDidRemovePanel = this._onDidRemovePanel.event;
4285
- this._onDidActivePanelChange = new Emitter();
4286
- this.onDidActivePanelChange = this._onDidActivePanelChange.event;
4287
- this._overwriteRenderContainer = null;
4288
- toggleClass(this.container, 'groupview', true);
4289
- this._api = new DockviewApi(this.accessor);
4290
- this.tabsContainer = new TabsContainer(this.accessor, this.groupPanel);
4291
- this.contentContainer = new ContentContainer(this.accessor, this);
4292
- container.append(this.tabsContainer.element, this.contentContainer.element);
4293
- this.header.hidden = !!options.hideHeader;
4294
- this.locked = (_a = options.locked) !== null && _a !== void 0 ? _a : false;
4295
- this.addDisposables(this._onTabDragStart, this._onGroupDragStart, this._onWillShowOverlay, this.tabsContainer.onTabDragStart((event) => {
4296
- this._onTabDragStart.fire(event);
4297
- }), this.tabsContainer.onGroupDragStart((event) => {
4298
- this._onGroupDragStart.fire(event);
4299
- }), this.tabsContainer.onDrop((event) => {
4300
- this.handleDropEvent('header', event.event, 'center', event.index);
4301
- }), this.contentContainer.onDidFocus(() => {
4302
- this.accessor.doSetGroupActive(this.groupPanel);
4303
- }), this.contentContainer.onDidBlur(() => {
4304
- // noop
4305
- }), this.contentContainer.dropTarget.onDrop((event) => {
4306
- this.handleDropEvent('content', event.nativeEvent, event.position);
4307
- }), this.tabsContainer.onWillShowOverlay((event) => {
4308
- this._onWillShowOverlay.fire(event);
4309
- }), this.contentContainer.dropTarget.onWillShowOverlay((event) => {
4310
- this._onWillShowOverlay.fire(new WillShowOverlayLocationEvent(event, {
4311
- kind: 'content',
4312
- panel: this.activePanel,
4313
- api: this._api,
4314
- group: this.groupPanel,
4315
- getData: getPanelData,
4316
- }));
4317
- }), this._onMove, this._onDidChange, this._onDidDrop, this._onWillDrop, this._onDidAddPanel, this._onDidRemovePanel, this._onDidActivePanelChange);
4318
- }
4319
- focusContent() {
4320
- this.contentContainer.element.focus();
4321
- }
4322
- set renderContainer(value) {
4323
- this.panels.forEach((panel) => {
4324
- this.renderContainer.detatch(panel);
4325
- });
4326
- this._overwriteRenderContainer = value;
4327
- this.panels.forEach((panel) => {
4328
- this.rerender(panel);
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
+ },
4329
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);
4330
4606
  }
4331
- get renderContainer() {
4332
- var _a;
4333
- return ((_a = this._overwriteRenderContainer) !== null && _a !== void 0 ? _a : this.accessor.overlayRenderContainer);
4607
+ }
4608
+
4609
+ class TabsContainer extends CompositeDisposable {
4610
+ get panels() {
4611
+ return this.tabs.map((_) => _.value.panel.id);
4334
4612
  }
4335
- initialize() {
4336
- if (this.options.panels) {
4337
- this.options.panels.forEach((panel) => {
4338
- this.doAddPanel(panel);
4339
- });
4340
- }
4341
- if (this.options.activePanel) {
4342
- this.openPanel(this.options.activePanel);
4343
- }
4344
- // must be run after the constructor otherwise this.parent may not be
4345
- // correctly initialized
4346
- this.setActive(this.isActive, true);
4347
- this.updateContainer();
4348
- if (this.accessor.options.createRightHeaderActionsElement) {
4349
- this._rightHeaderActions =
4350
- this.accessor.options.createRightHeaderActionsElement(this.groupPanel);
4351
- this.addDisposables(this._rightHeaderActions);
4352
- this._rightHeaderActions.init({
4353
- containerApi: this._api,
4354
- api: this.groupPanel.api,
4355
- });
4356
- this.tabsContainer.setRightActionsElement(this._rightHeaderActions.element);
4357
- }
4358
- if (this.accessor.options.createLeftHeaderActionsElement) {
4359
- this._leftHeaderActions =
4360
- this.accessor.options.createLeftHeaderActionsElement(this.groupPanel);
4361
- this.addDisposables(this._leftHeaderActions);
4362
- this._leftHeaderActions.init({
4363
- containerApi: this._api,
4364
- api: this.groupPanel.api,
4365
- });
4366
- this.tabsContainer.setLeftActionsElement(this._leftHeaderActions.element);
4367
- }
4368
- if (this.accessor.options.createPrefixHeaderActionsElement) {
4369
- this._prefixHeaderActions =
4370
- this.accessor.options.createPrefixHeaderActionsElement(this.groupPanel);
4371
- this.addDisposables(this._prefixHeaderActions);
4372
- this._prefixHeaderActions.init({
4373
- containerApi: this._api,
4374
- api: this.groupPanel.api,
4375
- });
4376
- this.tabsContainer.setPrefixActionsElement(this._prefixHeaderActions.element);
4377
- }
4378
- }
4379
- rerender(panel) {
4380
- this.contentContainer.renderPanel(panel, { asActive: false });
4381
- }
4382
- indexOf(panel) {
4383
- return this.tabsContainer.indexOf(panel.id);
4384
- }
4385
- toJSON() {
4386
- var _a;
4387
- const result = {
4388
- views: this.tabsContainer.panels,
4389
- activeView: (_a = this._activePanel) === null || _a === void 0 ? void 0 : _a.id,
4390
- id: this.id,
4391
- };
4392
- if (this.locked !== false) {
4393
- result.locked = this.locked;
4394
- }
4395
- if (this.header.hidden) {
4396
- result.hideHeader = true;
4397
- }
4398
- return result;
4399
- }
4400
- moveToNext(options) {
4401
- if (!options) {
4402
- options = {};
4403
- }
4404
- if (!options.panel) {
4405
- options.panel = this.activePanel;
4406
- }
4407
- const index = options.panel ? this.panels.indexOf(options.panel) : -1;
4408
- let normalizedIndex;
4409
- if (index < this.panels.length - 1) {
4410
- normalizedIndex = index + 1;
4411
- }
4412
- else if (!options.suppressRoll) {
4413
- normalizedIndex = 0;
4414
- }
4415
- else {
4416
- return;
4417
- }
4418
- this.openPanel(this.panels[normalizedIndex]);
4419
- }
4420
- moveToPrevious(options) {
4421
- if (!options) {
4422
- options = {};
4423
- }
4424
- if (!options.panel) {
4425
- options.panel = this.activePanel;
4426
- }
4427
- if (!options.panel) {
4428
- return;
4429
- }
4430
- const index = this.panels.indexOf(options.panel);
4431
- let normalizedIndex;
4432
- if (index > 0) {
4433
- normalizedIndex = index - 1;
4434
- }
4435
- else if (!options.suppressRoll) {
4436
- normalizedIndex = this.panels.length - 1;
4437
- }
4438
- else {
4439
- return;
4440
- }
4441
- this.openPanel(this.panels[normalizedIndex]);
4442
- }
4443
- containsPanel(panel) {
4444
- return this.panels.includes(panel);
4445
- }
4446
- init(_params) {
4447
- //noop
4448
- }
4449
- update(_params) {
4450
- //noop
4451
- }
4452
- focus() {
4453
- var _a;
4454
- (_a = this._activePanel) === null || _a === void 0 ? void 0 : _a.focus();
4455
- }
4456
- openPanel(panel, options = {}) {
4457
- /**
4458
- * set the panel group
4459
- * add the panel
4460
- * check if group active
4461
- * check if panel active
4462
- */
4463
- if (typeof options.index !== 'number' ||
4464
- options.index > this.panels.length) {
4465
- options.index = this.panels.length;
4466
- }
4467
- const skipSetActive = !!options.skipSetActive;
4468
- // ensure the group is updated before we fire any events
4469
- panel.updateParentGroup(this.groupPanel, {
4470
- skipSetActive: options.skipSetActive,
4471
- });
4472
- this.doAddPanel(panel, options.index, {
4473
- skipSetActive: skipSetActive,
4474
- });
4475
- if (this._activePanel === panel) {
4476
- this.contentContainer.renderPanel(panel, { asActive: true });
4477
- return;
4478
- }
4479
- if (!skipSetActive) {
4480
- this.doSetActivePanel(panel);
4481
- }
4482
- if (!options.skipSetGroupActive) {
4483
- this.accessor.doSetGroupActive(this.groupPanel);
4484
- }
4485
- if (!options.skipSetActive) {
4486
- this.updateContainer();
4487
- }
4488
- }
4489
- removePanel(groupItemOrId, options = {
4490
- skipSetActive: false,
4491
- }) {
4492
- const id = typeof groupItemOrId === 'string'
4493
- ? groupItemOrId
4494
- : groupItemOrId.id;
4495
- const panelToRemove = this._panels.find((panel) => panel.id === id);
4496
- if (!panelToRemove) {
4497
- throw new Error('invalid operation');
4498
- }
4499
- return this._removePanel(panelToRemove, options);
4500
- }
4501
- closeAllPanels() {
4502
- if (this.panels.length > 0) {
4503
- // take a copy since we will be edting the array as we iterate through
4504
- const arrPanelCpy = [...this.panels];
4505
- for (const panel of arrPanelCpy) {
4506
- this.doClose(panel);
4507
- }
4508
- }
4509
- else {
4510
- this.accessor.removeGroup(this.groupPanel);
4511
- }
4512
- }
4513
- closePanel(panel) {
4514
- this.doClose(panel);
4515
- }
4516
- doClose(panel) {
4517
- this.accessor.removePanel(panel);
4518
- }
4519
- isPanelActive(panel) {
4520
- return this._activePanel === panel;
4521
- }
4522
- updateActions(element) {
4523
- this.tabsContainer.setRightActionsElement(element);
4524
- }
4525
- setActive(isGroupActive, force = false) {
4526
- if (!force && this.isActive === isGroupActive) {
4527
- return;
4528
- }
4529
- this._isGroupActive = isGroupActive;
4530
- toggleClass(this.container, 'active-group', isGroupActive);
4531
- toggleClass(this.container, 'inactive-group', !isGroupActive);
4532
- this.tabsContainer.setActive(this.isActive);
4533
- if (!this._activePanel && this.panels.length > 0) {
4534
- this.doSetActivePanel(this.panels[0]);
4535
- }
4536
- this.updateContainer();
4537
- }
4538
- layout(width, height) {
4539
- var _a;
4540
- this._width = width;
4541
- this._height = height;
4542
- this.contentContainer.layout(this._width, this._height);
4543
- if ((_a = this._activePanel) === null || _a === void 0 ? void 0 : _a.layout) {
4544
- this._activePanel.layout(this._width, this._height);
4545
- }
4546
- }
4547
- _removePanel(panel, options) {
4548
- const isActivePanel = this._activePanel === panel;
4549
- this.doRemovePanel(panel);
4550
- if (isActivePanel && this.panels.length > 0) {
4551
- const nextPanel = this.mostRecentlyUsed[0];
4552
- this.openPanel(nextPanel, {
4553
- skipSetActive: options.skipSetActive,
4554
- skipSetGroupActive: options.skipSetActiveGroup,
4555
- });
4556
- }
4557
- if (this._activePanel && this.panels.length === 0) {
4558
- this.doSetActivePanel(undefined);
4559
- }
4560
- if (!options.skipSetActive) {
4561
- this.updateContainer();
4562
- }
4563
- return panel;
4564
- }
4565
- doRemovePanel(panel) {
4566
- const index = this.panels.indexOf(panel);
4567
- if (this._activePanel === panel) {
4568
- this.contentContainer.closePanel();
4569
- }
4570
- this.tabsContainer.delete(panel.id);
4571
- this._panels.splice(index, 1);
4572
- if (this.mostRecentlyUsed.includes(panel)) {
4573
- this.mostRecentlyUsed.splice(this.mostRecentlyUsed.indexOf(panel), 1);
4574
- }
4575
- const disposable = this._panelDisposables.get(panel.id);
4576
- if (disposable) {
4577
- disposable.dispose();
4578
- this._panelDisposables.delete(panel.id);
4579
- }
4580
- this._onDidRemovePanel.fire({ panel });
4581
- }
4582
- doAddPanel(panel, index = this.panels.length, options = { skipSetActive: false }) {
4583
- const existingPanel = this._panels.indexOf(panel);
4584
- const hasExistingPanel = existingPanel > -1;
4585
- this.tabsContainer.show();
4586
- this.contentContainer.show();
4587
- this.tabsContainer.openPanel(panel, index);
4588
- if (!options.skipSetActive) {
4589
- this.contentContainer.openPanel(panel);
4590
- }
4591
- if (hasExistingPanel) {
4592
- // TODO - need to ensure ordering hasn't changed and if it has need to re-order this.panels
4593
- return;
4594
- }
4595
- this.updateMru(panel);
4596
- this.panels.splice(index, 0, panel);
4597
- this._panelDisposables.set(panel.id, new CompositeDisposable(panel.api.onDidTitleChange((event) => this._onDidPanelTitleChange.fire(event)), panel.api.onDidParametersChange((event) => this._onDidPanelParametersChange.fire(event))));
4598
- this._onDidAddPanel.fire({ panel });
4599
- }
4600
- doSetActivePanel(panel) {
4601
- if (this._activePanel === panel) {
4602
- return;
4603
- }
4604
- this._activePanel = panel;
4605
- if (panel) {
4606
- this.tabsContainer.setActivePanel(panel);
4607
- panel.layout(this._width, this._height);
4608
- this.updateMru(panel);
4609
- this._onDidActivePanelChange.fire({
4610
- panel,
4611
- });
4612
- }
4613
- }
4614
- updateMru(panel) {
4615
- if (this.mostRecentlyUsed.includes(panel)) {
4616
- this.mostRecentlyUsed.splice(this.mostRecentlyUsed.indexOf(panel), 1);
4617
- }
4618
- this.mostRecentlyUsed = [panel, ...this.mostRecentlyUsed];
4619
- }
4620
- updateContainer() {
4621
- var _a, _b;
4622
- toggleClass(this.container, 'empty', this.isEmpty);
4623
- this.panels.forEach((panel) => panel.runEvents());
4624
- if (this.isEmpty && !this.watermark) {
4625
- const watermark = this.accessor.createWatermarkComponent();
4626
- watermark.init({
4627
- containerApi: this._api,
4628
- group: this.groupPanel,
4629
- });
4630
- this.watermark = watermark;
4631
- addDisposableListener(this.watermark.element, 'click', () => {
4632
- if (!this.isActive) {
4633
- this.accessor.doSetGroupActive(this.groupPanel);
4634
- }
4635
- });
4636
- this.tabsContainer.hide();
4637
- this.contentContainer.element.appendChild(this.watermark.element);
4638
- this.watermark.updateParentGroup(this.groupPanel, true);
4639
- }
4640
- if (!this.isEmpty && this.watermark) {
4641
- this.watermark.element.remove();
4642
- (_b = (_a = this.watermark).dispose) === null || _b === void 0 ? void 0 : _b.call(_a);
4643
- this.watermark = undefined;
4644
- this.tabsContainer.show();
4645
- }
4613
+ get size() {
4614
+ return this.tabs.length;
4646
4615
  }
4647
- canDisplayOverlay(event, position, target) {
4648
- // custom overlay handler
4649
- if (this.accessor.options.showDndOverlay) {
4650
- return this.accessor.options.showDndOverlay({
4651
- nativeEvent: event,
4652
- target,
4653
- group: this.accessor.getPanel(this.id),
4654
- position,
4655
- getData: getPanelData,
4656
- });
4657
- }
4658
- return false;
4616
+ get hidden() {
4617
+ return this._hidden;
4659
4618
  }
4660
- handleDropEvent(type, event, position, index) {
4661
- if (this.locked === 'no-drop-target') {
4662
- return;
4663
- }
4664
- function getKind() {
4665
- switch (type) {
4666
- case 'header':
4667
- return typeof index === 'number' ? 'tab' : 'header_space';
4668
- case 'content':
4669
- return 'content';
4670
- }
4671
- }
4672
- const panel = typeof index === 'number' ? this.panels[index] : undefined;
4673
- const willDropEvent = new DockviewWillDropEvent({
4674
- nativeEvent: event,
4675
- position,
4676
- panel,
4677
- getData: () => getPanelData(),
4678
- kind: getKind(),
4679
- group: this.groupPanel,
4680
- api: this._api,
4681
- });
4682
- this._onWillDrop.fire(willDropEvent);
4683
- if (willDropEvent.defaultPrevented) {
4684
- return;
4685
- }
4686
- const data = getPanelData();
4687
- if (data && data.viewId === this.accessor.id) {
4688
- if (data.panelId === null) {
4689
- // this is a group move dnd event
4690
- const { groupId } = data;
4691
- this._onMove.fire({
4692
- target: position,
4693
- groupId: groupId,
4694
- index,
4695
- });
4696
- return;
4697
- }
4698
- const fromSameGroup = this.tabsContainer.indexOf(data.panelId) !== -1;
4699
- if (fromSameGroup && this.tabsContainer.size === 1) {
4700
- return;
4701
- }
4702
- const { groupId, panelId } = data;
4703
- const isSameGroup = this.id === groupId;
4704
- if (isSameGroup && !position) {
4705
- const oldIndex = this.tabsContainer.indexOf(panelId);
4706
- if (oldIndex === index) {
4707
- return;
4708
- }
4709
- }
4710
- this._onMove.fire({
4711
- target: position,
4712
- groupId: data.groupId,
4713
- itemId: data.panelId,
4714
- index,
4715
- });
4619
+ set hidden(value) {
4620
+ this._hidden = value;
4621
+ this.element.style.display = value ? 'none' : '';
4622
+ }
4623
+ show() {
4624
+ if (!this.hidden) {
4625
+ this.element.style.display = '';
4716
4626
  }
4717
- else {
4718
- this._onDidDrop.fire(new DockviewDidDropEvent({
4719
- nativeEvent: event,
4720
- position,
4721
- panel,
4722
- getData: () => getPanelData(),
4723
- group: this.groupPanel,
4724
- api: this._api,
4725
- }));
4627
+ }
4628
+ hide() {
4629
+ this._element.style.display = 'none';
4630
+ }
4631
+ setRightActionsElement(element) {
4632
+ if (this.rightActions === element) {
4633
+ return;
4634
+ }
4635
+ if (this.rightActions) {
4636
+ this.rightActions.remove();
4637
+ this.rightActions = undefined;
4638
+ }
4639
+ if (element) {
4640
+ this.rightActionsContainer.appendChild(element);
4641
+ this.rightActions = element;
4726
4642
  }
4727
4643
  }
4728
- dispose() {
4729
- var _a, _b, _c;
4730
- super.dispose();
4731
- (_a = this.watermark) === null || _a === void 0 ? void 0 : _a.element.remove();
4732
- (_c = (_b = this.watermark) === null || _b === void 0 ? void 0 : _b.dispose) === null || _c === void 0 ? void 0 : _c.call(_b);
4733
- this.watermark = undefined;
4734
- for (const panel of this.panels) {
4735
- panel.dispose();
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
+ }
4656
+ }
4657
+ setPrefixActionsElement(element) {
4658
+ if (this.preActions === element) {
4659
+ return;
4660
+ }
4661
+ if (this.preActions) {
4662
+ this.preActions.remove();
4663
+ this.preActions = undefined;
4664
+ }
4665
+ if (element) {
4666
+ this.preActionsContainer.appendChild(element);
4667
+ this.preActions = element;
4736
4668
  }
4737
- this.tabsContainer.dispose();
4738
- this.contentContainer.dispose();
4739
4669
  }
4740
- }
4741
-
4742
- class Resizable extends CompositeDisposable {
4743
4670
  get element() {
4744
4671
  return this._element;
4745
4672
  }
4746
- get disableResizing() {
4747
- return this._disableResizing;
4673
+ isActive(tab) {
4674
+ return (this.selectedIndex > -1 &&
4675
+ this.tabs[this.selectedIndex].value === tab);
4748
4676
  }
4749
- set disableResizing(value) {
4750
- this._disableResizing = value;
4677
+ indexOf(id) {
4678
+ return this.tabs.findIndex((tab) => tab.value.panel.id === id);
4751
4679
  }
4752
- constructor(parentElement, disableResizing = false) {
4680
+ constructor(accessor, group) {
4753
4681
  super();
4754
- this._disableResizing = disableResizing;
4755
- this._element = parentElement;
4756
- this.addDisposables(watchElementResize(this._element, (entry) => {
4757
- if (this.isDisposed) {
4758
- /**
4759
- * resize is delayed through requestAnimationFrame so there is a small chance
4760
- * the component has already been disposed of
4761
- */
4762
- return;
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);
4763
4715
  }
4764
- if (this.disableResizing) {
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) {
4765
4753
  return;
4766
4754
  }
4767
- if (!this._element.offsetParent) {
4768
- /**
4769
- * offsetParent === null is equivalent to display: none being set on the element or one
4770
- * of it's parents. In the display: none case the size will become (0, 0) which we do
4771
- * not want to propagate.
4772
- *
4773
- * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetParent
4774
- *
4775
- * You could use checkVisibility() but at the time of writing it's not supported across
4776
- * all Browsers
4777
- *
4778
- * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility
4779
- */
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) {
4793
+ var _a;
4794
+ if (this.tabs.find((tab) => tab.value.panel.id === panel.id)) {
4795
+ return;
4796
+ }
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 });
4780
4819
  return;
4781
4820
  }
4782
- if (!isInDocument(this._element)) {
4783
- /**
4784
- * since the event is dispatched through requestAnimationFrame there is a small chance
4785
- * the component is no longer attached to the DOM, if that is the case the dimensions
4786
- * are mostly likely all zero and meaningless. we should skip this case.
4787
- */
4821
+ const isLeftClick = event.button === 0;
4822
+ if (!isLeftClick || event.defaultPrevented) {
4788
4823
  return;
4789
4824
  }
4790
- const { width, height } = entry.contentRect;
4791
- this.layout(width, height);
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
+ }));
4792
4841
  }));
4842
+ const value = { value: tab, disposable };
4843
+ this.addTab(value, index);
4793
4844
  }
4794
- }
4795
-
4796
- const nextLayoutId$1 = sequentialNumberGenerator();
4797
- function toTarget(direction) {
4798
- switch (direction) {
4799
- case 'left':
4800
- return 'left';
4801
- case 'right':
4802
- return 'right';
4803
- case 'above':
4804
- return 'top';
4805
- case 'below':
4806
- return 'bottom';
4807
- case 'within':
4808
- default:
4809
- return 'center';
4845
+ closePanel(panel) {
4846
+ this.delete(panel.id);
4847
+ }
4848
+ dispose() {
4849
+ super.dispose();
4850
+ for (const { value, disposable } of this.tabs) {
4851
+ disposable.dispose();
4852
+ value.dispose();
4853
+ }
4854
+ this.tabs = [];
4810
4855
  }
4811
4856
  }
4812
- class BaseGrid extends Resizable {
4813
- get id() {
4814
- return this._id;
4857
+
4858
+ class DockviewUnhandledDragOverEvent {
4859
+ get isAccepted() {
4860
+ return this._isAccepted;
4815
4861
  }
4816
- get size() {
4817
- return this._groups.size;
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;
4818
4869
  }
4819
- get groups() {
4820
- return Array.from(this._groups.values()).map((_) => _.value);
4870
+ accept() {
4871
+ this._isAccepted = true;
4821
4872
  }
4822
- get width() {
4823
- return this.gridview.width;
4873
+ }
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;
4824
4897
  }
4825
- get height() {
4826
- return this.gridview.height;
4898
+ return false;
4899
+ }
4900
+ function isPanelOptionsWithGroup(data) {
4901
+ if (data.referenceGroup) {
4902
+ return true;
4827
4903
  }
4828
- get minimumHeight() {
4829
- return this.gridview.minimumHeight;
4904
+ return false;
4905
+ }
4906
+ function isGroupOptionsWithPanel(data) {
4907
+ if (data.referencePanel) {
4908
+ return true;
4830
4909
  }
4831
- get maximumHeight() {
4832
- return this.gridview.maximumHeight;
4910
+ return false;
4911
+ }
4912
+ function isGroupOptionsWithGroup(data) {
4913
+ if (data.referenceGroup) {
4914
+ return true;
4833
4915
  }
4834
- get minimumWidth() {
4835
- return this.gridview.minimumWidth;
4916
+ return false;
4917
+ }
4918
+
4919
+ class DockviewDidDropEvent extends DockviewEvent {
4920
+ get nativeEvent() {
4921
+ return this.options.nativeEvent;
4836
4922
  }
4837
- get maximumWidth() {
4838
- return this.gridview.maximumWidth;
4923
+ get position() {
4924
+ return this.options.position;
4839
4925
  }
4840
- get activeGroup() {
4841
- return this._activeGroup;
4926
+ get panel() {
4927
+ return this.options.panel;
4842
4928
  }
4843
- get locked() {
4844
- return this.gridview.locked;
4929
+ get group() {
4930
+ return this.options.group;
4845
4931
  }
4846
- set locked(value) {
4847
- this.gridview.locked = value;
4932
+ get api() {
4933
+ return this.options.api;
4848
4934
  }
4849
4935
  constructor(options) {
4850
- super(document.createElement('div'), options.disableAutoResizing);
4851
- this._id = nextLayoutId$1.next();
4852
- this._groups = new Map();
4853
- this._onDidLayoutChange = new Emitter();
4854
- this.onDidLayoutChange = this._onDidLayoutChange.event;
4855
- this._onDidRemove = new Emitter();
4856
- this.onDidRemove = this._onDidRemove.event;
4857
- this._onDidAdd = new Emitter();
4858
- this.onDidAdd = this._onDidAdd.event;
4859
- this._onDidActiveChange = new Emitter();
4860
- this.onDidActiveChange = this._onDidActiveChange.event;
4861
- this._bufferOnDidLayoutChange = new TickDelayedEvent();
4862
- this.element.style.height = '100%';
4863
- this.element.style.width = '100%';
4864
- options.parentElement.appendChild(this.element);
4865
- this.gridview = new Gridview(!!options.proportionalLayout, options.styles, options.orientation);
4866
- this.gridview.locked = !!options.locked;
4867
- this.element.appendChild(this.gridview.element);
4868
- this.layout(0, 0, true); // set some elements height/widths
4869
- this.addDisposables(Disposable.from(() => {
4870
- var _a;
4871
- (_a = this.element.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(this.element);
4872
- }), this.gridview.onDidChange(() => {
4873
- this._bufferOnDidLayoutChange.fire();
4874
- }), exports.DockviewEvent.any(this.onDidAdd, this.onDidRemove, this.onDidActiveChange)(() => {
4875
- this._bufferOnDidLayoutChange.fire();
4876
- }), this._bufferOnDidLayoutChange.onEvent(() => {
4877
- this._onDidLayoutChange.fire();
4878
- }), this._bufferOnDidLayoutChange);
4879
- }
4880
- setVisible(panel, visible) {
4881
- this.gridview.setViewVisible(getGridLocation(panel.element), visible);
4882
- this._onDidLayoutChange.fire();
4883
- }
4884
- isVisible(panel) {
4885
- return this.gridview.isViewVisible(getGridLocation(panel.element));
4886
- }
4887
- maximizeGroup(panel) {
4888
- this.gridview.maximizeView(panel);
4889
- this.doSetGroupActive(panel);
4890
- }
4891
- isMaximizedGroup(panel) {
4892
- return this.gridview.maximizedView() === panel;
4893
- }
4894
- exitMaximizedGroup() {
4895
- this.gridview.exitMaximizedView();
4896
- }
4897
- hasMaximizedGroup() {
4898
- return this.gridview.hasMaximizedView();
4899
- }
4900
- get onDidMaximizedGroupChange() {
4901
- return this.gridview.onDidMaximizedNodeChange;
4936
+ super();
4937
+ this.options = options;
4902
4938
  }
4903
- doAddGroup(group, location = [0], size) {
4904
- this.gridview.addView(group, size !== null && size !== void 0 ? size : exports.Sizing.Distribute, location);
4905
- this._onDidAdd.fire(group);
4939
+ getData() {
4940
+ return this.options.getData();
4906
4941
  }
4907
- doRemoveGroup(group, options) {
4908
- if (!this._groups.has(group.id)) {
4909
- throw new Error('invalid operation');
4910
- }
4911
- const item = this._groups.get(group.id);
4912
- const view = this.gridview.remove(group, exports.Sizing.Distribute);
4913
- if (item && !(options === null || options === void 0 ? void 0 : options.skipDispose)) {
4914
- item.disposable.dispose();
4915
- item.value.dispose();
4916
- this._groups.delete(group.id);
4917
- this._onDidRemove.fire(group);
4918
- }
4919
- if (!(options === null || options === void 0 ? void 0 : options.skipActive) && this._activeGroup === group) {
4920
- const groups = Array.from(this._groups.values());
4921
- this.doSetGroupActive(groups.length > 0 ? groups[0].value : undefined);
4922
- }
4923
- return view;
4942
+ }
4943
+ class DockviewWillDropEvent extends DockviewDidDropEvent {
4944
+ get kind() {
4945
+ return this._kind;
4924
4946
  }
4925
- getPanel(id) {
4926
- var _a;
4927
- return (_a = this._groups.get(id)) === null || _a === void 0 ? void 0 : _a.value;
4947
+ constructor(options) {
4948
+ super(options);
4949
+ this._kind = options.kind;
4928
4950
  }
4929
- doSetGroupActive(group) {
4930
- if (this._activeGroup === group) {
4931
- return;
4932
- }
4933
- if (this._activeGroup) {
4934
- this._activeGroup.setActive(false);
4935
- }
4936
- if (group) {
4937
- group.setActive(true);
4938
- }
4939
- this._activeGroup = group;
4940
- this._onDidActiveChange.fire(group);
4951
+ }
4952
+ class WillShowOverlayLocationEvent {
4953
+ get kind() {
4954
+ return this.options.kind;
4941
4955
  }
4942
- removeGroup(group) {
4943
- this.doRemoveGroup(group);
4956
+ get nativeEvent() {
4957
+ return this.event.nativeEvent;
4944
4958
  }
4945
- moveToNext(options) {
4946
- var _a;
4947
- if (!options) {
4948
- options = {};
4949
- }
4950
- if (!options.group) {
4951
- if (!this.activeGroup) {
4952
- return;
4953
- }
4954
- options.group = this.activeGroup;
4955
- }
4956
- const location = getGridLocation(options.group.element);
4957
- const next = (_a = this.gridview.next(location)) === null || _a === void 0 ? void 0 : _a.view;
4958
- this.doSetGroupActive(next);
4959
+ get position() {
4960
+ return this.event.position;
4959
4961
  }
4960
- moveToPrevious(options) {
4961
- var _a;
4962
- if (!options) {
4963
- options = {};
4964
- }
4965
- if (!options.group) {
4966
- if (!this.activeGroup) {
4967
- return;
4968
- }
4969
- options.group = this.activeGroup;
4970
- }
4971
- const location = getGridLocation(options.group.element);
4972
- const next = (_a = this.gridview.previous(location)) === null || _a === void 0 ? void 0 : _a.view;
4973
- this.doSetGroupActive(next);
4962
+ get defaultPrevented() {
4963
+ return this.event.defaultPrevented;
4974
4964
  }
4975
- layout(width, height, forceResize) {
4976
- const different = forceResize !== null && forceResize !== void 0 ? forceResize : (width !== this.width || height !== this.height);
4977
- if (!different) {
4978
- return;
4979
- }
4980
- this.gridview.element.style.height = `${height}px`;
4981
- this.gridview.element.style.width = `${width}px`;
4982
- this.gridview.layout(width, height);
4965
+ get panel() {
4966
+ return this.options.panel;
4983
4967
  }
4984
- dispose() {
4985
- this._onDidActiveChange.dispose();
4986
- this._onDidAdd.dispose();
4987
- this._onDidRemove.dispose();
4988
- this._onDidLayoutChange.dispose();
4989
- for (const group of this.groups) {
4990
- group.dispose();
4991
- }
4992
- this.gridview.dispose();
4993
- super.dispose();
4968
+ get api() {
4969
+ return this.options.api;
4994
4970
  }
4995
- }
4996
-
4997
- class WillFocusEvent extends DockviewEvent {
4998
- constructor() {
4999
- super();
4971
+ get group() {
4972
+ return this.options.group;
5000
4973
  }
5001
- }
5002
- /**
5003
- * A core api implementation that should be used across all panel-like objects
5004
- */
5005
- class PanelApiImpl extends CompositeDisposable {
5006
- get isFocused() {
5007
- return this._isFocused;
4974
+ preventDefault() {
4975
+ this.event.preventDefault();
5008
4976
  }
5009
- get isActive() {
5010
- return this._isActive;
4977
+ getData() {
4978
+ return this.options.getData();
5011
4979
  }
5012
- get isVisible() {
5013
- return this._isVisible;
4980
+ constructor(event, options) {
4981
+ this.event = event;
4982
+ this.options = options;
5014
4983
  }
5015
- get width() {
5016
- return this._width;
4984
+ }
4985
+ class DockviewGroupPanelModel extends CompositeDisposable {
4986
+ get element() {
4987
+ throw new Error('not supported');
5017
4988
  }
5018
- get height() {
5019
- return this._height;
4989
+ get activePanel() {
4990
+ return this._activePanel;
5020
4991
  }
5021
- constructor(id, component) {
5022
- super();
5023
- this.id = id;
5024
- this.component = component;
5025
- this._isFocused = false;
5026
- this._isActive = false;
5027
- this._isVisible = true;
5028
- this._width = 0;
5029
- this._height = 0;
5030
- this._parameters = {};
5031
- this.panelUpdatesDisposable = new MutableDisposable();
5032
- this._onDidDimensionChange = new Emitter();
5033
- this.onDidDimensionsChange = this._onDidDimensionChange.event;
5034
- this._onDidChangeFocus = new Emitter();
5035
- this.onDidFocusChange = this._onDidChangeFocus.event;
5036
- //
5037
- this._onWillFocus = new Emitter();
5038
- this.onWillFocus = this._onWillFocus.event;
5039
- //
5040
- this._onDidVisibilityChange = new Emitter();
5041
- this.onDidVisibilityChange = this._onDidVisibilityChange.event;
5042
- this._onWillVisibilityChange = new Emitter();
5043
- this.onWillVisibilityChange = this._onWillVisibilityChange.event;
5044
- this._onDidActiveChange = new Emitter();
5045
- this.onDidActiveChange = this._onDidActiveChange.event;
5046
- this._onActiveChange = new Emitter();
5047
- this.onActiveChange = this._onActiveChange.event;
5048
- this._onDidParametersChange = new Emitter();
5049
- this.onDidParametersChange = this._onDidParametersChange.event;
5050
- this.addDisposables(this.onDidFocusChange((event) => {
5051
- this._isFocused = event.isFocused;
5052
- }), this.onDidActiveChange((event) => {
5053
- this._isActive = event.isActive;
5054
- }), this.onDidVisibilityChange((event) => {
5055
- this._isVisible = event.isVisible;
5056
- }), this.onDidDimensionsChange((event) => {
5057
- this._width = event.width;
5058
- this._height = event.height;
5059
- }), this.panelUpdatesDisposable, this._onDidDimensionChange, this._onDidChangeFocus, this._onDidVisibilityChange, this._onDidActiveChange, this._onWillFocus, this._onActiveChange, this._onWillFocus, this._onWillVisibilityChange, this._onDidParametersChange);
4992
+ get locked() {
4993
+ return this._locked;
5060
4994
  }
5061
- getParameters() {
5062
- return this._parameters;
4995
+ set locked(value) {
4996
+ this._locked = value;
4997
+ toggleClass(this.container, 'locked-groupview', value === 'no-drop-target' || value);
5063
4998
  }
5064
- initialize(panel) {
5065
- this.panelUpdatesDisposable.value = this._onDidParametersChange.event((parameters) => {
5066
- this._parameters = parameters;
5067
- panel.update({
5068
- params: parameters,
5069
- });
5070
- });
4999
+ get isActive() {
5000
+ return this._isGroupActive;
5071
5001
  }
5072
- setVisible(isVisible) {
5073
- this._onWillVisibilityChange.fire({ isVisible });
5002
+ get panels() {
5003
+ return this._panels;
5074
5004
  }
5075
- setActive() {
5076
- this._onActiveChange.fire();
5005
+ get size() {
5006
+ return this._panels.length;
5077
5007
  }
5078
- updateParameters(parameters) {
5079
- this._onDidParametersChange.fire(parameters);
5008
+ get isEmpty() {
5009
+ return this._panels.length === 0;
5080
5010
  }
5081
- }
5082
-
5083
- class SplitviewPanelApiImpl extends PanelApiImpl {
5084
- //
5085
- constructor(id, component) {
5086
- super(id, component);
5087
- this._onDidConstraintsChangeInternal = new Emitter();
5088
- this.onDidConstraintsChangeInternal = this._onDidConstraintsChangeInternal.event;
5089
- //
5090
- this._onDidConstraintsChange = new Emitter({
5091
- replay: true,
5092
- });
5093
- this.onDidConstraintsChange = this._onDidConstraintsChange.event;
5094
- //
5095
- this._onDidSizeChange = new Emitter();
5096
- this.onDidSizeChange = this._onDidSizeChange.event;
5097
- this.addDisposables(this._onDidConstraintsChangeInternal, this._onDidConstraintsChange, this._onDidSizeChange);
5011
+ get hasWatermark() {
5012
+ return !!(this.watermark && this.container.contains(this.watermark.element));
5098
5013
  }
5099
- setConstraints(value) {
5100
- this._onDidConstraintsChangeInternal.fire(value);
5014
+ get header() {
5015
+ return this.tabsContainer;
5101
5016
  }
5102
- setSize(event) {
5103
- this._onDidSizeChange.fire(event);
5017
+ get isContentFocused() {
5018
+ if (!document.activeElement) {
5019
+ return false;
5020
+ }
5021
+ return isAncestor(document.activeElement, this.contentContainer.element);
5104
5022
  }
5105
- }
5106
-
5107
- class PaneviewPanelApiImpl extends SplitviewPanelApiImpl {
5108
- set pane(pane) {
5109
- this._pane = pane;
5023
+ get location() {
5024
+ return this._location;
5110
5025
  }
5111
- constructor(id, component) {
5112
- super(id, component);
5113
- this._onDidExpansionChange = new Emitter({
5114
- replay: true,
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,
5115
5054
  });
5116
- this.onDidExpansionChange = this._onDidExpansionChange.event;
5117
- this._onMouseEnter = new Emitter({});
5118
- this.onMouseEnter = this._onMouseEnter.event;
5119
- this._onMouseLeave = new Emitter({});
5120
- this.onMouseLeave = this._onMouseLeave.event;
5121
- this.addDisposables(this._onDidExpansionChange, this._onMouseEnter, this._onMouseLeave);
5122
- }
5123
- setExpanded(isExpanded) {
5124
- var _a;
5125
- (_a = this._pane) === null || _a === void 0 ? void 0 : _a.setExpanded(isExpanded);
5126
5055
  }
5127
- get isExpanded() {
5056
+ constructor(container, accessor, id, options, groupPanel) {
5128
5057
  var _a;
5129
- return !!((_a = this._pane) === null || _a === void 0 ? void 0 : _a.isExpanded());
5130
- }
5131
- }
5132
-
5133
- class BasePanelView extends CompositeDisposable {
5134
- get element() {
5135
- return this._element;
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);
5136
5129
  }
5137
- get width() {
5138
- return this._width;
5130
+ focusContent() {
5131
+ this.contentContainer.element.focus();
5139
5132
  }
5140
- get height() {
5141
- return this._height;
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
+ });
5142
5141
  }
5143
- get params() {
5142
+ get renderContainer() {
5144
5143
  var _a;
5145
- return (_a = this._params) === null || _a === void 0 ? void 0 : _a.params;
5146
- }
5147
- constructor(id, component, api) {
5148
- super();
5149
- this.id = id;
5150
- this.component = component;
5151
- this.api = api;
5152
- this._height = 0;
5153
- this._width = 0;
5154
- this._element = document.createElement('div');
5155
- this._element.tabIndex = -1;
5156
- this._element.style.outline = 'none';
5157
- this._element.style.height = '100%';
5158
- this._element.style.width = '100%';
5159
- this._element.style.overflow = 'hidden';
5160
- const focusTracker = trackFocus(this._element);
5161
- this.addDisposables(this.api, focusTracker.onDidFocus(() => {
5162
- this.api._onDidChangeFocus.fire({ isFocused: true });
5163
- }), focusTracker.onDidBlur(() => {
5164
- this.api._onDidChangeFocus.fire({ isFocused: false });
5165
- }), focusTracker);
5144
+ return ((_a = this._overwriteRenderContainer) !== null && _a !== void 0 ? _a : this.accessor.overlayRenderContainer);
5166
5145
  }
5167
- focus() {
5168
- const event = new WillFocusEvent();
5169
- this.api._onWillFocus.fire(event);
5170
- if (event.defaultPrevented) {
5171
- return;
5146
+ initialize() {
5147
+ if (this.options.panels) {
5148
+ this.options.panels.forEach((panel) => {
5149
+ this.doAddPanel(panel);
5150
+ });
5172
5151
  }
5173
- this._element.focus();
5174
- }
5175
- layout(width, height) {
5176
- this._width = width;
5177
- this._height = height;
5178
- this.api._onDidDimensionChange.fire({ width, height });
5179
- if (this.part) {
5180
- if (this._params) {
5181
- this.part.update(this._params.params);
5182
- }
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);
5183
5191
  }
5184
5192
  }
5185
- init(parameters) {
5186
- this._params = parameters;
5187
- this.part = this.getComponent();
5193
+ rerender(panel) {
5194
+ this.contentContainer.renderPanel(panel, { asActive: false });
5188
5195
  }
5189
- update(event) {
5190
- var _a, _b;
5191
- // merge the new parameters with the existing parameters
5192
- this._params = Object.assign(Object.assign({}, this._params), { params: Object.assign(Object.assign({}, (_a = this._params) === null || _a === void 0 ? void 0 : _a.params), event.params) });
5193
- /**
5194
- * delete new keys that have a value of undefined,
5195
- * allow values of null
5196
- */
5197
- for (const key of Object.keys(event.params)) {
5198
- if (event.params[key] === undefined) {
5199
- delete this._params.params[key];
5200
- }
5201
- }
5202
- // update the view with the updated props
5203
- (_b = this.part) === null || _b === void 0 ? void 0 : _b.update({ params: this._params.params });
5196
+ indexOf(panel) {
5197
+ return this.tabsContainer.indexOf(panel.id);
5204
5198
  }
5205
5199
  toJSON() {
5206
- var _a, _b;
5207
- const params = (_b = (_a = this._params) === null || _a === void 0 ? void 0 : _a.params) !== null && _b !== void 0 ? _b : {};
5208
- return {
5200
+ var _a;
5201
+ const result = {
5202
+ views: this.tabsContainer.panels,
5203
+ activeView: (_a = this._activePanel) === null || _a === void 0 ? void 0 : _a.id,
5209
5204
  id: this.id,
5210
- component: this.component,
5211
- params: Object.keys(params).length > 0 ? params : undefined,
5212
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;
5213
5213
  }
5214
- dispose() {
5215
- var _a;
5216
- this.api.dispose();
5217
- (_a = this.part) === null || _a === void 0 ? void 0 : _a.dispose();
5218
- super.dispose();
5219
- }
5220
- }
5221
-
5222
- class PaneviewPanel extends BasePanelView {
5223
- set orientation(value) {
5224
- this._orientation = value;
5225
- }
5226
- get orientation() {
5227
- return this._orientation;
5228
- }
5229
- get minimumSize() {
5230
- const headerSize = this.headerSize;
5231
- const expanded = this.isExpanded();
5232
- const minimumBodySize = expanded ? this._minimumBodySize : 0;
5233
- return headerSize + minimumBodySize;
5234
- }
5235
- get maximumSize() {
5236
- const headerSize = this.headerSize;
5237
- const expanded = this.isExpanded();
5238
- const maximumBodySize = expanded ? this._maximumBodySize : 0;
5239
- return headerSize + maximumBodySize;
5240
- }
5241
- get size() {
5242
- return this._size;
5243
- }
5244
- get orthogonalSize() {
5245
- return this._orthogonalSize;
5246
- }
5247
- set orthogonalSize(size) {
5248
- this._orthogonalSize = size;
5249
- }
5250
- get minimumBodySize() {
5251
- return this._minimumBodySize;
5252
- }
5253
- set minimumBodySize(value) {
5254
- this._minimumBodySize = typeof value === 'number' ? value : 0;
5255
- }
5256
- get maximumBodySize() {
5257
- return this._maximumBodySize;
5258
- }
5259
- set maximumBodySize(value) {
5260
- this._maximumBodySize =
5261
- typeof value === 'number' ? value : Number.POSITIVE_INFINITY;
5262
- }
5263
- get headerVisible() {
5264
- return this._headerVisible;
5265
- }
5266
- set headerVisible(value) {
5267
- this._headerVisible = value;
5268
- this.header.style.display = value ? '' : 'none';
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]);
5269
5233
  }
5270
- constructor(id, component, headerComponent, orientation, isExpanded, isHeaderVisible) {
5271
- super(id, component, new PaneviewPanelApiImpl(id, component));
5272
- this.headerComponent = headerComponent;
5273
- this._onDidChangeExpansionState = new Emitter({ replay: true });
5274
- this.onDidChangeExpansionState = this._onDidChangeExpansionState.event;
5275
- this._onDidChange = new Emitter();
5276
- this.onDidChange = this._onDidChange.event;
5277
- this.headerSize = 22;
5278
- this._orthogonalSize = 0;
5279
- this._size = 0;
5280
- this._minimumBodySize = 100;
5281
- this._maximumBodySize = Number.POSITIVE_INFINITY;
5282
- this._isExpanded = false;
5283
- this.expandedSize = 0;
5284
- this.api.pane = this; // TODO cannot use 'this' before 'super'
5285
- this.api.initialize(this);
5286
- this._isExpanded = isExpanded;
5287
- this._headerVisible = isHeaderVisible;
5288
- this._onDidChangeExpansionState.fire(this.isExpanded()); // initialize value
5289
- this._orientation = orientation;
5290
- this.element.classList.add('pane');
5291
- this.addDisposables(this.api.onWillVisibilityChange((event) => {
5292
- const { isVisible } = event;
5293
- const { accessor } = this._params;
5294
- accessor.setVisible(this, isVisible);
5295
- }), this.api.onDidSizeChange((event) => {
5296
- this._onDidChange.fire({ size: event.size });
5297
- }), addDisposableListener(this.element, 'mouseenter', (ev) => {
5298
- this.api._onMouseEnter.fire(ev);
5299
- }), addDisposableListener(this.element, 'mouseleave', (ev) => {
5300
- this.api._onMouseLeave.fire(ev);
5301
- }));
5302
- this.addDisposables(this._onDidChangeExpansionState, this.onDidChangeExpansionState((isPanelExpanded) => {
5303
- this.api._onDidExpansionChange.fire({
5304
- isExpanded: isPanelExpanded,
5305
- });
5306
- }), this.api.onDidFocusChange((e) => {
5307
- if (!this.header) {
5308
- return;
5309
- }
5310
- if (e.isFocused) {
5311
- addClasses(this.header, 'focused');
5312
- }
5313
- else {
5314
- removeClasses(this.header, 'focused');
5315
- }
5316
- }));
5317
- this.renderOnce();
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]);
5318
5256
  }
5319
- setVisible(isVisible) {
5320
- this.api._onDidVisibilityChange.fire({ isVisible });
5257
+ containsPanel(panel) {
5258
+ return this.panels.includes(panel);
5321
5259
  }
5322
- setActive(isActive) {
5323
- this.api._onDidActiveChange.fire({ isActive });
5260
+ init(_params) {
5261
+ //noop
5324
5262
  }
5325
- isExpanded() {
5326
- return this._isExpanded;
5263
+ update(_params) {
5264
+ //noop
5327
5265
  }
5328
- setExpanded(expanded) {
5329
- if (this._isExpanded === expanded) {
5266
+ focus() {
5267
+ var _a;
5268
+ (_a = this._activePanel) === null || _a === void 0 ? void 0 : _a.focus();
5269
+ }
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 });
5330
5291
  return;
5331
5292
  }
5332
- this._isExpanded = expanded;
5333
- if (expanded) {
5334
- if (this.animationTimer) {
5335
- clearTimeout(this.animationTimer);
5336
- }
5337
- if (this.body) {
5338
- this.element.appendChild(this.body);
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
+ }
5302
+ }
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);
5314
+ }
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);
5339
5321
  }
5340
5322
  }
5341
5323
  else {
5342
- this.animationTimer = setTimeout(() => {
5343
- var _a;
5344
- (_a = this.body) === null || _a === void 0 ? void 0 : _a.remove();
5345
- }, 200);
5324
+ this.accessor.removeGroup(this.groupPanel);
5346
5325
  }
5347
- this._onDidChange.fire(expanded ? { size: this.width } : {});
5348
- this._onDidChangeExpansionState.fire(expanded);
5349
5326
  }
5350
- layout(size, orthogonalSize) {
5351
- this._size = size;
5352
- this._orthogonalSize = orthogonalSize;
5353
- const [width, height] = this.orientation === exports.Orientation.HORIZONTAL
5354
- ? [size, orthogonalSize]
5355
- : [orthogonalSize, size];
5356
- if (this.isExpanded()) {
5357
- this.expandedSize = width;
5327
+ closePanel(panel) {
5328
+ this.doClose(panel);
5329
+ }
5330
+ doClose(panel) {
5331
+ this.accessor.removePanel(panel);
5332
+ }
5333
+ isPanelActive(panel) {
5334
+ return this._activePanel === panel;
5335
+ }
5336
+ updateActions(element) {
5337
+ this.tabsContainer.setRightActionsElement(element);
5338
+ }
5339
+ setActive(isGroupActive, force = false) {
5340
+ if (!force && this.isActive === isGroupActive) {
5341
+ return;
5358
5342
  }
5359
- super.layout(width, height);
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]);
5349
+ }
5350
+ this.updateContainer();
5360
5351
  }
5361
- init(parameters) {
5362
- var _a, _b;
5363
- super.init(parameters);
5364
- if (typeof parameters.minimumBodySize === 'number') {
5365
- this.minimumBodySize = parameters.minimumBodySize;
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);
5366
5359
  }
5367
- if (typeof parameters.maximumBodySize === 'number') {
5368
- this.maximumBodySize = parameters.maximumBodySize;
5360
+ }
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
+ });
5369
5370
  }
5370
- this.bodyPart = this.getBodyComponent();
5371
- this.headerPart = this.getHeaderComponent();
5372
- this.bodyPart.init(Object.assign(Object.assign({}, parameters), { api: this.api }));
5373
- this.headerPart.init(Object.assign(Object.assign({}, parameters), { api: this.api }));
5374
- (_a = this.body) === null || _a === void 0 ? void 0 : _a.append(this.bodyPart.element);
5375
- (_b = this.header) === null || _b === void 0 ? void 0 : _b.append(this.headerPart.element);
5376
- if (typeof parameters.isExpanded === 'boolean') {
5377
- this.setExpanded(parameters.isExpanded);
5371
+ if (this._activePanel && this.panels.length === 0) {
5372
+ this.doSetActivePanel(undefined);
5373
+ }
5374
+ if (!options.skipSetActive) {
5375
+ this.updateContainer();
5378
5376
  }
5377
+ return panel;
5379
5378
  }
5380
- toJSON() {
5381
- const params = this._params;
5382
- return Object.assign(Object.assign({}, super.toJSON()), { headerComponent: this.headerComponent, title: params.title });
5379
+ doRemovePanel(panel) {
5380
+ const index = this.panels.indexOf(panel);
5381
+ if (this._activePanel === panel) {
5382
+ this.contentContainer.closePanel();
5383
+ }
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);
5389
+ }
5390
+ const disposable = this._panelDisposables.get(panel.id);
5391
+ if (disposable) {
5392
+ disposable.dispose();
5393
+ this._panelDisposables.delete(panel.id);
5394
+ }
5395
+ this._onDidRemovePanel.fire({ panel });
5383
5396
  }
5384
- renderOnce() {
5385
- this.header = document.createElement('div');
5386
- this.header.tabIndex = 0;
5387
- this.header.className = 'pane-header';
5388
- this.header.style.height = `${this.headerSize}px`;
5389
- this.header.style.lineHeight = `${this.headerSize}px`;
5390
- this.header.style.minHeight = `${this.headerSize}px`;
5391
- this.header.style.maxHeight = `${this.headerSize}px`;
5392
- this.element.appendChild(this.header);
5393
- this.body = document.createElement('div');
5394
- this.body.className = 'pane-body';
5395
- this.element.appendChild(this.body);
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 });
5396
5414
  }
5397
- // TODO slightly hacky by-pass of the component to create a body and header component
5398
- getComponent() {
5399
- return {
5400
- update: (params) => {
5401
- var _a, _b;
5402
- (_a = this.bodyPart) === null || _a === void 0 ? void 0 : _a.update({ params });
5403
- (_b = this.headerPart) === null || _b === void 0 ? void 0 : _b.update({ params });
5404
- },
5405
- dispose: () => {
5406
- var _a, _b;
5407
- (_a = this.bodyPart) === null || _a === void 0 ? void 0 : _a.dispose();
5408
- (_b = this.headerPart) === null || _b === void 0 ? void 0 : _b.dispose();
5409
- },
5410
- };
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
+ }
5411
5428
  }
5412
- }
5413
-
5414
- class DraggablePaneviewPanel extends PaneviewPanel {
5415
- constructor(accessor, id, component, headerComponent, orientation, isExpanded, disableDnd) {
5416
- super(id, component, headerComponent, orientation, isExpanded, true);
5417
- this.accessor = accessor;
5418
- this._onDidDrop = new Emitter();
5419
- this.onDidDrop = this._onDidDrop.event;
5420
- if (!disableDnd) {
5421
- this.initDragFeatures();
5429
+ updateMru(panel) {
5430
+ if (this.mostRecentlyUsed.includes(panel)) {
5431
+ this.mostRecentlyUsed.splice(this.mostRecentlyUsed.indexOf(panel), 1);
5422
5432
  }
5433
+ this.mostRecentlyUsed = [panel, ...this.mostRecentlyUsed];
5423
5434
  }
5424
- initDragFeatures() {
5425
- if (!this.header) {
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();
5460
+ }
5461
+ }
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') {
5426
5469
  return;
5427
5470
  }
5428
- const id = this.id;
5429
- const accessorId = this.accessor.id;
5430
- this.header.draggable = true;
5431
- this.handler = new (class PaneDragHandler extends DragHandler {
5432
- getData() {
5433
- LocalSelectionTransfer.getInstance().setData([new PaneTransfer(accessorId, id)], PaneTransfer.prototype);
5434
- return {
5435
- dispose: () => {
5436
- LocalSelectionTransfer.getInstance().clearData(PaneTransfer.prototype);
5437
- },
5438
- };
5471
+ function getKind() {
5472
+ switch (type) {
5473
+ case 'header':
5474
+ return typeof index === 'number' ? 'tab' : 'header_space';
5475
+ case 'content':
5476
+ return 'content';
5439
5477
  }
5440
- })(this.header);
5441
- this.target = new Droptarget(this.element, {
5442
- acceptedTargetZones: ['top', 'bottom'],
5443
- overlayModel: {
5444
- activationSize: { type: 'percentage', value: 50 },
5445
- },
5446
- canDisplayOverlay: (event) => {
5447
- const data = getPaneData();
5448
- if (data) {
5449
- if (data.paneId !== this.id &&
5450
- data.viewId === this.accessor.id) {
5451
- return true;
5452
- }
5453
- }
5454
- if (this.accessor.options.showDndOverlay) {
5455
- return this.accessor.options.showDndOverlay({
5456
- nativeEvent: event,
5457
- getData: getPaneData,
5458
- panel: this,
5459
- });
5460
- }
5461
- return false;
5462
- },
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,
5463
5488
  });
5464
- this.addDisposables(this._onDidDrop, this.handler, this.target, this.target.onDrop((event) => {
5465
- this.onDrop(event);
5466
- }));
5467
- }
5468
- onDrop(event) {
5469
- const data = getPaneData();
5470
- if (!data || data.viewId !== this.accessor.id) {
5471
- // if there is no local drag event for this panel
5472
- // or if the drag event was creating by another Paneview instance
5473
- this._onDidDrop.fire(Object.assign(Object.assign({}, event), { panel: this, api: new PaneviewApi(this.accessor), getData: getPaneData }));
5489
+ this._onWillDrop.fire(willDropEvent);
5490
+ if (willDropEvent.defaultPrevented) {
5474
5491
  return;
5475
5492
  }
5476
- const containerApi = this._params
5477
- .containerApi;
5478
- const panelId = data.paneId;
5479
- const existingPanel = containerApi.getPanel(panelId);
5480
- if (!existingPanel) {
5481
- // if the panel doesn't exist
5482
- this._onDidDrop.fire(Object.assign(Object.assign({}, event), { panel: this, getData: getPaneData, api: new PaneviewApi(this.accessor) }));
5483
- return;
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
+ });
5484
5523
  }
5485
- const allPanels = containerApi.panels;
5486
- const fromIndex = allPanels.indexOf(existingPanel);
5487
- let toIndex = containerApi.panels.indexOf(this);
5488
- if (event.position === 'left' || event.position === 'top') {
5489
- toIndex = Math.max(0, toIndex - 1);
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
+ }));
5490
5533
  }
5491
- if (event.position === 'right' || event.position === 'bottom') {
5492
- if (fromIndex > toIndex) {
5493
- toIndex++;
5494
- }
5495
- 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();
5496
5543
  }
5497
- containerApi.movePanel(fromIndex, toIndex);
5544
+ this.tabsContainer.dispose();
5545
+ this.contentContainer.dispose();
5498
5546
  }
5499
5547
  }
5500
5548
 
@@ -5681,9 +5729,12 @@
5681
5729
  constructor(id, accessor) {
5682
5730
  super(id, '__dockviewgroup__');
5683
5731
  this.accessor = accessor;
5732
+ this._mutableDisposable = new MutableDisposable();
5684
5733
  this._onDidLocationChange = new Emitter();
5685
5734
  this.onDidLocationChange = this._onDidLocationChange.event;
5686
- this.addDisposables(this._onDidLocationChange);
5735
+ this._onDidActivePanelChange = new Emitter();
5736
+ this.onDidActivePanelChange = this._onDidActivePanelChange.event;
5737
+ this.addDisposables(this._onDidLocationChange, this._onDidActivePanelChange, this._mutableDisposable);
5687
5738
  }
5688
5739
  close() {
5689
5740
  if (!this._group) {
@@ -5741,6 +5792,19 @@
5741
5792
  }
5742
5793
  initialize(group) {
5743
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
+ });
5744
5808
  }
5745
5809
  }
5746
5810
 
@@ -5801,31 +5865,6 @@
5801
5865
  }
5802
5866
  }
5803
5867
 
5804
- function isPanelOptionsWithPanel(data) {
5805
- if (data.referencePanel) {
5806
- return true;
5807
- }
5808
- return false;
5809
- }
5810
- function isPanelOptionsWithGroup(data) {
5811
- if (data.referenceGroup) {
5812
- return true;
5813
- }
5814
- return false;
5815
- }
5816
- function isGroupOptionsWithPanel(data) {
5817
- if (data.referencePanel) {
5818
- return true;
5819
- }
5820
- return false;
5821
- }
5822
- function isGroupOptionsWithGroup(data) {
5823
- if (data.referenceGroup) {
5824
- return true;
5825
- }
5826
- return false;
5827
- }
5828
-
5829
5868
  class DockviewPanelApiImpl extends GridviewPanelApiImpl {
5830
5869
  get location() {
5831
5870
  return this.group.api.location;
@@ -6193,7 +6232,7 @@
6193
6232
  this._tab = this.createTabComponent(this.id, tabComponent);
6194
6233
  }
6195
6234
  init(params) {
6196
- this.content.init(Object.assign(Object.assign({}, params), { tab: this.tab }));
6235
+ this.content.init(params);
6197
6236
  this.tab.init(params);
6198
6237
  }
6199
6238
  updateParentGroup(_group, _isPanelVisible) {
@@ -6214,20 +6253,29 @@
6214
6253
  (_d = (_c = this.tab).dispose) === null || _d === void 0 ? void 0 : _d.call(_c);
6215
6254
  }
6216
6255
  createContentComponent(id, componentName) {
6217
- var _a, _b;
6218
- return createComponent(id, componentName, (_a = this.accessor.options.components) !== null && _a !== void 0 ? _a : {}, this.accessor.options.frameworkComponents, (_b = this.accessor.options.frameworkComponentFactory) === null || _b === void 0 ? void 0 : _b.content);
6256
+ return this.accessor.options.createComponent({
6257
+ id,
6258
+ name: componentName,
6259
+ });
6219
6260
  }
6220
6261
  createTabComponent(id, componentName) {
6221
- var _a, _b;
6222
- if (componentName) {
6223
- return createComponent(id, componentName, this.accessor.options.tabComponents, this.accessor.options.frameworkTabComponents, (_a = this.accessor.options.frameworkComponentFactory) === null || _a === void 0 ? void 0 : _a.tab, () => new DefaultTab());
6224
- }
6225
- else if (this.accessor.options.defaultTabComponent) {
6226
- return createComponent(id, this.accessor.options.defaultTabComponent, this.accessor.options.tabComponents, this.accessor.options.frameworkTabComponents, (_b = this.accessor.options.frameworkComponentFactory) === null || _b === void 0 ? void 0 : _b.tab, () => new DefaultTab());
6227
- }
6228
- else {
6229
- return new DefaultTab();
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.`);
6230
6277
  }
6278
+ return new DefaultTab();
6231
6279
  }
6232
6280
  }
6233
6281
 
@@ -6987,11 +7035,13 @@
6987
7035
  return this._api;
6988
7036
  }
6989
7037
  constructor(options) {
6990
- var _a, _b;
7038
+ var _a;
6991
7039
  super({
6992
7040
  proportionalLayout: true,
6993
- orientation: (_a = options.orientation) !== null && _a !== void 0 ? _a : exports.Orientation.HORIZONTAL,
6994
- styles: options.styles,
7041
+ orientation: exports.Orientation.HORIZONTAL,
7042
+ styles: options.hideBorders
7043
+ ? { separatorBorder: 'transparent' }
7044
+ : undefined,
6995
7045
  parentElement: options.parentElement,
6996
7046
  disableAutoResizing: options.disableAutoResizing,
6997
7047
  locked: options.locked,
@@ -7009,6 +7059,8 @@
7009
7059
  this.onWillDrop = this._onWillDrop.event;
7010
7060
  this._onWillShowOverlay = new Emitter();
7011
7061
  this.onWillShowOverlay = this._onWillShowOverlay.event;
7062
+ this._onUnhandledDragOverEvent = new Emitter();
7063
+ this.onUnhandledDragOverEvent = this._onUnhandledDragOverEvent.event;
7012
7064
  this._onDidRemovePanel = new Emitter();
7013
7065
  this.onDidRemovePanel = this._onDidRemovePanel.event;
7014
7066
  this._onDidAddPanel = new Emitter();
@@ -7034,7 +7086,7 @@
7034
7086
  this.overlayRenderContainer = new OverlayRenderContainer(gready);
7035
7087
  toggleClass(this.gridview.element, 'dv-dockview', true);
7036
7088
  toggleClass(this.element, 'dv-debug', !!options.debug);
7037
- this.addDisposables(this.overlayRenderContainer, this._onWillDragPanel, this._onWillDragGroup, this._onWillShowOverlay, this._onDidActivePanelChange, this._onDidAddPanel, this._onDidRemovePanel, this._onDidLayoutFromJSON, this._onDidDrop, this._onWillDrop, this._onDidMovePanel, this._onDidAddGroup, this._onDidRemoveGroup, this._onDidActiveGroupChange, this.onDidAdd((event) => {
7089
+ this.addDisposables(this.overlayRenderContainer, this._onWillDragPanel, this._onWillDragGroup, this._onWillShowOverlay, this._onDidActivePanelChange, this._onDidAddPanel, this._onDidRemovePanel, this._onDidLayoutFromJSON, this._onDidDrop, this._onWillDrop, this._onDidMovePanel, this._onDidAddGroup, this._onDidRemoveGroup, this._onDidActiveGroupChange, this._onUnhandledDragOverEvent, this.onDidAdd((event) => {
7038
7090
  if (!this._moving) {
7039
7091
  this._onDidAddGroup.fire(event);
7040
7092
  }
@@ -7061,22 +7113,6 @@
7061
7113
  }
7062
7114
  }));
7063
7115
  this._options = options;
7064
- if (!this.options.components) {
7065
- this.options.components = {};
7066
- }
7067
- if (!this.options.frameworkComponents) {
7068
- this.options.frameworkComponents = {};
7069
- }
7070
- if (!this.options.frameworkTabComponents) {
7071
- this.options.frameworkTabComponents = {};
7072
- }
7073
- if (!this.options.tabComponents) {
7074
- this.options.tabComponents = {};
7075
- }
7076
- if (!this.options.watermarkComponent &&
7077
- !this.options.watermarkFrameworkComponent) {
7078
- this.options.watermarkComponent = Watermark;
7079
- }
7080
7116
  this._rootDropTarget = new Droptarget(this.element, {
7081
7117
  canDisplayOverlay: (event, position) => {
7082
7118
  const data = getPanelData();
@@ -7091,26 +7127,20 @@
7091
7127
  }
7092
7128
  return true;
7093
7129
  }
7094
- if (this.options.showDndOverlay) {
7095
- if (position === 'center' && this.gridview.length !== 0) {
7096
- /**
7097
- * for external events only show the four-corner drag overlays, disable
7098
- * the center position so that external drag events can fall through to the group
7099
- * and panel drop target handlers
7100
- */
7101
- return false;
7102
- }
7103
- return this.options.showDndOverlay({
7104
- nativeEvent: event,
7105
- position: position,
7106
- target: 'edge',
7107
- getData: getPanelData,
7108
- });
7130
+ if (position === 'center' && this.gridview.length !== 0) {
7131
+ /**
7132
+ * for external events only show the four-corner drag overlays, disable
7133
+ * the center position so that external drag events can fall through to the group
7134
+ * and panel drop target handlers
7135
+ */
7136
+ return false;
7109
7137
  }
7110
- return false;
7138
+ const firedEvent = new DockviewUnhandledDragOverEvent(event, 'edge', position, getPanelData);
7139
+ this._onUnhandledDragOverEvent.fire(firedEvent);
7140
+ return firedEvent.isAccepted;
7111
7141
  },
7112
7142
  acceptedTargetZones: ['top', 'bottom', 'left', 'right', 'center'],
7113
- overlayModel: (_b = this.options.rootOverlayModel) !== null && _b !== void 0 ? _b : DEFAULT_ROOT_OVERLAY_MODEL,
7143
+ overlayModel: (_a = this.options.rootOverlayModel) !== null && _a !== void 0 ? _a : DEFAULT_ROOT_OVERLAY_MODEL,
7114
7144
  });
7115
7145
  this.addDisposables(this._rootDropTarget, this._rootDropTarget.onWillShowOverlay((event) => {
7116
7146
  if (this.gridview.length > 0 && event.position === 'center') {
@@ -7334,7 +7364,7 @@
7334
7364
  skipDispose: true,
7335
7365
  skipSetActiveGroup: true,
7336
7366
  }));
7337
- group.model.openPanel(item, { skipSetGroupActive: true });
7367
+ this.movingLock(() => group.model.openPanel(item, { skipSetGroupActive: true }));
7338
7368
  }
7339
7369
  else {
7340
7370
  group = item;
@@ -7407,7 +7437,7 @@
7407
7437
  // this is either a resize or a move
7408
7438
  // to inform the panels .layout(...) the group with it's current size
7409
7439
  // don't care about resize since the above watcher handles that
7410
- group.layout(group.height, group.width);
7440
+ group.layout(group.width, group.height);
7411
7441
  }), overlay.onDidChangeEnd(() => {
7412
7442
  this._bufferOnDidLayoutChange.fire();
7413
7443
  }), group.onDidChange((event) => {
@@ -7462,16 +7492,11 @@
7462
7492
  }
7463
7493
  updateOptions(options) {
7464
7494
  var _a, _b;
7465
- const changed_orientation = typeof options.orientation === 'string' &&
7466
- this.gridview.orientation !== options.orientation;
7467
- const changed_floatingGroupBounds = options.floatingGroupBounds !== undefined &&
7495
+ const changed_floatingGroupBounds = 'floatingGroupBounds' in options &&
7468
7496
  options.floatingGroupBounds !== this.options.floatingGroupBounds;
7469
- const changed_rootOverlayOptions = options.rootOverlayModel !== undefined &&
7497
+ const changed_rootOverlayOptions = 'rootOverlayModel' in options &&
7470
7498
  options.rootOverlayModel !== this.options.rootOverlayModel;
7471
7499
  this._options = Object.assign(Object.assign({}, this.options), options);
7472
- if (changed_orientation) {
7473
- this.gridview.orientation = options.orientation;
7474
- }
7475
7500
  if (changed_floatingGroupBounds) {
7476
7501
  for (const group of this._floatingGroups) {
7477
7502
  switch (this.options.floatingGroupBounds) {
@@ -7759,7 +7784,7 @@
7759
7784
  ? this.getGroupPanel(options.position.referencePanel)
7760
7785
  : options.position.referencePanel;
7761
7786
  if (!referencePanel) {
7762
- throw new Error(`referencePanel ${options.position.referencePanel} does not exist`);
7787
+ throw new Error(`referencePanel '${options.position.referencePanel}' does not exist`);
7763
7788
  }
7764
7789
  referenceGroup = this.findGroup(referencePanel);
7765
7790
  }
@@ -7769,14 +7794,19 @@
7769
7794
  ? (_a = this._groups.get(options.position.referenceGroup)) === null || _a === void 0 ? void 0 : _a.value
7770
7795
  : options.position.referenceGroup;
7771
7796
  if (!referenceGroup) {
7772
- throw new Error(`referencePanel ${options.position.referenceGroup} does not exist`);
7797
+ throw new Error(`referenceGroup '${options.position.referenceGroup}' does not exist`);
7773
7798
  }
7774
7799
  }
7775
7800
  else {
7776
7801
  const group = this.orthogonalize(directionToPosition(options.position.direction));
7777
7802
  const panel = this.createPanel(options, group);
7778
- group.model.openPanel(panel);
7779
- this.doSetGroupAndPanelActive(group);
7803
+ group.model.openPanel(panel, {
7804
+ skipSetActive: options.inactive,
7805
+ skipSetGroupActive: options.inactive,
7806
+ });
7807
+ if (!options.inactive) {
7808
+ this.doSetGroupAndPanelActive(group);
7809
+ }
7780
7810
  return panel;
7781
7811
  }
7782
7812
  }
@@ -7799,43 +7829,64 @@
7799
7829
  skipActiveGroup: true,
7800
7830
  });
7801
7831
  panel = this.createPanel(options, group);
7802
- group.model.openPanel(panel);
7832
+ group.model.openPanel(panel, {
7833
+ skipSetActive: options.inactive,
7834
+ skipSetGroupActive: options.inactive,
7835
+ });
7803
7836
  }
7804
7837
  else if (referenceGroup.api.location.type === 'floating' ||
7805
7838
  target === 'center') {
7806
7839
  panel = this.createPanel(options, referenceGroup);
7807
- referenceGroup.model.openPanel(panel);
7808
- this.doSetGroupAndPanelActive(referenceGroup);
7840
+ referenceGroup.model.openPanel(panel, {
7841
+ skipSetActive: options.inactive,
7842
+ skipSetGroupActive: options.inactive,
7843
+ });
7844
+ if (!options.inactive) {
7845
+ this.doSetGroupAndPanelActive(referenceGroup);
7846
+ }
7809
7847
  }
7810
7848
  else {
7811
7849
  const location = getGridLocation(referenceGroup.element);
7812
7850
  const relativeLocation = getRelativeLocation(this.gridview.orientation, location, target);
7813
7851
  const group = this.createGroupAtLocation(relativeLocation);
7814
7852
  panel = this.createPanel(options, group);
7815
- group.model.openPanel(panel);
7816
- this.doSetGroupAndPanelActive(group);
7853
+ group.model.openPanel(panel, {
7854
+ skipSetActive: options.inactive,
7855
+ skipSetGroupActive: options.inactive,
7856
+ });
7857
+ if (!options.inactive) {
7858
+ this.doSetGroupAndPanelActive(group);
7859
+ }
7817
7860
  }
7818
7861
  }
7819
7862
  else if (options.floating) {
7820
7863
  const group = this.createGroup();
7821
7864
  this._onDidAddGroup.fire(group);
7822
- const o = typeof options.floating === 'object' &&
7865
+ const coordinates = typeof options.floating === 'object' &&
7823
7866
  options.floating !== null
7824
7867
  ? options.floating
7825
7868
  : {};
7826
- this.addFloatingGroup(group, o, {
7869
+ this.addFloatingGroup(group, coordinates, {
7827
7870
  inDragMode: false,
7828
7871
  skipRemoveGroup: true,
7829
7872
  skipActiveGroup: true,
7830
7873
  });
7831
7874
  panel = this.createPanel(options, group);
7832
- group.model.openPanel(panel);
7875
+ group.model.openPanel(panel, {
7876
+ skipSetActive: options.inactive,
7877
+ skipSetGroupActive: options.inactive,
7878
+ });
7833
7879
  }
7834
7880
  else {
7835
7881
  const group = this.createGroupAtLocation();
7836
7882
  panel = this.createPanel(options, group);
7837
- group.model.openPanel(panel);
7838
- this.doSetGroupAndPanelActive(group);
7883
+ group.model.openPanel(panel, {
7884
+ skipSetActive: options.inactive,
7885
+ skipSetGroupActive: options.inactive,
7886
+ });
7887
+ if (!options.inactive) {
7888
+ this.doSetGroupAndPanelActive(group);
7889
+ }
7839
7890
  }
7840
7891
  return panel;
7841
7892
  }
@@ -7859,12 +7910,10 @@
7859
7910
  }
7860
7911
  }
7861
7912
  createWatermarkComponent() {
7862
- var _a;
7863
- return createComponent('watermark-id', 'watermark-name', this.options.watermarkComponent
7864
- ? { 'watermark-name': this.options.watermarkComponent }
7865
- : {}, this.options.watermarkFrameworkComponent
7866
- ? { 'watermark-name': this.options.watermarkFrameworkComponent }
7867
- : {}, (_a = this.options.frameworkComponentFactory) === null || _a === void 0 ? void 0 : _a.watermark);
7913
+ if (this.options.createWatermarkComponent) {
7914
+ return this.options.createWatermarkComponent();
7915
+ }
7916
+ return new Watermark();
7868
7917
  }
7869
7918
  updateWatermark() {
7870
7919
  var _a, _b;
@@ -8245,6 +8294,8 @@
8245
8294
  return;
8246
8295
  }
8247
8296
  this._onWillShowOverlay.fire(event);
8297
+ }), view.model.onUnhandledDragOverEvent((event) => {
8298
+ this._onUnhandledDragOverEvent.fire(event);
8248
8299
  }), view.model.onDidAddPanel((event) => {
8249
8300
  if (this._moving) {
8250
8301
  return;
@@ -9278,6 +9329,7 @@
9278
9329
  exports.DockviewGroupPanelModel = DockviewGroupPanelModel;
9279
9330
  exports.DockviewMutableDisposable = MutableDisposable;
9280
9331
  exports.DockviewPanel = DockviewPanel;
9332
+ exports.DockviewUnhandledDragOverEvent = DockviewUnhandledDragOverEvent;
9281
9333
  exports.DockviewWillDropEvent = DockviewWillDropEvent;
9282
9334
  exports.DraggablePaneviewPanel = DraggablePaneviewPanel;
9283
9335
  exports.Gridview = Gridview;
@@ -9285,6 +9337,7 @@
9285
9337
  exports.GridviewComponent = GridviewComponent;
9286
9338
  exports.GridviewPanel = GridviewPanel;
9287
9339
  exports.LocalSelectionTransfer = LocalSelectionTransfer;
9340
+ exports.PROPERTY_KEYS = PROPERTY_KEYS;
9288
9341
  exports.PaneFramework = PaneFramework;
9289
9342
  exports.PaneTransfer = PaneTransfer;
9290
9343
  exports.PanelTransfer = PanelTransfer;