dockview-react 1.17.2 → 2.0.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.
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * dockview-react
3
- * @version 1.17.2
3
+ * @version 2.0.0
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -328,31 +328,6 @@
328
328
  }
329
329
  }
330
330
 
331
- function createComponent(id, componentName, components = {}, frameworkComponents = {}, createFrameworkComponent, fallback) {
332
- const Component = typeof componentName === 'string'
333
- ? components[componentName]
334
- : undefined;
335
- const FrameworkComponent = typeof componentName === 'string'
336
- ? frameworkComponents[componentName]
337
- : undefined;
338
- if (Component && FrameworkComponent) {
339
- throw new Error(`Cannot create '${id}'. component '${componentName}' registered as both a component and frameworkComponent`);
340
- }
341
- if (FrameworkComponent) {
342
- if (!createFrameworkComponent) {
343
- throw new Error(`Cannot create '${id}' for framework component '${componentName}'. you must register a frameworkPanelWrapper to use framework components`);
344
- }
345
- return createFrameworkComponent.createComponent(id, componentName, FrameworkComponent);
346
- }
347
- if (!Component) {
348
- if (fallback) {
349
- return fallback();
350
- }
351
- throw new Error(`Cannot create '${id}', no component '${componentName}' provided`);
352
- }
353
- return new Component(id, componentName);
354
- }
355
-
356
331
  function watchElementResize(element, cb) {
357
332
  const observer = new ResizeObserver((entires) => {
358
333
  /**
@@ -821,10 +796,10 @@
821
796
  const tmp = this.size;
822
797
  this.size = this.orthogonalSize;
823
798
  this.orthogonalSize = tmp;
824
- removeClasses(this.element, 'horizontal', 'vertical');
799
+ removeClasses(this.element, 'dv-horizontal', 'dv-vertical');
825
800
  this.element.classList.add(this.orientation == exports.Orientation.HORIZONTAL
826
- ? 'horizontal'
827
- : 'vertical');
801
+ ? 'dv-horizontal'
802
+ : 'dv-vertical');
828
803
  }
829
804
  get minimumSize() {
830
805
  return this.viewItems.reduce((r, item) => r + item.minimumSize, 0);
@@ -1002,11 +977,11 @@
1002
977
  }
1003
978
  style(styles) {
1004
979
  if ((styles === null || styles === void 0 ? void 0 : styles.separatorBorder) === 'transparent') {
1005
- removeClasses(this.element, 'separator-border');
980
+ removeClasses(this.element, 'dv-separator-border');
1006
981
  this.element.style.removeProperty('--dv-separator-border');
1007
982
  }
1008
983
  else {
1009
- addClasses(this.element, 'separator-border');
984
+ addClasses(this.element, 'dv-separator-border');
1010
985
  if (styles === null || styles === void 0 ? void 0 : styles.separatorBorder) {
1011
986
  this.element.style.setProperty('--dv-separator-border', styles.separatorBorder);
1012
987
  }
@@ -1076,7 +1051,7 @@
1076
1051
  }
1077
1052
  addView(view, size = { type: 'distribute' }, index = this.viewItems.length, skipLayout) {
1078
1053
  const container = document.createElement('div');
1079
- container.className = 'view';
1054
+ container.className = 'dv-view';
1080
1055
  container.appendChild(view.element);
1081
1056
  let viewSize;
1082
1057
  if (typeof size === 'number') {
@@ -1108,7 +1083,7 @@
1108
1083
  if (this.viewItems.length > 1) {
1109
1084
  //add sash
1110
1085
  const sash = document.createElement('div');
1111
- sash.className = 'sash';
1086
+ sash.className = 'dv-sash';
1112
1087
  const onPointerStart = (event) => {
1113
1088
  for (const item of this.viewItems) {
1114
1089
  item.enabled = false;
@@ -1367,7 +1342,8 @@
1367
1342
  const offset = i === 0 || visiblePanelsBeforeThisView === 0
1368
1343
  ? 0
1369
1344
  : viewLeftOffsets[i - 1] +
1370
- (visiblePanelsBeforeThisView / sashCount) * marginReducedSize;
1345
+ (visiblePanelsBeforeThisView / sashCount) *
1346
+ marginReducedSize;
1371
1347
  if (i < this.viewItems.length - 1) {
1372
1348
  // calculate sash position
1373
1349
  const newSize = view.visible
@@ -1478,27 +1454,27 @@
1478
1454
  }
1479
1455
  }
1480
1456
  updateSash(sash, state) {
1481
- toggleClass(sash.container, 'disabled', state === exports.SashState.DISABLED);
1482
- toggleClass(sash.container, 'enabled', state === exports.SashState.ENABLED);
1483
- toggleClass(sash.container, 'maximum', state === exports.SashState.MAXIMUM);
1484
- toggleClass(sash.container, 'minimum', state === exports.SashState.MINIMUM);
1457
+ toggleClass(sash.container, 'dv-disabled', state === exports.SashState.DISABLED);
1458
+ toggleClass(sash.container, 'dv-enabled', state === exports.SashState.ENABLED);
1459
+ toggleClass(sash.container, 'dv-maximum', state === exports.SashState.MAXIMUM);
1460
+ toggleClass(sash.container, 'dv-minimum', state === exports.SashState.MINIMUM);
1485
1461
  }
1486
1462
  createViewContainer() {
1487
1463
  const element = document.createElement('div');
1488
- element.className = 'view-container';
1464
+ element.className = 'dv-view-container';
1489
1465
  return element;
1490
1466
  }
1491
1467
  createSashContainer() {
1492
1468
  const element = document.createElement('div');
1493
- element.className = 'sash-container';
1469
+ element.className = 'dv-sash-container';
1494
1470
  return element;
1495
1471
  }
1496
1472
  createContainer() {
1497
1473
  const element = document.createElement('div');
1498
1474
  const orientationClassname = this._orientation === exports.Orientation.HORIZONTAL
1499
- ? 'horizontal'
1500
- : 'vertical';
1501
- element.className = `split-view-container ${orientationClassname}`;
1475
+ ? 'dv-horizontal'
1476
+ : 'dv-vertical';
1477
+ element.className = `dv-split-view-container ${orientationClassname}`;
1502
1478
  return element;
1503
1479
  }
1504
1480
  dispose() {
@@ -1549,7 +1525,7 @@
1549
1525
  this.onDidChange = this._onDidChange.event;
1550
1526
  this._orientation = (_a = options.orientation) !== null && _a !== void 0 ? _a : exports.Orientation.VERTICAL;
1551
1527
  this.element = document.createElement('div');
1552
- this.element.className = 'pane-container';
1528
+ this.element.className = 'dv-pane-container';
1553
1529
  container.appendChild(this.element);
1554
1530
  this.splitview = new Splitview(this.element, {
1555
1531
  orientation: this._orientation,
@@ -1641,10 +1617,10 @@
1641
1617
  clearTimeout(this.animationTimer);
1642
1618
  this.animationTimer = undefined;
1643
1619
  }
1644
- addClasses(this.element, 'animated');
1620
+ addClasses(this.element, 'dv-animated');
1645
1621
  this.animationTimer = setTimeout(() => {
1646
1622
  this.animationTimer = undefined;
1647
- removeClasses(this.element, 'animated');
1623
+ removeClasses(this.element, 'dv-animated');
1648
1624
  }, 200);
1649
1625
  }
1650
1626
  dispose() {
@@ -1869,7 +1845,7 @@
1869
1845
  this._orthogonalSize = orthogonalSize;
1870
1846
  this._size = size;
1871
1847
  this.element = document.createElement('div');
1872
- this.element.className = 'branch-node';
1848
+ this.element.className = 'dv-branch-node';
1873
1849
  if (!childDescriptors) {
1874
1850
  this.splitview = new Splitview(this.element, {
1875
1851
  orientation: this.orientation,
@@ -2080,7 +2056,7 @@
2080
2056
  if (!parentElement) {
2081
2057
  throw new Error('Invalid grid element');
2082
2058
  }
2083
- if (/\bgrid-view\b/.test(parentElement.className)) {
2059
+ if (/\bdv-grid-view\b/.test(parentElement.className)) {
2084
2060
  return [];
2085
2061
  }
2086
2062
  const index = indexInParent(parentElement);
@@ -2428,7 +2404,7 @@
2428
2404
  this._onDidMaximizedNodeChange = new Emitter();
2429
2405
  this.onDidMaximizedNodeChange = this._onDidMaximizedNodeChange.event;
2430
2406
  this.element = document.createElement('div');
2431
- this.element.className = 'grid-view';
2407
+ this.element.className = 'dv-grid-view';
2432
2408
  this._locked = locked !== null && locked !== void 0 ? locked : false;
2433
2409
  this._margin = margin !== null && margin !== void 0 ? margin : 0;
2434
2410
  this.root = new BranchNode(orientation, proportionalLayout, styles, 0, 0, this.locked, this.margin);
@@ -3650,7 +3626,7 @@
3650
3626
  * dnd logic. You can see the code at
3651
3627
  * https://github.com/react-dnd/react-dnd/blob/main/packages/backend-html5/src/HTML5BackendImpl.ts#L542
3652
3628
  */
3653
- event.dataTransfer.setData('text/plain', '__dockview_internal_drag_event__');
3629
+ event.dataTransfer.setData('text/plain', '');
3654
3630
  }
3655
3631
  }
3656
3632
  }), addDisposableListener(this.el, 'dragend', () => {
@@ -3824,12 +3800,12 @@
3824
3800
  this.markAsUsed(e);
3825
3801
  if (!this.targetElement) {
3826
3802
  this.targetElement = document.createElement('div');
3827
- this.targetElement.className = 'drop-target-dropzone';
3803
+ this.targetElement.className = 'dv-drop-target-dropzone';
3828
3804
  this.overlayElement = document.createElement('div');
3829
- this.overlayElement.className = 'drop-target-selection';
3805
+ this.overlayElement.className = 'dv-drop-target-selection';
3830
3806
  this._state = 'center';
3831
3807
  this.targetElement.appendChild(this.overlayElement);
3832
- this.element.classList.add('drop-target');
3808
+ this.element.classList.add('dv-drop-target');
3833
3809
  this.element.append(this.targetElement);
3834
3810
  }
3835
3811
  this.toggleClasses(quadrant, width, height);
@@ -3967,7 +3943,7 @@
3967
3943
  this.element.removeChild(this.targetElement);
3968
3944
  this.targetElement = undefined;
3969
3945
  this.overlayElement = undefined;
3970
- this.element.classList.remove('drop-target');
3946
+ this.element.classList.remove('dv-drop-target');
3971
3947
  }
3972
3948
  }
3973
3949
  }
@@ -4304,7 +4280,7 @@
4304
4280
  this._headerVisible = isHeaderVisible;
4305
4281
  this._onDidChangeExpansionState.fire(this.isExpanded()); // initialize value
4306
4282
  this._orientation = orientation;
4307
- this.element.classList.add('pane');
4283
+ this.element.classList.add('dv-pane');
4308
4284
  this.addDisposables(this.api.onWillVisibilityChange((event) => {
4309
4285
  const { isVisible } = event;
4310
4286
  const { accessor } = this._params;
@@ -4401,14 +4377,14 @@
4401
4377
  renderOnce() {
4402
4378
  this.header = document.createElement('div');
4403
4379
  this.header.tabIndex = 0;
4404
- this.header.className = 'pane-header';
4380
+ this.header.className = 'dv-pane-header';
4405
4381
  this.header.style.height = `${this.headerSize}px`;
4406
4382
  this.header.style.lineHeight = `${this.headerSize}px`;
4407
4383
  this.header.style.minHeight = `${this.headerSize}px`;
4408
4384
  this.header.style.maxHeight = `${this.headerSize}px`;
4409
4385
  this.element.appendChild(this.header);
4410
4386
  this.body = document.createElement('div');
4411
- this.body.className = 'pane-body';
4387
+ this.body.className = 'dv-pane-body';
4412
4388
  this.element.appendChild(this.body);
4413
4389
  }
4414
4390
  // TODO slightly hacky by-pass of the component to create a body and header component
@@ -4529,7 +4505,7 @@
4529
4505
  this._onDidBlur = new Emitter();
4530
4506
  this.onDidBlur = this._onDidBlur.event;
4531
4507
  this._element = document.createElement('div');
4532
- this._element.className = 'content-container';
4508
+ this._element.className = 'dv-content-container';
4533
4509
  this._element.tabIndex = -1;
4534
4510
  this.addDisposables(this._onDidFocus, this._onDidBlur);
4535
4511
  this.dropTarget = new Droptarget(this.element, {
@@ -4602,6 +4578,8 @@
4602
4578
  referenceContainer: this,
4603
4579
  });
4604
4580
  break;
4581
+ default:
4582
+ throw new Error(`dockview: invalid renderer type '${panel.api.renderer}'`);
4605
4583
  }
4606
4584
  if (doRender) {
4607
4585
  const focusTracker = trackFocus(container);
@@ -4668,10 +4646,10 @@
4668
4646
  this._onDragStart = new Emitter();
4669
4647
  this.onDragStart = this._onDragStart.event;
4670
4648
  this._element = document.createElement('div');
4671
- this._element.className = 'tab';
4649
+ this._element.className = 'dv-tab';
4672
4650
  this._element.tabIndex = 0;
4673
4651
  this._element.draggable = true;
4674
- toggleClass(this.element, 'inactive-tab', true);
4652
+ toggleClass(this.element, 'dv-inactive-tab', true);
4675
4653
  const dragHandler = new TabDragHandler(this._element, this.accessor, this.group, this.panel);
4676
4654
  this.dropTarget = new Droptarget(this._element, {
4677
4655
  acceptedTargetZones: ['center'],
@@ -4704,8 +4682,8 @@
4704
4682
  }), this.dropTarget);
4705
4683
  }
4706
4684
  setActive(isActive) {
4707
- toggleClass(this.element, 'active-tab', isActive);
4708
- toggleClass(this.element, 'inactive-tab', !isActive);
4685
+ toggleClass(this.element, 'dv-active-tab', isActive);
4686
+ toggleClass(this.element, 'dv-inactive-tab', !isActive);
4709
4687
  }
4710
4688
  setContent(part) {
4711
4689
  if (this.content) {
@@ -4793,7 +4771,7 @@
4793
4771
  this._onDragStart = new Emitter();
4794
4772
  this.onDragStart = this._onDragStart.event;
4795
4773
  this._element = document.createElement('div');
4796
- this._element.className = 'void-container';
4774
+ this._element.className = 'dv-void-container';
4797
4775
  this._element.tabIndex = 0;
4798
4776
  this._element.draggable = true;
4799
4777
  this.addDisposables(this._onDrop, this._onDragStart, addDisposableListener(this._element, 'pointerdown', () => {
@@ -4913,16 +4891,16 @@
4913
4891
  this._onWillShowOverlay = new Emitter();
4914
4892
  this.onWillShowOverlay = this._onWillShowOverlay.event;
4915
4893
  this._element = document.createElement('div');
4916
- this._element.className = 'tabs-and-actions-container';
4894
+ this._element.className = 'dv-tabs-and-actions-container';
4917
4895
  toggleClass(this._element, 'dv-full-width-single-tab', this.accessor.options.singleTabMode === 'fullwidth');
4918
4896
  this.rightActionsContainer = document.createElement('div');
4919
- this.rightActionsContainer.className = 'right-actions-container';
4897
+ this.rightActionsContainer.className = 'dv-right-actions-container';
4920
4898
  this.leftActionsContainer = document.createElement('div');
4921
- this.leftActionsContainer.className = 'left-actions-container';
4899
+ this.leftActionsContainer.className = 'dv-left-actions-container';
4922
4900
  this.preActionsContainer = document.createElement('div');
4923
- this.preActionsContainer.className = 'pre-actions-container';
4901
+ this.preActionsContainer.className = 'dv-pre-actions-container';
4924
4902
  this.tabContainer = document.createElement('div');
4925
- this.tabContainer.className = 'tabs-container';
4903
+ this.tabContainer.className = 'dv-tabs-container';
4926
4904
  this.voidContainer = new VoidContainer(this.accessor, this.group);
4927
4905
  this._element.appendChild(this.preActionsContainer);
4928
4906
  this._element.appendChild(this.tabContainer);
@@ -5011,14 +4989,10 @@
5011
4989
  });
5012
4990
  }
5013
4991
  openPanel(panel, index = this.tabs.length) {
5014
- var _a;
5015
4992
  if (this.tabs.find((tab) => tab.value.panel.id === panel.id)) {
5016
4993
  return;
5017
4994
  }
5018
4995
  const tab = new Tab(panel, this.accessor, this.group);
5019
- if (!((_a = panel.view) === null || _a === void 0 ? void 0 : _a.tab)) {
5020
- throw new Error('invalid header component');
5021
- }
5022
4996
  tab.setContent(panel.view.tab);
5023
4997
  const disposable = new CompositeDisposable(tab.onDragStart((event) => {
5024
4998
  this._onTabDragStart.fire({ nativeEvent: event, panel });
@@ -5208,7 +5182,7 @@
5208
5182
  }
5209
5183
  class DockviewGroupPanelModel extends CompositeDisposable {
5210
5184
  get element() {
5211
- throw new Error('not supported');
5185
+ throw new Error('dockview: not supported');
5212
5186
  }
5213
5187
  get activePanel() {
5214
5188
  return this._activePanel;
@@ -5218,7 +5192,7 @@
5218
5192
  }
5219
5193
  set locked(value) {
5220
5194
  this._locked = value;
5221
- toggleClass(this.container, 'locked-groupview', value === 'no-drop-target' || value);
5195
+ toggleClass(this.container, 'dv-locked-groupview', value === 'no-drop-target' || value);
5222
5196
  }
5223
5197
  get isActive() {
5224
5198
  return this._isGroupActive;
@@ -5289,6 +5263,7 @@
5289
5263
  this._locked = false;
5290
5264
  this._location = { type: 'grid' };
5291
5265
  this.mostRecentlyUsed = [];
5266
+ this._overwriteRenderContainer = null;
5292
5267
  this._onDidChange = new Emitter();
5293
5268
  this.onDidChange = this._onDidChange.event;
5294
5269
  this._width = 0;
@@ -5319,8 +5294,7 @@
5319
5294
  this.onDidActivePanelChange = this._onDidActivePanelChange.event;
5320
5295
  this._onUnhandledDragOverEvent = new Emitter();
5321
5296
  this.onUnhandledDragOverEvent = this._onUnhandledDragOverEvent.event;
5322
- this._overwriteRenderContainer = null;
5323
- toggleClass(this.container, 'groupview', true);
5297
+ toggleClass(this.container, 'dv-groupview', true);
5324
5298
  this._api = new DockviewApi(this.accessor);
5325
5299
  this.tabsContainer = new TabsContainer(this.accessor, this.groupPanel);
5326
5300
  this.contentContainer = new ContentContainer(this.accessor, this);
@@ -5565,8 +5539,8 @@
5565
5539
  return;
5566
5540
  }
5567
5541
  this._isGroupActive = isGroupActive;
5568
- toggleClass(this.container, 'active-group', isGroupActive);
5569
- toggleClass(this.container, 'inactive-group', !isGroupActive);
5542
+ toggleClass(this.container, 'dv-active-group', isGroupActive);
5543
+ toggleClass(this.container, 'dv-inactive-group', !isGroupActive);
5570
5544
  this.tabsContainer.setActive(this.isActive);
5571
5545
  if (!this._activePanel && this.panels.length > 0) {
5572
5546
  this.doSetActivePanel(this.panels[0]);
@@ -5658,7 +5632,7 @@
5658
5632
  }
5659
5633
  updateContainer() {
5660
5634
  var _a, _b;
5661
- toggleClass(this.container, 'empty', this.isEmpty);
5635
+ toggleClass(this.container, 'dv-empty', this.isEmpty);
5662
5636
  this.panels.forEach((panel) => panel.runEvents());
5663
5637
  if (this.isEmpty && !this.watermark) {
5664
5638
  const watermark = this.accessor.createWatermarkComponent();
@@ -5799,6 +5773,34 @@
5799
5773
  return this._snap;
5800
5774
  }
5801
5775
  get minimumWidth() {
5776
+ /**
5777
+ * defer to protected function to allow subclasses to override easily.
5778
+ * see https://github.com/microsoft/TypeScript/issues/338
5779
+ */
5780
+ return this.__minimumWidth();
5781
+ }
5782
+ get minimumHeight() {
5783
+ /**
5784
+ * defer to protected function to allow subclasses to override easily.
5785
+ * see https://github.com/microsoft/TypeScript/issues/338
5786
+ */
5787
+ return this.__minimumHeight();
5788
+ }
5789
+ get maximumHeight() {
5790
+ /**
5791
+ * defer to protected function to allow subclasses to override easily.
5792
+ * see https://github.com/microsoft/TypeScript/issues/338
5793
+ */
5794
+ return this.__maximumHeight();
5795
+ }
5796
+ get maximumWidth() {
5797
+ /**
5798
+ * defer to protected function to allow subclasses to override easily.
5799
+ * see https://github.com/microsoft/TypeScript/issues/338
5800
+ */
5801
+ return this.__maximumWidth();
5802
+ }
5803
+ __minimumWidth() {
5802
5804
  const width = typeof this._minimumWidth === 'function'
5803
5805
  ? this._minimumWidth()
5804
5806
  : this._minimumWidth;
@@ -5808,7 +5810,17 @@
5808
5810
  }
5809
5811
  return width;
5810
5812
  }
5811
- get minimumHeight() {
5813
+ __maximumWidth() {
5814
+ const width = typeof this._maximumWidth === 'function'
5815
+ ? this._maximumWidth()
5816
+ : this._maximumWidth;
5817
+ if (width !== this._evaluatedMaximumWidth) {
5818
+ this._evaluatedMaximumWidth = width;
5819
+ this.updateConstraints();
5820
+ }
5821
+ return width;
5822
+ }
5823
+ __minimumHeight() {
5812
5824
  const height = typeof this._minimumHeight === 'function'
5813
5825
  ? this._minimumHeight()
5814
5826
  : this._minimumHeight;
@@ -5818,7 +5830,7 @@
5818
5830
  }
5819
5831
  return height;
5820
5832
  }
5821
- get maximumHeight() {
5833
+ __maximumHeight() {
5822
5834
  const height = typeof this._maximumHeight === 'function'
5823
5835
  ? this._maximumHeight()
5824
5836
  : this._maximumHeight;
@@ -5828,16 +5840,6 @@
5828
5840
  }
5829
5841
  return height;
5830
5842
  }
5831
- get maximumWidth() {
5832
- const width = typeof this._maximumWidth === 'function'
5833
- ? this._maximumWidth()
5834
- : this._maximumWidth;
5835
- if (width !== this._evaluatedMaximumWidth) {
5836
- this._evaluatedMaximumWidth = width;
5837
- this.updateConstraints();
5838
- }
5839
- return width;
5840
- }
5841
5843
  get isActive() {
5842
5844
  return this.api.isActive;
5843
5845
  }
@@ -5988,6 +5990,7 @@
5988
5990
  position: options.group
5989
5991
  ? (_c = options.position) !== null && _c !== void 0 ? _c : 'center'
5990
5992
  : 'center',
5993
+ index: options.index,
5991
5994
  },
5992
5995
  });
5993
5996
  }
@@ -6039,30 +6042,34 @@
6039
6042
  get minimumWidth() {
6040
6043
  var _a;
6041
6044
  const activePanelMinimumWidth = (_a = this.activePanel) === null || _a === void 0 ? void 0 : _a.minimumWidth;
6042
- return typeof activePanelMinimumWidth === 'number'
6043
- ? activePanelMinimumWidth
6044
- : MINIMUM_DOCKVIEW_GROUP_PANEL_WIDTH;
6045
+ if (typeof activePanelMinimumWidth === 'number') {
6046
+ return activePanelMinimumWidth;
6047
+ }
6048
+ return super.__minimumWidth();
6045
6049
  }
6046
6050
  get minimumHeight() {
6047
6051
  var _a;
6048
6052
  const activePanelMinimumHeight = (_a = this.activePanel) === null || _a === void 0 ? void 0 : _a.minimumHeight;
6049
- return typeof activePanelMinimumHeight === 'number'
6050
- ? activePanelMinimumHeight
6051
- : MINIMUM_DOCKVIEW_GROUP_PANEL_HEIGHT;
6053
+ if (typeof activePanelMinimumHeight === 'number') {
6054
+ return activePanelMinimumHeight;
6055
+ }
6056
+ return super.__minimumHeight();
6052
6057
  }
6053
6058
  get maximumWidth() {
6054
6059
  var _a;
6055
6060
  const activePanelMaximumWidth = (_a = this.activePanel) === null || _a === void 0 ? void 0 : _a.maximumWidth;
6056
- return typeof activePanelMaximumWidth === 'number'
6057
- ? activePanelMaximumWidth
6058
- : Number.MAX_SAFE_INTEGER;
6061
+ if (typeof activePanelMaximumWidth === 'number') {
6062
+ return activePanelMaximumWidth;
6063
+ }
6064
+ return super.__maximumWidth();
6059
6065
  }
6060
6066
  get maximumHeight() {
6061
6067
  var _a;
6062
6068
  const activePanelMaximumHeight = (_a = this.activePanel) === null || _a === void 0 ? void 0 : _a.maximumHeight;
6063
- return typeof activePanelMaximumHeight === 'number'
6064
- ? activePanelMaximumHeight
6065
- : Number.MAX_SAFE_INTEGER;
6069
+ if (typeof activePanelMaximumHeight === 'number') {
6070
+ return activePanelMaximumHeight;
6071
+ }
6072
+ return super.__maximumHeight();
6066
6073
  }
6067
6074
  get panels() {
6068
6075
  return this._model.panels;
@@ -6176,12 +6183,14 @@
6176
6183
  return this.group.api.getWindow();
6177
6184
  }
6178
6185
  moveTo(options) {
6179
- var _a;
6186
+ var _a, _b;
6180
6187
  this.accessor.moveGroupOrPanel({
6181
6188
  from: { groupId: this._group.id, panelId: this.panel.id },
6182
6189
  to: {
6183
- group: options.group,
6184
- position: (_a = options.position) !== null && _a !== void 0 ? _a : 'center',
6190
+ group: (_a = options.group) !== null && _a !== void 0 ? _a : this._group,
6191
+ position: options.group
6192
+ ? (_b = options.position) !== null && _b !== void 0 ? _b : 'center'
6193
+ : 'center',
6185
6194
  index: options.index,
6186
6195
  },
6187
6196
  });
@@ -6400,7 +6409,7 @@
6400
6409
  svg.setAttributeNS(null, 'viewBox', params.viewbox);
6401
6410
  svg.setAttributeNS(null, 'aria-hidden', 'false');
6402
6411
  svg.setAttributeNS(null, 'focusable', 'false');
6403
- svg.classList.add('dockview-svg');
6412
+ svg.classList.add('dv-svg');
6404
6413
  const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
6405
6414
  path.setAttributeNS(null, 'd', params.path);
6406
6415
  svg.appendChild(path);
@@ -6571,19 +6580,19 @@
6571
6580
  constructor() {
6572
6581
  super();
6573
6582
  this._element = document.createElement('div');
6574
- this._element.className = 'watermark';
6583
+ this._element.className = 'dv-watermark';
6575
6584
  const title = document.createElement('div');
6576
- title.className = 'watermark-title';
6585
+ title.className = 'dv-watermark-title';
6577
6586
  const emptySpace = document.createElement('span');
6578
6587
  emptySpace.style.flexGrow = '1';
6579
6588
  const content = document.createElement('div');
6580
- content.className = 'watermark-content';
6589
+ content.className = 'dv-watermark-content';
6581
6590
  this._element.appendChild(title);
6582
6591
  this._element.appendChild(content);
6583
6592
  const actionsContainer = document.createElement('div');
6584
- actionsContainer.className = 'actions-container';
6593
+ actionsContainer.className = 'dv-actions-container';
6585
6594
  const closeAnchor = document.createElement('div');
6586
- closeAnchor.className = 'close-action';
6595
+ closeAnchor.className = 'dv-close-action';
6587
6596
  closeAnchor.appendChild(createCloseButton());
6588
6597
  actionsContainer.appendChild(closeAnchor);
6589
6598
  title.appendChild(emptySpace);
@@ -6603,7 +6612,7 @@
6603
6612
  }
6604
6613
  render() {
6605
6614
  const isOneGroup = !!(this._api && this._api.size <= 1);
6606
- toggleClass(this.element, 'has-actions', isOneGroup);
6615
+ toggleClass(this.element, 'dv-has-actions', isOneGroup);
6607
6616
  }
6608
6617
  }
6609
6618
 
@@ -7214,7 +7223,6 @@
7214
7223
  window: this._window.value,
7215
7224
  });
7216
7225
  this._window.disposable.dispose();
7217
- this._window.value.close();
7218
7226
  this._window = null;
7219
7227
  this._onDidClose.fire();
7220
7228
  }
@@ -7246,7 +7254,9 @@
7246
7254
  }
7247
7255
  const disposable = new CompositeDisposable();
7248
7256
  this._window = { value: externalWindow, disposable };
7249
- disposable.addDisposables(addDisposableWindowListener(window, 'beforeunload', () => {
7257
+ disposable.addDisposables(exports.DockviewDisposable.from(() => {
7258
+ externalWindow.close();
7259
+ }), addDisposableWindowListener(window, 'beforeunload', () => {
7250
7260
  /**
7251
7261
  * before the main window closes we should close this popup too
7252
7262
  * to be good citizens
@@ -7263,7 +7273,7 @@
7263
7273
  id: this.target,
7264
7274
  window: externalWindow,
7265
7275
  });
7266
- return new Promise((resolve) => {
7276
+ return new Promise((resolve, reject) => {
7267
7277
  externalWindow.addEventListener('unload', (e) => {
7268
7278
  // if page fails to load before unloading
7269
7279
  // this.close();
@@ -7272,21 +7282,27 @@
7272
7282
  /**
7273
7283
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/load_event
7274
7284
  */
7275
- const externalDocument = externalWindow.document;
7276
- externalDocument.title = document.title;
7277
- externalDocument.body.appendChild(container);
7278
- addStyles(externalDocument, window.document.styleSheets);
7279
- /**
7280
- * beforeunload must be registered after load for reasons I could not determine
7281
- * otherwise the beforeunload event will not fire when the window is closed
7282
- */
7283
- addDisposableWindowListener(externalWindow, 'beforeunload', () => {
7285
+ try {
7286
+ const externalDocument = externalWindow.document;
7287
+ externalDocument.title = document.title;
7288
+ externalDocument.body.appendChild(container);
7289
+ addStyles(externalDocument, window.document.styleSheets);
7284
7290
  /**
7285
- * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event
7291
+ * beforeunload must be registered after load for reasons I could not determine
7292
+ * otherwise the beforeunload event will not fire when the window is closed
7286
7293
  */
7287
- this.close();
7288
- });
7289
- resolve(container);
7294
+ addDisposableWindowListener(externalWindow, 'beforeunload', () => {
7295
+ /**
7296
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event
7297
+ */
7298
+ this.close();
7299
+ });
7300
+ resolve(container);
7301
+ }
7302
+ catch (err) {
7303
+ // only except this is the DOM isn't setup. e.g. in a in correctly configured test
7304
+ reject(err);
7305
+ }
7290
7306
  });
7291
7307
  });
7292
7308
  });
@@ -7539,9 +7555,6 @@
7539
7555
  }
7540
7556
  const box = getBox();
7541
7557
  const groupId = (_b = (_a = options === null || options === void 0 ? void 0 : options.overridePopoutGroup) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : this.getNextGroupId();
7542
- if (itemToPopout.api.location.type === 'grid') {
7543
- itemToPopout.api.setVisible(false);
7544
- }
7545
7558
  const _window = new PopoutWindow(`${this.id}-${groupId}`, // unique id
7546
7559
  theme !== null && theme !== void 0 ? theme : '', {
7547
7560
  url: (_c = options === null || options === void 0 ? void 0 : options.popoutUrl) !== null && _c !== void 0 ? _c : '/popout.html',
@@ -7560,11 +7573,11 @@
7560
7573
  .then((popoutContainer) => {
7561
7574
  var _a;
7562
7575
  if (_window.isDisposed) {
7563
- return;
7576
+ return false;
7564
7577
  }
7565
7578
  if (popoutContainer === null) {
7566
7579
  popoutWindowDisposable.dispose();
7567
- return;
7580
+ return false;
7568
7581
  }
7569
7582
  const gready = document.createElement('div');
7570
7583
  gready.className = 'dv-overlay-render-container';
@@ -7573,30 +7586,40 @@
7573
7586
  ? itemToPopout.group
7574
7587
  : itemToPopout;
7575
7588
  const referenceLocation = itemToPopout.api.location.type;
7576
- const group = (_a = options === null || options === void 0 ? void 0 : options.overridePopoutGroup) !== null && _a !== void 0 ? _a : this.createGroup({ id: groupId });
7589
+ /**
7590
+ * The group that is being added doesn't already exist within the DOM, the most likely occurance
7591
+ * of this case is when being called from the `fromJSON(...)` method
7592
+ */
7593
+ const isGroupAddedToDom = referenceGroup.element.parentElement !== null;
7594
+ const group = !isGroupAddedToDom
7595
+ ? referenceGroup
7596
+ : (_a = options === null || options === void 0 ? void 0 : options.overridePopoutGroup) !== null && _a !== void 0 ? _a : this.createGroup({ id: groupId });
7577
7597
  group.model.renderContainer = overlayRenderContainer;
7578
- if (!(options === null || options === void 0 ? void 0 : options.overridePopoutGroup)) {
7598
+ group.layout(_window.window.innerWidth, _window.window.innerHeight);
7599
+ if (!this._groups.has(group.api.id)) {
7579
7600
  this._onDidAddGroup.fire(group);
7580
7601
  }
7581
- if (itemToPopout instanceof DockviewPanel) {
7582
- this.movingLock(() => {
7583
- const panel = referenceGroup.model.removePanel(itemToPopout);
7584
- group.model.openPanel(panel);
7585
- });
7586
- }
7587
- else {
7588
- this.movingLock(() => moveGroupWithoutDestroying({
7589
- from: referenceGroup,
7590
- to: group,
7591
- }));
7592
- switch (referenceLocation) {
7593
- case 'grid':
7594
- referenceGroup.api.setVisible(false);
7595
- break;
7596
- case 'floating':
7597
- case 'popout':
7598
- this.removeGroup(referenceGroup);
7599
- break;
7602
+ if (!(options === null || options === void 0 ? void 0 : options.overridePopoutGroup) && isGroupAddedToDom) {
7603
+ if (itemToPopout instanceof DockviewPanel) {
7604
+ this.movingLock(() => {
7605
+ const panel = referenceGroup.model.removePanel(itemToPopout);
7606
+ group.model.openPanel(panel);
7607
+ });
7608
+ }
7609
+ else {
7610
+ this.movingLock(() => moveGroupWithoutDestroying({
7611
+ from: referenceGroup,
7612
+ to: group,
7613
+ }));
7614
+ switch (referenceLocation) {
7615
+ case 'grid':
7616
+ referenceGroup.api.setVisible(false);
7617
+ break;
7618
+ case 'floating':
7619
+ case 'popout':
7620
+ this.removeGroup(referenceGroup);
7621
+ break;
7622
+ }
7600
7623
  }
7601
7624
  }
7602
7625
  popoutContainer.classList.add('dv-dockview');
@@ -7607,6 +7630,10 @@
7607
7630
  type: 'popout',
7608
7631
  getWindow: () => _window.window,
7609
7632
  };
7633
+ if (isGroupAddedToDom &&
7634
+ itemToPopout.api.location.type === 'grid') {
7635
+ itemToPopout.api.setVisible(false);
7636
+ }
7610
7637
  this.doSetGroupAndPanelActive(group);
7611
7638
  popoutWindowDisposable.addDisposables(group.api.onDidActiveChange((event) => {
7612
7639
  var _a;
@@ -7621,9 +7648,13 @@
7621
7648
  const value = {
7622
7649
  window: _window,
7623
7650
  popoutGroup: group,
7624
- referenceGroup: this.getPanel(referenceGroup.id)
7625
- ? referenceGroup.id
7626
- : undefined,
7651
+ referenceGroup: !isGroupAddedToDom
7652
+ ? undefined
7653
+ : referenceGroup
7654
+ ? this.getPanel(referenceGroup.id)
7655
+ ? referenceGroup.id
7656
+ : undefined
7657
+ : undefined,
7627
7658
  disposable: {
7628
7659
  dispose: () => {
7629
7660
  popoutWindowDisposable.dispose();
@@ -7638,9 +7669,10 @@
7638
7669
  * window dimensions
7639
7670
  */
7640
7671
  addDisposableWindowListener(_window.window, 'resize', () => {
7641
- group.layout(window.innerWidth, window.innerHeight);
7672
+ group.layout(_window.window.innerWidth, _window.window.innerHeight);
7642
7673
  }), overlayRenderContainer, exports.DockviewDisposable.from(() => {
7643
- if (this.getPanel(referenceGroup.id)) {
7674
+ if (isGroupAddedToDom &&
7675
+ this.getPanel(referenceGroup.id)) {
7644
7676
  this.movingLock(() => moveGroupWithoutDestroying({
7645
7677
  from: group,
7646
7678
  to: referenceGroup,
@@ -7655,21 +7687,27 @@
7655
7687
  }
7656
7688
  }
7657
7689
  else if (this.getPanel(group.id)) {
7658
- const removedGroup = this.doRemoveGroup(group, {
7690
+ this.doRemoveGroup(group, {
7659
7691
  skipDispose: true,
7660
7692
  skipActive: true,
7693
+ skipPopoutReturn: true,
7661
7694
  });
7695
+ const removedGroup = group;
7662
7696
  removedGroup.model.renderContainer =
7663
7697
  this.overlayRenderContainer;
7664
7698
  removedGroup.model.location = { type: 'grid' };
7665
7699
  returnedGroup = removedGroup;
7700
+ this.doAddGroup(removedGroup, [0]);
7701
+ this.doSetGroupAndPanelActive(removedGroup);
7666
7702
  }
7667
7703
  }));
7668
7704
  this._popoutGroups.push(value);
7669
7705
  this.updateWatermark();
7706
+ return true;
7670
7707
  })
7671
7708
  .catch((err) => {
7672
7709
  console.error('dockview: failed to create popout window', err);
7710
+ return false;
7673
7711
  });
7674
7712
  }
7675
7713
  addFloatingGroup(item, options) {
@@ -7773,7 +7811,7 @@
7773
7811
  : (_c = (_b = this.options.floatingGroupBounds) === null || _b === void 0 ? void 0 : _b.minimumWidthWithinViewport) !== null && _c !== void 0 ? _c : DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE, minimumInViewportHeight: this.options.floatingGroupBounds === 'boundedWithinViewport'
7774
7812
  ? undefined
7775
7813
  : (_e = (_d = this.options.floatingGroupBounds) === null || _d === void 0 ? void 0 : _d.minimumHeightWithinViewport) !== null && _e !== void 0 ? _e : DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE }));
7776
- const el = group.element.querySelector('.void-container');
7814
+ const el = group.element.querySelector('.dv-void-container');
7777
7815
  if (!el) {
7778
7816
  throw new Error('failed to find drag handle');
7779
7817
  }
@@ -8056,7 +8094,6 @@
8056
8094
  this.addPopoutGroup((_c = (gridReferenceGroup
8057
8095
  ? this.getPanel(gridReferenceGroup)
8058
8096
  : undefined)) !== null && _c !== void 0 ? _c : group, {
8059
- skipRemoveGroup: true,
8060
8097
  position: position !== null && position !== void 0 ? position : undefined,
8061
8098
  overridePopoutGroup: gridReferenceGroup
8062
8099
  ? group
@@ -8074,6 +8111,7 @@
8074
8111
  }
8075
8112
  }
8076
8113
  catch (err) {
8114
+ console.error('dockview: failed to deserialize layout. Reverting changes', err);
8077
8115
  /**
8078
8116
  * Takes all the successfully created groups and remove all of their panels.
8079
8117
  */
@@ -8141,11 +8179,13 @@
8141
8179
  width: options.initialWidth,
8142
8180
  height: options.initialHeight,
8143
8181
  };
8182
+ let index;
8144
8183
  if (options.position) {
8145
8184
  if (isPanelOptionsWithPanel(options.position)) {
8146
8185
  const referencePanel = typeof options.position.referencePanel === 'string'
8147
8186
  ? this.getGroupPanel(options.position.referencePanel)
8148
8187
  : options.position.referencePanel;
8188
+ index = options.position.index;
8149
8189
  if (!referencePanel) {
8150
8190
  throw new Error(`referencePanel '${options.position.referencePanel}' does not exist`);
8151
8191
  }
@@ -8156,6 +8196,7 @@
8156
8196
  typeof options.position.referenceGroup === 'string'
8157
8197
  ? (_a = this._groups.get(options.position.referenceGroup)) === null || _a === void 0 ? void 0 : _a.value
8158
8198
  : options.position.referenceGroup;
8199
+ index = options.position.index;
8159
8200
  if (!referenceGroup) {
8160
8201
  throw new Error(`referenceGroup '${options.position.referenceGroup}' does not exist`);
8161
8202
  }
@@ -8166,6 +8207,7 @@
8166
8207
  group.model.openPanel(panel, {
8167
8208
  skipSetActive: options.inactive,
8168
8209
  skipSetGroupActive: options.inactive,
8210
+ index,
8169
8211
  });
8170
8212
  if (!options.inactive) {
8171
8213
  this.doSetGroupAndPanelActive(group);
@@ -8195,6 +8237,7 @@
8195
8237
  group.model.openPanel(panel, {
8196
8238
  skipSetActive: options.inactive,
8197
8239
  skipSetGroupActive: options.inactive,
8240
+ index,
8198
8241
  });
8199
8242
  }
8200
8243
  else if (referenceGroup.api.location.type === 'floating' ||
@@ -8203,6 +8246,7 @@
8203
8246
  referenceGroup.model.openPanel(panel, {
8204
8247
  skipSetActive: options.inactive,
8205
8248
  skipSetGroupActive: options.inactive,
8249
+ index,
8206
8250
  });
8207
8251
  referenceGroup.api.setSize({
8208
8252
  width: initial === null || initial === void 0 ? void 0 : initial.width,
@@ -8223,6 +8267,7 @@
8223
8267
  group.model.openPanel(panel, {
8224
8268
  skipSetActive: options.inactive,
8225
8269
  skipSetGroupActive: options.inactive,
8270
+ index,
8226
8271
  });
8227
8272
  if (!options.inactive) {
8228
8273
  this.doSetGroupAndPanelActive(group);
@@ -8241,6 +8286,7 @@
8241
8286
  group.model.openPanel(panel, {
8242
8287
  skipSetActive: options.inactive,
8243
8288
  skipSetGroupActive: options.inactive,
8289
+ index,
8244
8290
  });
8245
8291
  }
8246
8292
  else {
@@ -8251,6 +8297,7 @@
8251
8297
  group.model.openPanel(panel, {
8252
8298
  skipSetActive: options.inactive,
8253
8299
  skipSetGroupActive: options.inactive,
8300
+ index,
8254
8301
  });
8255
8302
  if (!options.inactive) {
8256
8303
  this.doSetGroupAndPanelActive(group);
@@ -8791,6 +8838,31 @@
8791
8838
  }
8792
8839
  }
8793
8840
 
8841
+ function createComponent(id, componentName, components = {}, frameworkComponents = {}, createFrameworkComponent, fallback) {
8842
+ const Component = typeof componentName === 'string'
8843
+ ? components[componentName]
8844
+ : undefined;
8845
+ const FrameworkComponent = typeof componentName === 'string'
8846
+ ? frameworkComponents[componentName]
8847
+ : undefined;
8848
+ if (Component && FrameworkComponent) {
8849
+ throw new Error(`Cannot create '${id}'. component '${componentName}' registered as both a component and frameworkComponent`);
8850
+ }
8851
+ if (FrameworkComponent) {
8852
+ if (!createFrameworkComponent) {
8853
+ throw new Error(`Cannot create '${id}' for framework component '${componentName}'. you must register a frameworkPanelWrapper to use framework components`);
8854
+ }
8855
+ return createFrameworkComponent.createComponent(id, componentName, FrameworkComponent);
8856
+ }
8857
+ if (!Component) {
8858
+ if (fallback) {
8859
+ return fallback();
8860
+ }
8861
+ throw new Error(`Cannot create '${id}', no component '${componentName}' provided`);
8862
+ }
8863
+ return new Component(id, componentName);
8864
+ }
8865
+
8794
8866
  class GridviewComponent extends BaseGrid {
8795
8867
  get orientation() {
8796
8868
  return this.gridview.orientation;
@@ -9339,12 +9411,14 @@
9339
9411
  this._expandedIcon = createExpandMoreButton();
9340
9412
  this._collapsedIcon = createChevronRightButton();
9341
9413
  this.disposable = new MutableDisposable();
9342
- this.apiRef = { api: null };
9414
+ this.apiRef = {
9415
+ api: null,
9416
+ };
9343
9417
  this._element = document.createElement('div');
9344
- this.element.className = 'default-header';
9418
+ this.element.className = 'dv-default-header';
9345
9419
  this._content = document.createElement('span');
9346
9420
  this._expander = document.createElement('div');
9347
- this._expander.className = 'dockview-pane-header-icon';
9421
+ this._expander.className = 'dv-pane-header-icon';
9348
9422
  this.element.appendChild(this._expander);
9349
9423
  this.element.appendChild(this._content);
9350
9424
  this.addDisposables(addDisposableListener(this._element, 'click', () => {
@@ -10201,22 +10275,6 @@
10201
10275
  disposable.dispose();
10202
10276
  };
10203
10277
  }, [props.onDidDrop]);
10204
- React.useEffect(() => {
10205
- if (!dockviewRef.current) {
10206
- return () => {
10207
- // noop
10208
- };
10209
- }
10210
- const disposable = dockviewRef.current.onUnhandledDragOverEvent((event) => {
10211
- var _a;
10212
- if ((_a = props.showDndOverlay) === null || _a === void 0 ? void 0 : _a.call(props, event)) {
10213
- event.accept();
10214
- }
10215
- });
10216
- return () => {
10217
- disposable.dispose();
10218
- };
10219
- }, [props.showDndOverlay]);
10220
10278
  React.useEffect(() => {
10221
10279
  if (!dockviewRef.current) {
10222
10280
  return () => {
@@ -10634,7 +10692,6 @@
10634
10692
  exports.GridviewComponent = GridviewComponent;
10635
10693
  exports.GridviewPanel = GridviewPanel;
10636
10694
  exports.GridviewReact = GridviewReact;
10637
- exports.LocalSelectionTransfer = LocalSelectionTransfer;
10638
10695
  exports.PROPERTY_KEYS = PROPERTY_KEYS;
10639
10696
  exports.PaneFramework = PaneFramework;
10640
10697
  exports.PaneTransfer = PaneTransfer;
@@ -10653,7 +10710,6 @@
10653
10710
  exports.SplitviewReact = SplitviewReact;
10654
10711
  exports.Tab = Tab;
10655
10712
  exports.WillShowOverlayLocationEvent = WillShowOverlayLocationEvent;
10656
- exports.createComponent = createComponent;
10657
10713
  exports.createDockview = createDockview;
10658
10714
  exports.createGridview = createGridview;
10659
10715
  exports.createPaneview = createPaneview;