dockview-react 1.17.2 → 2.1.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.1.0
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -324,31 +324,6 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
324
324
  }
325
325
  }
326
326
 
327
- function createComponent(id, componentName, components = {}, frameworkComponents = {}, createFrameworkComponent, fallback) {
328
- const Component = typeof componentName === 'string'
329
- ? components[componentName]
330
- : undefined;
331
- const FrameworkComponent = typeof componentName === 'string'
332
- ? frameworkComponents[componentName]
333
- : undefined;
334
- if (Component && FrameworkComponent) {
335
- throw new Error(`Cannot create '${id}'. component '${componentName}' registered as both a component and frameworkComponent`);
336
- }
337
- if (FrameworkComponent) {
338
- if (!createFrameworkComponent) {
339
- throw new Error(`Cannot create '${id}' for framework component '${componentName}'. you must register a frameworkPanelWrapper to use framework components`);
340
- }
341
- return createFrameworkComponent.createComponent(id, componentName, FrameworkComponent);
342
- }
343
- if (!Component) {
344
- if (fallback) {
345
- return fallback();
346
- }
347
- throw new Error(`Cannot create '${id}', no component '${componentName}' provided`);
348
- }
349
- return new Component(id, componentName);
350
- }
351
-
352
327
  function watchElementResize(element, cb) {
353
328
  const observer = new ResizeObserver((entires) => {
354
329
  /**
@@ -817,10 +792,10 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
817
792
  const tmp = this.size;
818
793
  this.size = this.orthogonalSize;
819
794
  this.orthogonalSize = tmp;
820
- removeClasses(this.element, 'horizontal', 'vertical');
795
+ removeClasses(this.element, 'dv-horizontal', 'dv-vertical');
821
796
  this.element.classList.add(this.orientation == exports.Orientation.HORIZONTAL
822
- ? 'horizontal'
823
- : 'vertical');
797
+ ? 'dv-horizontal'
798
+ : 'dv-vertical');
824
799
  }
825
800
  get minimumSize() {
826
801
  return this.viewItems.reduce((r, item) => r + item.minimumSize, 0);
@@ -998,11 +973,11 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
998
973
  }
999
974
  style(styles) {
1000
975
  if ((styles === null || styles === void 0 ? void 0 : styles.separatorBorder) === 'transparent') {
1001
- removeClasses(this.element, 'separator-border');
976
+ removeClasses(this.element, 'dv-separator-border');
1002
977
  this.element.style.removeProperty('--dv-separator-border');
1003
978
  }
1004
979
  else {
1005
- addClasses(this.element, 'separator-border');
980
+ addClasses(this.element, 'dv-separator-border');
1006
981
  if (styles === null || styles === void 0 ? void 0 : styles.separatorBorder) {
1007
982
  this.element.style.setProperty('--dv-separator-border', styles.separatorBorder);
1008
983
  }
@@ -1072,7 +1047,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1072
1047
  }
1073
1048
  addView(view, size = { type: 'distribute' }, index = this.viewItems.length, skipLayout) {
1074
1049
  const container = document.createElement('div');
1075
- container.className = 'view';
1050
+ container.className = 'dv-view';
1076
1051
  container.appendChild(view.element);
1077
1052
  let viewSize;
1078
1053
  if (typeof size === 'number') {
@@ -1104,7 +1079,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1104
1079
  if (this.viewItems.length > 1) {
1105
1080
  //add sash
1106
1081
  const sash = document.createElement('div');
1107
- sash.className = 'sash';
1082
+ sash.className = 'dv-sash';
1108
1083
  const onPointerStart = (event) => {
1109
1084
  for (const item of this.viewItems) {
1110
1085
  item.enabled = false;
@@ -1363,7 +1338,8 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1363
1338
  const offset = i === 0 || visiblePanelsBeforeThisView === 0
1364
1339
  ? 0
1365
1340
  : viewLeftOffsets[i - 1] +
1366
- (visiblePanelsBeforeThisView / sashCount) * marginReducedSize;
1341
+ (visiblePanelsBeforeThisView / sashCount) *
1342
+ marginReducedSize;
1367
1343
  if (i < this.viewItems.length - 1) {
1368
1344
  // calculate sash position
1369
1345
  const newSize = view.visible
@@ -1474,27 +1450,27 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1474
1450
  }
1475
1451
  }
1476
1452
  updateSash(sash, state) {
1477
- toggleClass(sash.container, 'disabled', state === exports.SashState.DISABLED);
1478
- toggleClass(sash.container, 'enabled', state === exports.SashState.ENABLED);
1479
- toggleClass(sash.container, 'maximum', state === exports.SashState.MAXIMUM);
1480
- toggleClass(sash.container, 'minimum', state === exports.SashState.MINIMUM);
1453
+ toggleClass(sash.container, 'dv-disabled', state === exports.SashState.DISABLED);
1454
+ toggleClass(sash.container, 'dv-enabled', state === exports.SashState.ENABLED);
1455
+ toggleClass(sash.container, 'dv-maximum', state === exports.SashState.MAXIMUM);
1456
+ toggleClass(sash.container, 'dv-minimum', state === exports.SashState.MINIMUM);
1481
1457
  }
1482
1458
  createViewContainer() {
1483
1459
  const element = document.createElement('div');
1484
- element.className = 'view-container';
1460
+ element.className = 'dv-view-container';
1485
1461
  return element;
1486
1462
  }
1487
1463
  createSashContainer() {
1488
1464
  const element = document.createElement('div');
1489
- element.className = 'sash-container';
1465
+ element.className = 'dv-sash-container';
1490
1466
  return element;
1491
1467
  }
1492
1468
  createContainer() {
1493
1469
  const element = document.createElement('div');
1494
1470
  const orientationClassname = this._orientation === exports.Orientation.HORIZONTAL
1495
- ? 'horizontal'
1496
- : 'vertical';
1497
- element.className = `split-view-container ${orientationClassname}`;
1471
+ ? 'dv-horizontal'
1472
+ : 'dv-vertical';
1473
+ element.className = `dv-split-view-container ${orientationClassname}`;
1498
1474
  return element;
1499
1475
  }
1500
1476
  dispose() {
@@ -1545,7 +1521,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1545
1521
  this.onDidChange = this._onDidChange.event;
1546
1522
  this._orientation = (_a = options.orientation) !== null && _a !== void 0 ? _a : exports.Orientation.VERTICAL;
1547
1523
  this.element = document.createElement('div');
1548
- this.element.className = 'pane-container';
1524
+ this.element.className = 'dv-pane-container';
1549
1525
  container.appendChild(this.element);
1550
1526
  this.splitview = new Splitview(this.element, {
1551
1527
  orientation: this._orientation,
@@ -1637,10 +1613,10 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1637
1613
  clearTimeout(this.animationTimer);
1638
1614
  this.animationTimer = undefined;
1639
1615
  }
1640
- addClasses(this.element, 'animated');
1616
+ addClasses(this.element, 'dv-animated');
1641
1617
  this.animationTimer = setTimeout(() => {
1642
1618
  this.animationTimer = undefined;
1643
- removeClasses(this.element, 'animated');
1619
+ removeClasses(this.element, 'dv-animated');
1644
1620
  }, 200);
1645
1621
  }
1646
1622
  dispose() {
@@ -1865,7 +1841,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1865
1841
  this._orthogonalSize = orthogonalSize;
1866
1842
  this._size = size;
1867
1843
  this.element = document.createElement('div');
1868
- this.element.className = 'branch-node';
1844
+ this.element.className = 'dv-branch-node';
1869
1845
  if (!childDescriptors) {
1870
1846
  this.splitview = new Splitview(this.element, {
1871
1847
  orientation: this.orientation,
@@ -2076,7 +2052,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2076
2052
  if (!parentElement) {
2077
2053
  throw new Error('Invalid grid element');
2078
2054
  }
2079
- if (/\bgrid-view\b/.test(parentElement.className)) {
2055
+ if (/\bdv-grid-view\b/.test(parentElement.className)) {
2080
2056
  return [];
2081
2057
  }
2082
2058
  const index = indexInParent(parentElement);
@@ -2213,6 +2189,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2213
2189
  if (this.hasMaximizedView()) {
2214
2190
  this.exitMaximizedView();
2215
2191
  }
2192
+ serializeBranchNode(this.getView(), this.orientation);
2216
2193
  const hiddenOnMaximize = [];
2217
2194
  function hideAllViewsBut(parent, exclude) {
2218
2195
  for (let i = 0; i < parent.children.length; i++) {
@@ -2234,7 +2211,10 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2234
2211
  }
2235
2212
  hideAllViewsBut(this.root, node);
2236
2213
  this._maximizedNode = { leaf: node, hiddenOnMaximize };
2237
- this._onDidMaximizedNodeChange.fire();
2214
+ this._onDidMaximizedNodeChange.fire({
2215
+ view: node.view,
2216
+ isMaximized: true,
2217
+ });
2238
2218
  }
2239
2219
  exitMaximizedView() {
2240
2220
  if (!this._maximizedNode) {
@@ -2255,24 +2235,51 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2255
2235
  }
2256
2236
  }
2257
2237
  showViewsInReverseOrder(this.root);
2238
+ const tmp = this._maximizedNode.leaf;
2258
2239
  this._maximizedNode = undefined;
2259
- this._onDidMaximizedNodeChange.fire();
2240
+ this._onDidMaximizedNodeChange.fire({
2241
+ view: tmp.view,
2242
+ isMaximized: false,
2243
+ });
2260
2244
  }
2261
2245
  serialize() {
2246
+ const maximizedView = this.maximizedView();
2247
+ let maxmizedViewLocation;
2248
+ if (maximizedView) {
2249
+ /**
2250
+ * The minimum information we can get away with in order to serialize a maxmized view is it's location within the grid
2251
+ * which is represented as a branch of indices
2252
+ */
2253
+ maxmizedViewLocation = getGridLocation(maximizedView.element);
2254
+ }
2262
2255
  if (this.hasMaximizedView()) {
2263
2256
  /**
2264
- * do not persist maximized view state
2265
- * firstly exit any maximized views to ensure the correct dimensions are persisted
2257
+ * the saved layout cannot be in its maxmized state otherwise all of the underlying
2258
+ * view dimensions will be wrong
2259
+ *
2260
+ * To counteract this we temporaily remove the maximized view to compute the serialized output
2261
+ * of the grid before adding back the maxmized view as to not alter the layout from the users
2262
+ * perspective when `.toJSON()` is called
2266
2263
  */
2267
2264
  this.exitMaximizedView();
2268
2265
  }
2269
2266
  const root = serializeBranchNode(this.getView(), this.orientation);
2270
- return {
2267
+ const resullt = {
2271
2268
  root,
2272
2269
  width: this.width,
2273
2270
  height: this.height,
2274
2271
  orientation: this.orientation,
2275
2272
  };
2273
+ if (maxmizedViewLocation) {
2274
+ resullt.maximizedNode = {
2275
+ location: maxmizedViewLocation,
2276
+ };
2277
+ }
2278
+ if (maximizedView) {
2279
+ // replace any maximzied view that was removed for serialization purposes
2280
+ this.maximizeView(maximizedView);
2281
+ }
2282
+ return resullt;
2276
2283
  }
2277
2284
  dispose() {
2278
2285
  this.disposable.dispose();
@@ -2291,6 +2298,19 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2291
2298
  const orientation = json.orientation;
2292
2299
  const height = orientation === exports.Orientation.VERTICAL ? json.height : json.width;
2293
2300
  this._deserialize(json.root, orientation, deserializer, height);
2301
+ /**
2302
+ * The deserialied layout must be positioned through this.layout(...)
2303
+ * before any maximizedNode can be positioned
2304
+ */
2305
+ this.layout(json.width, json.height);
2306
+ if (json.maximizedNode) {
2307
+ const location = json.maximizedNode.location;
2308
+ const [_, node] = this.getNode(location);
2309
+ if (!(node instanceof LeafNode)) {
2310
+ return;
2311
+ }
2312
+ this.maximizeView(node.view);
2313
+ }
2294
2314
  }
2295
2315
  _deserialize(root, orientation, deserializer, orthogonalSize) {
2296
2316
  this.root = this._deserializeNode(root, orientation, deserializer, orthogonalSize);
@@ -2424,7 +2444,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2424
2444
  this._onDidMaximizedNodeChange = new Emitter();
2425
2445
  this.onDidMaximizedNodeChange = this._onDidMaximizedNodeChange.event;
2426
2446
  this.element = document.createElement('div');
2427
- this.element.className = 'grid-view';
2447
+ this.element.className = 'dv-grid-view';
2428
2448
  this._locked = locked !== null && locked !== void 0 ? locked : false;
2429
2449
  this._margin = margin !== null && margin !== void 0 ? margin : 0;
2430
2450
  this.root = new BranchNode(orientation, proportionalLayout, styles, 0, 0, this.locked, this.margin);
@@ -2715,6 +2735,8 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2715
2735
  this.onDidRemove = this._onDidRemove.event;
2716
2736
  this._onDidAdd = new Emitter();
2717
2737
  this.onDidAdd = this._onDidAdd.event;
2738
+ this._onDidMaximizedChange = new Emitter();
2739
+ this.onDidMaximizedChange = this._onDidMaximizedChange.event;
2718
2740
  this._onDidActiveChange = new Emitter();
2719
2741
  this.onDidActiveChange = this._onDidActiveChange.event;
2720
2742
  this._bufferOnDidLayoutChange = new AsapEvent();
@@ -2730,7 +2752,12 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2730
2752
  this.gridview.locked = !!options.locked;
2731
2753
  this.element.appendChild(this.gridview.element);
2732
2754
  this.layout(0, 0, true); // set some elements height/widths
2733
- this.addDisposables(this.gridview.onDidViewVisibilityChange(() => this._onDidViewVisibilityChangeMicroTaskQueue.fire()), this.onDidViewVisibilityChangeMicroTaskQueue(() => {
2755
+ this.addDisposables(this.gridview.onDidMaximizedNodeChange((event) => {
2756
+ this._onDidMaximizedChange.fire({
2757
+ panel: event.view,
2758
+ isMaximized: event.isMaximized,
2759
+ });
2760
+ }), this.gridview.onDidViewVisibilityChange(() => this._onDidViewVisibilityChangeMicroTaskQueue.fire()), this.onDidViewVisibilityChangeMicroTaskQueue(() => {
2734
2761
  this.layout(this.width, this.height, true);
2735
2762
  }), exports.DockviewDisposable.from(() => {
2736
2763
  var _a;
@@ -2780,9 +2807,6 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2780
2807
  hasMaximizedGroup() {
2781
2808
  return this.gridview.hasMaximizedView();
2782
2809
  }
2783
- get onDidMaximizedGroupChange() {
2784
- return this.gridview.onDidMaximizedNodeChange;
2785
- }
2786
2810
  doAddGroup(group, location = [0], size) {
2787
2811
  this.gridview.addView(group, size !== null && size !== void 0 ? size : exports.Sizing.Distribute, location);
2788
2812
  this._onDidAdd.fire(group);
@@ -3646,7 +3670,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3646
3670
  * dnd logic. You can see the code at
3647
3671
  * https://github.com/react-dnd/react-dnd/blob/main/packages/backend-html5/src/HTML5BackendImpl.ts#L542
3648
3672
  */
3649
- event.dataTransfer.setData('text/plain', '__dockview_internal_drag_event__');
3673
+ event.dataTransfer.setData('text/plain', '');
3650
3674
  }
3651
3675
  }
3652
3676
  }), addDisposableListener(this.el, 'dragend', () => {
@@ -3820,12 +3844,12 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3820
3844
  this.markAsUsed(e);
3821
3845
  if (!this.targetElement) {
3822
3846
  this.targetElement = document.createElement('div');
3823
- this.targetElement.className = 'drop-target-dropzone';
3847
+ this.targetElement.className = 'dv-drop-target-dropzone';
3824
3848
  this.overlayElement = document.createElement('div');
3825
- this.overlayElement.className = 'drop-target-selection';
3849
+ this.overlayElement.className = 'dv-drop-target-selection';
3826
3850
  this._state = 'center';
3827
3851
  this.targetElement.appendChild(this.overlayElement);
3828
- this.element.classList.add('drop-target');
3852
+ this.element.classList.add('dv-drop-target');
3829
3853
  this.element.append(this.targetElement);
3830
3854
  }
3831
3855
  this.toggleClasses(quadrant, width, height);
@@ -3963,7 +3987,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3963
3987
  this.element.removeChild(this.targetElement);
3964
3988
  this.targetElement = undefined;
3965
3989
  this.overlayElement = undefined;
3966
- this.element.classList.remove('drop-target');
3990
+ this.element.classList.remove('dv-drop-target');
3967
3991
  }
3968
3992
  }
3969
3993
  }
@@ -4300,7 +4324,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4300
4324
  this._headerVisible = isHeaderVisible;
4301
4325
  this._onDidChangeExpansionState.fire(this.isExpanded()); // initialize value
4302
4326
  this._orientation = orientation;
4303
- this.element.classList.add('pane');
4327
+ this.element.classList.add('dv-pane');
4304
4328
  this.addDisposables(this.api.onWillVisibilityChange((event) => {
4305
4329
  const { isVisible } = event;
4306
4330
  const { accessor } = this._params;
@@ -4397,14 +4421,14 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4397
4421
  renderOnce() {
4398
4422
  this.header = document.createElement('div');
4399
4423
  this.header.tabIndex = 0;
4400
- this.header.className = 'pane-header';
4424
+ this.header.className = 'dv-pane-header';
4401
4425
  this.header.style.height = `${this.headerSize}px`;
4402
4426
  this.header.style.lineHeight = `${this.headerSize}px`;
4403
4427
  this.header.style.minHeight = `${this.headerSize}px`;
4404
4428
  this.header.style.maxHeight = `${this.headerSize}px`;
4405
4429
  this.element.appendChild(this.header);
4406
4430
  this.body = document.createElement('div');
4407
- this.body.className = 'pane-body';
4431
+ this.body.className = 'dv-pane-body';
4408
4432
  this.element.appendChild(this.body);
4409
4433
  }
4410
4434
  // TODO slightly hacky by-pass of the component to create a body and header component
@@ -4525,7 +4549,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4525
4549
  this._onDidBlur = new Emitter();
4526
4550
  this.onDidBlur = this._onDidBlur.event;
4527
4551
  this._element = document.createElement('div');
4528
- this._element.className = 'content-container';
4552
+ this._element.className = 'dv-content-container';
4529
4553
  this._element.tabIndex = -1;
4530
4554
  this.addDisposables(this._onDidFocus, this._onDidBlur);
4531
4555
  this.dropTarget = new Droptarget(this.element, {
@@ -4598,6 +4622,8 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4598
4622
  referenceContainer: this,
4599
4623
  });
4600
4624
  break;
4625
+ default:
4626
+ throw new Error(`dockview: invalid renderer type '${panel.api.renderer}'`);
4601
4627
  }
4602
4628
  if (doRender) {
4603
4629
  const focusTracker = trackFocus(container);
@@ -4664,10 +4690,10 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4664
4690
  this._onDragStart = new Emitter();
4665
4691
  this.onDragStart = this._onDragStart.event;
4666
4692
  this._element = document.createElement('div');
4667
- this._element.className = 'tab';
4693
+ this._element.className = 'dv-tab';
4668
4694
  this._element.tabIndex = 0;
4669
4695
  this._element.draggable = true;
4670
- toggleClass(this.element, 'inactive-tab', true);
4696
+ toggleClass(this.element, 'dv-inactive-tab', true);
4671
4697
  const dragHandler = new TabDragHandler(this._element, this.accessor, this.group, this.panel);
4672
4698
  this.dropTarget = new Droptarget(this._element, {
4673
4699
  acceptedTargetZones: ['center'],
@@ -4700,8 +4726,8 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4700
4726
  }), this.dropTarget);
4701
4727
  }
4702
4728
  setActive(isActive) {
4703
- toggleClass(this.element, 'active-tab', isActive);
4704
- toggleClass(this.element, 'inactive-tab', !isActive);
4729
+ toggleClass(this.element, 'dv-active-tab', isActive);
4730
+ toggleClass(this.element, 'dv-inactive-tab', !isActive);
4705
4731
  }
4706
4732
  setContent(part) {
4707
4733
  if (this.content) {
@@ -4789,8 +4815,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4789
4815
  this._onDragStart = new Emitter();
4790
4816
  this.onDragStart = this._onDragStart.event;
4791
4817
  this._element = document.createElement('div');
4792
- this._element.className = 'void-container';
4793
- this._element.tabIndex = 0;
4818
+ this._element.className = 'dv-void-container';
4794
4819
  this._element.draggable = true;
4795
4820
  this.addDisposables(this._onDrop, this._onDragStart, addDisposableListener(this._element, 'pointerdown', () => {
4796
4821
  this.accessor.doSetGroupActive(this.group);
@@ -4909,16 +4934,16 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4909
4934
  this._onWillShowOverlay = new Emitter();
4910
4935
  this.onWillShowOverlay = this._onWillShowOverlay.event;
4911
4936
  this._element = document.createElement('div');
4912
- this._element.className = 'tabs-and-actions-container';
4937
+ this._element.className = 'dv-tabs-and-actions-container';
4913
4938
  toggleClass(this._element, 'dv-full-width-single-tab', this.accessor.options.singleTabMode === 'fullwidth');
4914
4939
  this.rightActionsContainer = document.createElement('div');
4915
- this.rightActionsContainer.className = 'right-actions-container';
4940
+ this.rightActionsContainer.className = 'dv-right-actions-container';
4916
4941
  this.leftActionsContainer = document.createElement('div');
4917
- this.leftActionsContainer.className = 'left-actions-container';
4942
+ this.leftActionsContainer.className = 'dv-left-actions-container';
4918
4943
  this.preActionsContainer = document.createElement('div');
4919
- this.preActionsContainer.className = 'pre-actions-container';
4944
+ this.preActionsContainer.className = 'dv-pre-actions-container';
4920
4945
  this.tabContainer = document.createElement('div');
4921
- this.tabContainer.className = 'tabs-container';
4946
+ this.tabContainer.className = 'dv-tabs-container';
4922
4947
  this.voidContainer = new VoidContainer(this.accessor, this.group);
4923
4948
  this._element.appendChild(this.preActionsContainer);
4924
4949
  this._element.appendChild(this.tabContainer);
@@ -5007,14 +5032,10 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5007
5032
  });
5008
5033
  }
5009
5034
  openPanel(panel, index = this.tabs.length) {
5010
- var _a;
5011
5035
  if (this.tabs.find((tab) => tab.value.panel.id === panel.id)) {
5012
5036
  return;
5013
5037
  }
5014
5038
  const tab = new Tab(panel, this.accessor, this.group);
5015
- if (!((_a = panel.view) === null || _a === void 0 ? void 0 : _a.tab)) {
5016
- throw new Error('invalid header component');
5017
- }
5018
5039
  tab.setContent(panel.view.tab);
5019
5040
  const disposable = new CompositeDisposable(tab.onDragStart((event) => {
5020
5041
  this._onTabDragStart.fire({ nativeEvent: event, panel });
@@ -5108,6 +5129,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5108
5129
  disableDnd: undefined,
5109
5130
  gap: undefined,
5110
5131
  className: undefined,
5132
+ noPanelsOverlay: undefined,
5111
5133
  };
5112
5134
  return Object.keys(properties);
5113
5135
  })();
@@ -5204,7 +5226,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5204
5226
  }
5205
5227
  class DockviewGroupPanelModel extends CompositeDisposable {
5206
5228
  get element() {
5207
- throw new Error('not supported');
5229
+ throw new Error('dockview: not supported');
5208
5230
  }
5209
5231
  get activePanel() {
5210
5232
  return this._activePanel;
@@ -5214,7 +5236,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5214
5236
  }
5215
5237
  set locked(value) {
5216
5238
  this._locked = value;
5217
- toggleClass(this.container, 'locked-groupview', value === 'no-drop-target' || value);
5239
+ toggleClass(this.container, 'dv-locked-groupview', value === 'no-drop-target' || value);
5218
5240
  }
5219
5241
  get isActive() {
5220
5242
  return this._isGroupActive;
@@ -5285,6 +5307,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5285
5307
  this._locked = false;
5286
5308
  this._location = { type: 'grid' };
5287
5309
  this.mostRecentlyUsed = [];
5310
+ this._overwriteRenderContainer = null;
5288
5311
  this._onDidChange = new Emitter();
5289
5312
  this.onDidChange = this._onDidChange.event;
5290
5313
  this._width = 0;
@@ -5315,8 +5338,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5315
5338
  this.onDidActivePanelChange = this._onDidActivePanelChange.event;
5316
5339
  this._onUnhandledDragOverEvent = new Emitter();
5317
5340
  this.onUnhandledDragOverEvent = this._onUnhandledDragOverEvent.event;
5318
- this._overwriteRenderContainer = null;
5319
- toggleClass(this.container, 'groupview', true);
5341
+ toggleClass(this.container, 'dv-groupview', true);
5320
5342
  this._api = new DockviewApi(this.accessor);
5321
5343
  this.tabsContainer = new TabsContainer(this.accessor, this.groupPanel);
5322
5344
  this.contentContainer = new ContentContainer(this.accessor, this);
@@ -5548,7 +5570,10 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5548
5570
  this.doClose(panel);
5549
5571
  }
5550
5572
  doClose(panel) {
5551
- this.accessor.removePanel(panel);
5573
+ const isLast = this.panels.length === 1 && this.accessor.groups.length === 1;
5574
+ this.accessor.removePanel(panel, isLast && this.accessor.options.noPanelsOverlay === 'emptyGroup'
5575
+ ? { removeEmptyGroup: false }
5576
+ : undefined);
5552
5577
  }
5553
5578
  isPanelActive(panel) {
5554
5579
  return this._activePanel === panel;
@@ -5561,8 +5586,8 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5561
5586
  return;
5562
5587
  }
5563
5588
  this._isGroupActive = isGroupActive;
5564
- toggleClass(this.container, 'active-group', isGroupActive);
5565
- toggleClass(this.container, 'inactive-group', !isGroupActive);
5589
+ toggleClass(this.container, 'dv-active-group', isGroupActive);
5590
+ toggleClass(this.container, 'dv-inactive-group', !isGroupActive);
5566
5591
  this.tabsContainer.setActive(this.isActive);
5567
5592
  if (!this._activePanel && this.panels.length > 0) {
5568
5593
  this.doSetActivePanel(this.panels[0]);
@@ -5654,7 +5679,6 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5654
5679
  }
5655
5680
  updateContainer() {
5656
5681
  var _a, _b;
5657
- toggleClass(this.container, 'empty', this.isEmpty);
5658
5682
  this.panels.forEach((panel) => panel.runEvents());
5659
5683
  if (this.isEmpty && !this.watermark) {
5660
5684
  const watermark = this.accessor.createWatermarkComponent();
@@ -5668,14 +5692,12 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5668
5692
  this.accessor.doSetGroupActive(this.groupPanel);
5669
5693
  }
5670
5694
  });
5671
- this.tabsContainer.hide();
5672
5695
  this.contentContainer.element.appendChild(this.watermark.element);
5673
5696
  }
5674
5697
  if (!this.isEmpty && this.watermark) {
5675
5698
  this.watermark.element.remove();
5676
5699
  (_b = (_a = this.watermark).dispose) === null || _b === void 0 ? void 0 : _b.call(_a);
5677
5700
  this.watermark = undefined;
5678
- this.tabsContainer.show();
5679
5701
  }
5680
5702
  }
5681
5703
  canDisplayOverlay(event, position, target) {
@@ -5795,6 +5817,34 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5795
5817
  return this._snap;
5796
5818
  }
5797
5819
  get minimumWidth() {
5820
+ /**
5821
+ * defer to protected function to allow subclasses to override easily.
5822
+ * see https://github.com/microsoft/TypeScript/issues/338
5823
+ */
5824
+ return this.__minimumWidth();
5825
+ }
5826
+ get minimumHeight() {
5827
+ /**
5828
+ * defer to protected function to allow subclasses to override easily.
5829
+ * see https://github.com/microsoft/TypeScript/issues/338
5830
+ */
5831
+ return this.__minimumHeight();
5832
+ }
5833
+ get maximumHeight() {
5834
+ /**
5835
+ * defer to protected function to allow subclasses to override easily.
5836
+ * see https://github.com/microsoft/TypeScript/issues/338
5837
+ */
5838
+ return this.__maximumHeight();
5839
+ }
5840
+ get maximumWidth() {
5841
+ /**
5842
+ * defer to protected function to allow subclasses to override easily.
5843
+ * see https://github.com/microsoft/TypeScript/issues/338
5844
+ */
5845
+ return this.__maximumWidth();
5846
+ }
5847
+ __minimumWidth() {
5798
5848
  const width = typeof this._minimumWidth === 'function'
5799
5849
  ? this._minimumWidth()
5800
5850
  : this._minimumWidth;
@@ -5804,7 +5854,17 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5804
5854
  }
5805
5855
  return width;
5806
5856
  }
5807
- get minimumHeight() {
5857
+ __maximumWidth() {
5858
+ const width = typeof this._maximumWidth === 'function'
5859
+ ? this._maximumWidth()
5860
+ : this._maximumWidth;
5861
+ if (width !== this._evaluatedMaximumWidth) {
5862
+ this._evaluatedMaximumWidth = width;
5863
+ this.updateConstraints();
5864
+ }
5865
+ return width;
5866
+ }
5867
+ __minimumHeight() {
5808
5868
  const height = typeof this._minimumHeight === 'function'
5809
5869
  ? this._minimumHeight()
5810
5870
  : this._minimumHeight;
@@ -5814,7 +5874,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5814
5874
  }
5815
5875
  return height;
5816
5876
  }
5817
- get maximumHeight() {
5877
+ __maximumHeight() {
5818
5878
  const height = typeof this._maximumHeight === 'function'
5819
5879
  ? this._maximumHeight()
5820
5880
  : this._maximumHeight;
@@ -5824,16 +5884,6 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5824
5884
  }
5825
5885
  return height;
5826
5886
  }
5827
- get maximumWidth() {
5828
- const width = typeof this._maximumWidth === 'function'
5829
- ? this._maximumWidth()
5830
- : this._maximumWidth;
5831
- if (width !== this._evaluatedMaximumWidth) {
5832
- this._evaluatedMaximumWidth = width;
5833
- this.updateConstraints();
5834
- }
5835
- return width;
5836
- }
5837
5887
  get isActive() {
5838
5888
  return this.api.isActive;
5839
5889
  }
@@ -5984,6 +6034,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5984
6034
  position: options.group
5985
6035
  ? (_c = options.position) !== null && _c !== void 0 ? _c : 'center'
5986
6036
  : 'center',
6037
+ index: options.index,
5987
6038
  },
5988
6039
  });
5989
6040
  }
@@ -6035,30 +6086,34 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6035
6086
  get minimumWidth() {
6036
6087
  var _a;
6037
6088
  const activePanelMinimumWidth = (_a = this.activePanel) === null || _a === void 0 ? void 0 : _a.minimumWidth;
6038
- return typeof activePanelMinimumWidth === 'number'
6039
- ? activePanelMinimumWidth
6040
- : MINIMUM_DOCKVIEW_GROUP_PANEL_WIDTH;
6089
+ if (typeof activePanelMinimumWidth === 'number') {
6090
+ return activePanelMinimumWidth;
6091
+ }
6092
+ return super.__minimumWidth();
6041
6093
  }
6042
6094
  get minimumHeight() {
6043
6095
  var _a;
6044
6096
  const activePanelMinimumHeight = (_a = this.activePanel) === null || _a === void 0 ? void 0 : _a.minimumHeight;
6045
- return typeof activePanelMinimumHeight === 'number'
6046
- ? activePanelMinimumHeight
6047
- : MINIMUM_DOCKVIEW_GROUP_PANEL_HEIGHT;
6097
+ if (typeof activePanelMinimumHeight === 'number') {
6098
+ return activePanelMinimumHeight;
6099
+ }
6100
+ return super.__minimumHeight();
6048
6101
  }
6049
6102
  get maximumWidth() {
6050
6103
  var _a;
6051
6104
  const activePanelMaximumWidth = (_a = this.activePanel) === null || _a === void 0 ? void 0 : _a.maximumWidth;
6052
- return typeof activePanelMaximumWidth === 'number'
6053
- ? activePanelMaximumWidth
6054
- : Number.MAX_SAFE_INTEGER;
6105
+ if (typeof activePanelMaximumWidth === 'number') {
6106
+ return activePanelMaximumWidth;
6107
+ }
6108
+ return super.__maximumWidth();
6055
6109
  }
6056
6110
  get maximumHeight() {
6057
6111
  var _a;
6058
6112
  const activePanelMaximumHeight = (_a = this.activePanel) === null || _a === void 0 ? void 0 : _a.maximumHeight;
6059
- return typeof activePanelMaximumHeight === 'number'
6060
- ? activePanelMaximumHeight
6061
- : Number.MAX_SAFE_INTEGER;
6113
+ if (typeof activePanelMaximumHeight === 'number') {
6114
+ return activePanelMaximumHeight;
6115
+ }
6116
+ return super.__maximumHeight();
6062
6117
  }
6063
6118
  get panels() {
6064
6119
  return this._model.panels;
@@ -6172,12 +6227,14 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6172
6227
  return this.group.api.getWindow();
6173
6228
  }
6174
6229
  moveTo(options) {
6175
- var _a;
6230
+ var _a, _b;
6176
6231
  this.accessor.moveGroupOrPanel({
6177
6232
  from: { groupId: this._group.id, panelId: this.panel.id },
6178
6233
  to: {
6179
- group: options.group,
6180
- position: (_a = options.position) !== null && _a !== void 0 ? _a : 'center',
6234
+ group: (_a = options.group) !== null && _a !== void 0 ? _a : this._group,
6235
+ position: options.group
6236
+ ? (_b = options.position) !== null && _b !== void 0 ? _b : 'center'
6237
+ : 'center',
6181
6238
  index: options.index,
6182
6239
  },
6183
6240
  });
@@ -6396,7 +6453,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6396
6453
  svg.setAttributeNS(null, 'viewBox', params.viewbox);
6397
6454
  svg.setAttributeNS(null, 'aria-hidden', 'false');
6398
6455
  svg.setAttributeNS(null, 'focusable', 'false');
6399
- svg.classList.add('dockview-svg');
6456
+ svg.classList.add('dv-svg');
6400
6457
  const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
6401
6458
  path.setAttributeNS(null, 'd', params.path);
6402
6459
  svg.appendChild(path);
@@ -6567,39 +6624,10 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6567
6624
  constructor() {
6568
6625
  super();
6569
6626
  this._element = document.createElement('div');
6570
- this._element.className = 'watermark';
6571
- const title = document.createElement('div');
6572
- title.className = 'watermark-title';
6573
- const emptySpace = document.createElement('span');
6574
- emptySpace.style.flexGrow = '1';
6575
- const content = document.createElement('div');
6576
- content.className = 'watermark-content';
6577
- this._element.appendChild(title);
6578
- this._element.appendChild(content);
6579
- const actionsContainer = document.createElement('div');
6580
- actionsContainer.className = 'actions-container';
6581
- const closeAnchor = document.createElement('div');
6582
- closeAnchor.className = 'close-action';
6583
- closeAnchor.appendChild(createCloseButton());
6584
- actionsContainer.appendChild(closeAnchor);
6585
- title.appendChild(emptySpace);
6586
- title.appendChild(actionsContainer);
6587
- this.addDisposables(addDisposableListener(closeAnchor, 'click', (event) => {
6588
- var _a;
6589
- event.preventDefault();
6590
- if (this._group) {
6591
- (_a = this._api) === null || _a === void 0 ? void 0 : _a.removeGroup(this._group);
6592
- }
6593
- }));
6627
+ this._element.className = 'dv-watermark';
6594
6628
  }
6595
6629
  init(_params) {
6596
- this._api = _params.containerApi;
6597
- this._group = _params.group;
6598
- this.render();
6599
- }
6600
- render() {
6601
- const isOneGroup = !!(this._api && this._api.size <= 1);
6602
- toggleClass(this.element, 'has-actions', isOneGroup);
6630
+ // noop
6603
6631
  }
6604
6632
  }
6605
6633
 
@@ -6636,6 +6664,9 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6636
6664
  get element() {
6637
6665
  return this._element;
6638
6666
  }
6667
+ get isVisible() {
6668
+ return this._isVisible;
6669
+ }
6639
6670
  constructor(options) {
6640
6671
  super();
6641
6672
  this.options = options;
@@ -6646,6 +6677,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6646
6677
  this.onDidChangeEnd = this._onDidChangeEnd.event;
6647
6678
  this.addDisposables(this._onDidChange, this._onDidChangeEnd);
6648
6679
  this._element.className = 'dv-resize-container';
6680
+ this._isVisible = true;
6649
6681
  this.setupResize('top');
6650
6682
  this.setupResize('bottom');
6651
6683
  this.setupResize('left');
@@ -6660,6 +6692,13 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6660
6692
  this.setBounds(Object.assign(Object.assign(Object.assign(Object.assign({ height: this.options.height, width: this.options.width }, ('top' in this.options && { top: this.options.top })), ('bottom' in this.options && { bottom: this.options.bottom })), ('left' in this.options && { left: this.options.left })), ('right' in this.options && { right: this.options.right })));
6661
6693
  arialLevelTracker.push(this._element);
6662
6694
  }
6695
+ setVisible(isVisible) {
6696
+ if (isVisible === this.isVisible) {
6697
+ return;
6698
+ }
6699
+ this._isVisible = isVisible;
6700
+ toggleClass(this.element, 'dv-hidden', !this.isVisible);
6701
+ }
6663
6702
  bringToFront() {
6664
6703
  arialLevelTracker.push(this._element);
6665
6704
  }
@@ -7210,7 +7249,6 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7210
7249
  window: this._window.value,
7211
7250
  });
7212
7251
  this._window.disposable.dispose();
7213
- this._window.value.close();
7214
7252
  this._window = null;
7215
7253
  this._onDidClose.fire();
7216
7254
  }
@@ -7242,7 +7280,9 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7242
7280
  }
7243
7281
  const disposable = new CompositeDisposable();
7244
7282
  this._window = { value: externalWindow, disposable };
7245
- disposable.addDisposables(addDisposableWindowListener(window, 'beforeunload', () => {
7283
+ disposable.addDisposables(exports.DockviewDisposable.from(() => {
7284
+ externalWindow.close();
7285
+ }), addDisposableWindowListener(window, 'beforeunload', () => {
7246
7286
  /**
7247
7287
  * before the main window closes we should close this popup too
7248
7288
  * to be good citizens
@@ -7259,7 +7299,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7259
7299
  id: this.target,
7260
7300
  window: externalWindow,
7261
7301
  });
7262
- return new Promise((resolve) => {
7302
+ return new Promise((resolve, reject) => {
7263
7303
  externalWindow.addEventListener('unload', (e) => {
7264
7304
  // if page fails to load before unloading
7265
7305
  // this.close();
@@ -7268,21 +7308,27 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7268
7308
  /**
7269
7309
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/load_event
7270
7310
  */
7271
- const externalDocument = externalWindow.document;
7272
- externalDocument.title = document.title;
7273
- externalDocument.body.appendChild(container);
7274
- addStyles(externalDocument, window.document.styleSheets);
7275
- /**
7276
- * beforeunload must be registered after load for reasons I could not determine
7277
- * otherwise the beforeunload event will not fire when the window is closed
7278
- */
7279
- addDisposableWindowListener(externalWindow, 'beforeunload', () => {
7311
+ try {
7312
+ const externalDocument = externalWindow.document;
7313
+ externalDocument.title = document.title;
7314
+ externalDocument.body.appendChild(container);
7315
+ addStyles(externalDocument, window.document.styleSheets);
7280
7316
  /**
7281
- * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event
7317
+ * beforeunload must be registered after load for reasons I could not determine
7318
+ * otherwise the beforeunload event will not fire when the window is closed
7282
7319
  */
7283
- this.close();
7284
- });
7285
- resolve(container);
7320
+ addDisposableWindowListener(externalWindow, 'beforeunload', () => {
7321
+ /**
7322
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event
7323
+ */
7324
+ this.close();
7325
+ });
7326
+ resolve(container);
7327
+ }
7328
+ catch (err) {
7329
+ // only except this is the DOM isn't setup. e.g. in a in correctly configured test
7330
+ reject(err);
7331
+ }
7286
7332
  });
7287
7333
  });
7288
7334
  });
@@ -7389,6 +7435,8 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7389
7435
  this.onDidActivePanelChange = this._onDidActivePanelChange.event;
7390
7436
  this._onDidMovePanel = new Emitter();
7391
7437
  this.onDidMovePanel = this._onDidMovePanel.event;
7438
+ this._onDidMaximizedGroupChange = new Emitter();
7439
+ this.onDidMaximizedGroupChange = this._onDidMaximizedGroupChange.event;
7392
7440
  this._floatingGroups = [];
7393
7441
  this._popoutGroups = [];
7394
7442
  this._onDidRemoveGroup = new Emitter();
@@ -7415,6 +7463,11 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7415
7463
  if (!this._moving) {
7416
7464
  this._onDidActiveGroupChange.fire(event);
7417
7465
  }
7466
+ }), this.onDidMaximizedChange((event) => {
7467
+ this._onDidMaximizedGroupChange.fire({
7468
+ group: event.panel,
7469
+ isMaximized: event.isMaximized,
7470
+ });
7418
7471
  }), exports.DockviewEvent.any(this.onDidAdd, this.onDidRemove)(() => {
7419
7472
  this.updateWatermark();
7420
7473
  }), exports.DockviewEvent.any(this.onDidAddPanel, this.onDidRemovePanel, this.onDidAddGroup, this.onDidRemove, this.onDidMovePanel, this.onDidActivePanelChange)(() => {
@@ -7513,8 +7566,28 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7513
7566
  this._api = new DockviewApi(this);
7514
7567
  this.updateWatermark();
7515
7568
  }
7569
+ setVisible(panel, visible) {
7570
+ switch (panel.api.location.type) {
7571
+ case 'grid':
7572
+ super.setVisible(panel, visible);
7573
+ break;
7574
+ case 'floating': {
7575
+ const item = this.floatingGroups.find((floatingGroup) => floatingGroup.group === panel);
7576
+ if (item) {
7577
+ item.overlay.setVisible(visible);
7578
+ panel.api._onDidVisibilityChange.fire({
7579
+ isVisible: visible,
7580
+ });
7581
+ }
7582
+ break;
7583
+ }
7584
+ case 'popout':
7585
+ console.warn('dockview: You cannot hide a group that is in a popout window');
7586
+ break;
7587
+ }
7588
+ }
7516
7589
  addPopoutGroup(itemToPopout, options) {
7517
- var _a, _b, _c;
7590
+ var _a, _b, _c, _d, _e;
7518
7591
  if (itemToPopout instanceof DockviewPanel &&
7519
7592
  itemToPopout.group.size === 1) {
7520
7593
  return this.addPopoutGroup(itemToPopout.group, options);
@@ -7535,12 +7608,9 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7535
7608
  }
7536
7609
  const box = getBox();
7537
7610
  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();
7538
- if (itemToPopout.api.location.type === 'grid') {
7539
- itemToPopout.api.setVisible(false);
7540
- }
7541
7611
  const _window = new PopoutWindow(`${this.id}-${groupId}`, // unique id
7542
7612
  theme !== null && theme !== void 0 ? theme : '', {
7543
- url: (_c = options === null || options === void 0 ? void 0 : options.popoutUrl) !== null && _c !== void 0 ? _c : '/popout.html',
7613
+ url: (_e = (_c = options === null || options === void 0 ? void 0 : options.popoutUrl) !== null && _c !== void 0 ? _c : (_d = this.options) === null || _d === void 0 ? void 0 : _d.popoutUrl) !== null && _e !== void 0 ? _e : '/popout.html',
7544
7614
  left: window.screenX + box.left,
7545
7615
  top: window.screenY + box.top,
7546
7616
  width: box.width,
@@ -7554,13 +7624,12 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7554
7624
  return _window
7555
7625
  .open()
7556
7626
  .then((popoutContainer) => {
7557
- var _a;
7558
7627
  if (_window.isDisposed) {
7559
- return;
7628
+ return false;
7560
7629
  }
7561
7630
  if (popoutContainer === null) {
7562
7631
  popoutWindowDisposable.dispose();
7563
- return;
7632
+ return false;
7564
7633
  }
7565
7634
  const gready = document.createElement('div');
7566
7635
  gready.className = 'dv-overlay-render-container';
@@ -7569,30 +7638,45 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7569
7638
  ? itemToPopout.group
7570
7639
  : itemToPopout;
7571
7640
  const referenceLocation = itemToPopout.api.location.type;
7572
- const group = (_a = options === null || options === void 0 ? void 0 : options.overridePopoutGroup) !== null && _a !== void 0 ? _a : this.createGroup({ id: groupId });
7573
- group.model.renderContainer = overlayRenderContainer;
7574
- if (!(options === null || options === void 0 ? void 0 : options.overridePopoutGroup)) {
7575
- this._onDidAddGroup.fire(group);
7641
+ /**
7642
+ * The group that is being added doesn't already exist within the DOM, the most likely occurance
7643
+ * of this case is when being called from the `fromJSON(...)` method
7644
+ */
7645
+ const isGroupAddedToDom = referenceGroup.element.parentElement !== null;
7646
+ let group;
7647
+ if (!isGroupAddedToDom) {
7648
+ group = referenceGroup;
7576
7649
  }
7577
- if (itemToPopout instanceof DockviewPanel) {
7578
- this.movingLock(() => {
7579
- const panel = referenceGroup.model.removePanel(itemToPopout);
7580
- group.model.openPanel(panel);
7581
- });
7650
+ else if (options === null || options === void 0 ? void 0 : options.overridePopoutGroup) {
7651
+ group = options.overridePopoutGroup;
7582
7652
  }
7583
7653
  else {
7584
- this.movingLock(() => moveGroupWithoutDestroying({
7585
- from: referenceGroup,
7586
- to: group,
7587
- }));
7588
- switch (referenceLocation) {
7589
- case 'grid':
7590
- referenceGroup.api.setVisible(false);
7591
- break;
7592
- case 'floating':
7593
- case 'popout':
7594
- this.removeGroup(referenceGroup);
7595
- break;
7654
+ group = this.createGroup({ id: groupId });
7655
+ this._onDidAddGroup.fire(group);
7656
+ }
7657
+ group.model.renderContainer = overlayRenderContainer;
7658
+ group.layout(_window.window.innerWidth, _window.window.innerHeight);
7659
+ if (!(options === null || options === void 0 ? void 0 : options.overridePopoutGroup) && isGroupAddedToDom) {
7660
+ if (itemToPopout instanceof DockviewPanel) {
7661
+ this.movingLock(() => {
7662
+ const panel = referenceGroup.model.removePanel(itemToPopout);
7663
+ group.model.openPanel(panel);
7664
+ });
7665
+ }
7666
+ else {
7667
+ this.movingLock(() => moveGroupWithoutDestroying({
7668
+ from: referenceGroup,
7669
+ to: group,
7670
+ }));
7671
+ switch (referenceLocation) {
7672
+ case 'grid':
7673
+ referenceGroup.api.setVisible(false);
7674
+ break;
7675
+ case 'floating':
7676
+ case 'popout':
7677
+ this.removeGroup(referenceGroup);
7678
+ break;
7679
+ }
7596
7680
  }
7597
7681
  }
7598
7682
  popoutContainer.classList.add('dv-dockview');
@@ -7602,7 +7686,12 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7602
7686
  group.model.location = {
7603
7687
  type: 'popout',
7604
7688
  getWindow: () => _window.window,
7689
+ popoutUrl: options === null || options === void 0 ? void 0 : options.popoutUrl,
7605
7690
  };
7691
+ if (isGroupAddedToDom &&
7692
+ itemToPopout.api.location.type === 'grid') {
7693
+ itemToPopout.api.setVisible(false);
7694
+ }
7606
7695
  this.doSetGroupAndPanelActive(group);
7607
7696
  popoutWindowDisposable.addDisposables(group.api.onDidActiveChange((event) => {
7608
7697
  var _a;
@@ -7614,10 +7703,13 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7614
7703
  (_a = _window.window) === null || _a === void 0 ? void 0 : _a.focus();
7615
7704
  }));
7616
7705
  let returnedGroup;
7706
+ const isValidReferenceGroup = isGroupAddedToDom &&
7707
+ referenceGroup &&
7708
+ this.getPanel(referenceGroup.id);
7617
7709
  const value = {
7618
7710
  window: _window,
7619
7711
  popoutGroup: group,
7620
- referenceGroup: this.getPanel(referenceGroup.id)
7712
+ referenceGroup: isValidReferenceGroup
7621
7713
  ? referenceGroup.id
7622
7714
  : undefined,
7623
7715
  disposable: {
@@ -7634,9 +7726,10 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7634
7726
  * window dimensions
7635
7727
  */
7636
7728
  addDisposableWindowListener(_window.window, 'resize', () => {
7637
- group.layout(window.innerWidth, window.innerHeight);
7729
+ group.layout(_window.window.innerWidth, _window.window.innerHeight);
7638
7730
  }), overlayRenderContainer, exports.DockviewDisposable.from(() => {
7639
- if (this.getPanel(referenceGroup.id)) {
7731
+ if (isGroupAddedToDom &&
7732
+ this.getPanel(referenceGroup.id)) {
7640
7733
  this.movingLock(() => moveGroupWithoutDestroying({
7641
7734
  from: group,
7642
7735
  to: referenceGroup,
@@ -7651,21 +7744,27 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7651
7744
  }
7652
7745
  }
7653
7746
  else if (this.getPanel(group.id)) {
7654
- const removedGroup = this.doRemoveGroup(group, {
7747
+ this.doRemoveGroup(group, {
7655
7748
  skipDispose: true,
7656
7749
  skipActive: true,
7750
+ skipPopoutReturn: true,
7657
7751
  });
7752
+ const removedGroup = group;
7658
7753
  removedGroup.model.renderContainer =
7659
7754
  this.overlayRenderContainer;
7660
7755
  removedGroup.model.location = { type: 'grid' };
7661
7756
  returnedGroup = removedGroup;
7757
+ this.doAddGroup(removedGroup, [0]);
7758
+ this.doSetGroupAndPanelActive(removedGroup);
7662
7759
  }
7663
7760
  }));
7664
7761
  this._popoutGroups.push(value);
7665
7762
  this.updateWatermark();
7763
+ return true;
7666
7764
  })
7667
7765
  .catch((err) => {
7668
7766
  console.error('dockview: failed to create popout window', err);
7767
+ return false;
7669
7768
  });
7670
7769
  }
7671
7770
  addFloatingGroup(item, options) {
@@ -7769,7 +7868,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7769
7868
  : (_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'
7770
7869
  ? undefined
7771
7870
  : (_e = (_d = this.options.floatingGroupBounds) === null || _d === void 0 ? void 0 : _d.minimumHeightWithinViewport) !== null && _e !== void 0 ? _e : DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE }));
7772
- const el = group.element.querySelector('.void-container');
7871
+ const el = group.element.querySelector('.dv-void-container');
7773
7872
  if (!el) {
7774
7873
  throw new Error('failed to find drag handle');
7775
7874
  }
@@ -7961,6 +8060,9 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7961
8060
  data: group.popoutGroup.toJSON(),
7962
8061
  gridReferenceGroup: group.referenceGroup,
7963
8062
  position: group.window.dimensions(),
8063
+ url: group.popoutGroup.api.location.type === 'popout'
8064
+ ? group.popoutGroup.api.location.popoutUrl
8065
+ : undefined,
7964
8066
  };
7965
8067
  });
7966
8068
  const result = {
@@ -8047,16 +8149,16 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
8047
8149
  }
8048
8150
  const serializedPopoutGroups = (_b = data.popoutGroups) !== null && _b !== void 0 ? _b : [];
8049
8151
  for (const serializedPopoutGroup of serializedPopoutGroups) {
8050
- const { data, position, gridReferenceGroup } = serializedPopoutGroup;
8152
+ const { data, position, gridReferenceGroup, url } = serializedPopoutGroup;
8051
8153
  const group = createGroupFromSerializedState(data);
8052
8154
  this.addPopoutGroup((_c = (gridReferenceGroup
8053
8155
  ? this.getPanel(gridReferenceGroup)
8054
8156
  : undefined)) !== null && _c !== void 0 ? _c : group, {
8055
- skipRemoveGroup: true,
8056
8157
  position: position !== null && position !== void 0 ? position : undefined,
8057
8158
  overridePopoutGroup: gridReferenceGroup
8058
8159
  ? group
8059
8160
  : undefined,
8161
+ popoutUrl: url,
8060
8162
  });
8061
8163
  }
8062
8164
  for (const floatingGroup of this._floatingGroups) {
@@ -8070,6 +8172,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
8070
8172
  }
8071
8173
  }
8072
8174
  catch (err) {
8175
+ console.error('dockview: failed to deserialize layout. Reverting changes', err);
8073
8176
  /**
8074
8177
  * Takes all the successfully created groups and remove all of their panels.
8075
8178
  */
@@ -8137,11 +8240,13 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
8137
8240
  width: options.initialWidth,
8138
8241
  height: options.initialHeight,
8139
8242
  };
8243
+ let index;
8140
8244
  if (options.position) {
8141
8245
  if (isPanelOptionsWithPanel(options.position)) {
8142
8246
  const referencePanel = typeof options.position.referencePanel === 'string'
8143
8247
  ? this.getGroupPanel(options.position.referencePanel)
8144
8248
  : options.position.referencePanel;
8249
+ index = options.position.index;
8145
8250
  if (!referencePanel) {
8146
8251
  throw new Error(`referencePanel '${options.position.referencePanel}' does not exist`);
8147
8252
  }
@@ -8152,6 +8257,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
8152
8257
  typeof options.position.referenceGroup === 'string'
8153
8258
  ? (_a = this._groups.get(options.position.referenceGroup)) === null || _a === void 0 ? void 0 : _a.value
8154
8259
  : options.position.referenceGroup;
8260
+ index = options.position.index;
8155
8261
  if (!referenceGroup) {
8156
8262
  throw new Error(`referenceGroup '${options.position.referenceGroup}' does not exist`);
8157
8263
  }
@@ -8162,6 +8268,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
8162
8268
  group.model.openPanel(panel, {
8163
8269
  skipSetActive: options.inactive,
8164
8270
  skipSetGroupActive: options.inactive,
8271
+ index,
8165
8272
  });
8166
8273
  if (!options.inactive) {
8167
8274
  this.doSetGroupAndPanelActive(group);
@@ -8191,6 +8298,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
8191
8298
  group.model.openPanel(panel, {
8192
8299
  skipSetActive: options.inactive,
8193
8300
  skipSetGroupActive: options.inactive,
8301
+ index,
8194
8302
  });
8195
8303
  }
8196
8304
  else if (referenceGroup.api.location.type === 'floating' ||
@@ -8199,6 +8307,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
8199
8307
  referenceGroup.model.openPanel(panel, {
8200
8308
  skipSetActive: options.inactive,
8201
8309
  skipSetGroupActive: options.inactive,
8310
+ index,
8202
8311
  });
8203
8312
  referenceGroup.api.setSize({
8204
8313
  width: initial === null || initial === void 0 ? void 0 : initial.width,
@@ -8219,6 +8328,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
8219
8328
  group.model.openPanel(panel, {
8220
8329
  skipSetActive: options.inactive,
8221
8330
  skipSetGroupActive: options.inactive,
8331
+ index,
8222
8332
  });
8223
8333
  if (!options.inactive) {
8224
8334
  this.doSetGroupAndPanelActive(group);
@@ -8237,6 +8347,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
8237
8347
  group.model.openPanel(panel, {
8238
8348
  skipSetActive: options.inactive,
8239
8349
  skipSetGroupActive: options.inactive,
8350
+ index,
8240
8351
  });
8241
8352
  }
8242
8353
  else {
@@ -8247,6 +8358,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
8247
8358
  group.model.openPanel(panel, {
8248
8359
  skipSetActive: options.inactive,
8249
8360
  skipSetGroupActive: options.inactive,
8361
+ index,
8250
8362
  });
8251
8363
  if (!options.inactive) {
8252
8364
  this.doSetGroupAndPanelActive(group);
@@ -8256,7 +8368,6 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
8256
8368
  }
8257
8369
  removePanel(panel, options = {
8258
8370
  removeEmptyGroup: true,
8259
- skipDispose: false,
8260
8371
  }) {
8261
8372
  const group = panel.group;
8262
8373
  if (!group) {
@@ -8787,6 +8898,31 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
8787
8898
  }
8788
8899
  }
8789
8900
 
8901
+ function createComponent(id, componentName, components = {}, frameworkComponents = {}, createFrameworkComponent, fallback) {
8902
+ const Component = typeof componentName === 'string'
8903
+ ? components[componentName]
8904
+ : undefined;
8905
+ const FrameworkComponent = typeof componentName === 'string'
8906
+ ? frameworkComponents[componentName]
8907
+ : undefined;
8908
+ if (Component && FrameworkComponent) {
8909
+ throw new Error(`Cannot create '${id}'. component '${componentName}' registered as both a component and frameworkComponent`);
8910
+ }
8911
+ if (FrameworkComponent) {
8912
+ if (!createFrameworkComponent) {
8913
+ throw new Error(`Cannot create '${id}' for framework component '${componentName}'. you must register a frameworkPanelWrapper to use framework components`);
8914
+ }
8915
+ return createFrameworkComponent.createComponent(id, componentName, FrameworkComponent);
8916
+ }
8917
+ if (!Component) {
8918
+ if (fallback) {
8919
+ return fallback();
8920
+ }
8921
+ throw new Error(`Cannot create '${id}', no component '${componentName}' provided`);
8922
+ }
8923
+ return new Component(id, componentName);
8924
+ }
8925
+
8790
8926
  class GridviewComponent extends BaseGrid {
8791
8927
  get orientation() {
8792
8928
  return this.gridview.orientation;
@@ -9335,12 +9471,14 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
9335
9471
  this._expandedIcon = createExpandMoreButton();
9336
9472
  this._collapsedIcon = createChevronRightButton();
9337
9473
  this.disposable = new MutableDisposable();
9338
- this.apiRef = { api: null };
9474
+ this.apiRef = {
9475
+ api: null,
9476
+ };
9339
9477
  this._element = document.createElement('div');
9340
- this.element.className = 'default-header';
9478
+ this.element.className = 'dv-default-header';
9341
9479
  this._content = document.createElement('span');
9342
9480
  this._expander = document.createElement('div');
9343
- this._expander.className = 'dockview-pane-header-icon';
9481
+ this._expander.className = 'dv-pane-header-icon';
9344
9482
  this.element.appendChild(this._expander);
9345
9483
  this.element.appendChild(this._content);
9346
9484
  this.addDisposables(addDisposableListener(this._element, 'click', () => {
@@ -10197,22 +10335,6 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
10197
10335
  disposable.dispose();
10198
10336
  };
10199
10337
  }, [props.onDidDrop]);
10200
- React.useEffect(() => {
10201
- if (!dockviewRef.current) {
10202
- return () => {
10203
- // noop
10204
- };
10205
- }
10206
- const disposable = dockviewRef.current.onUnhandledDragOverEvent((event) => {
10207
- var _a;
10208
- if ((_a = props.showDndOverlay) === null || _a === void 0 ? void 0 : _a.call(props, event)) {
10209
- event.accept();
10210
- }
10211
- });
10212
- return () => {
10213
- disposable.dispose();
10214
- };
10215
- }, [props.showDndOverlay]);
10216
10338
  React.useEffect(() => {
10217
10339
  if (!dockviewRef.current) {
10218
10340
  return () => {
@@ -10630,7 +10752,6 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
10630
10752
  exports.GridviewComponent = GridviewComponent;
10631
10753
  exports.GridviewPanel = GridviewPanel;
10632
10754
  exports.GridviewReact = GridviewReact;
10633
- exports.LocalSelectionTransfer = LocalSelectionTransfer;
10634
10755
  exports.PROPERTY_KEYS = PROPERTY_KEYS;
10635
10756
  exports.PaneFramework = PaneFramework;
10636
10757
  exports.PaneTransfer = PaneTransfer;
@@ -10649,7 +10770,6 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
10649
10770
  exports.SplitviewReact = SplitviewReact;
10650
10771
  exports.Tab = Tab;
10651
10772
  exports.WillShowOverlayLocationEvent = WillShowOverlayLocationEvent;
10652
- exports.createComponent = createComponent;
10653
10773
  exports.createDockview = createDockview;
10654
10774
  exports.createGridview = createGridview;
10655
10775
  exports.createPaneview = createPaneview;