dockview 1.12.0 → 1.13.0

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