dockview 1.4.0 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/api/component.api.d.ts +0 -5
  3. package/dist/cjs/api/component.api.js +0 -15
  4. package/dist/cjs/api/component.api.js.map +1 -1
  5. package/dist/cjs/api/panelApi.d.ts +1 -2
  6. package/dist/cjs/api/panelApi.js +3 -3
  7. package/dist/cjs/api/panelApi.js.map +1 -1
  8. package/dist/cjs/dockview/components/tab/defaultTab.d.ts +0 -17
  9. package/dist/cjs/dockview/components/tab/defaultTab.js +9 -64
  10. package/dist/cjs/dockview/components/tab/defaultTab.js.map +1 -1
  11. package/dist/cjs/dockview/defaultGroupPanelView.d.ts +1 -2
  12. package/dist/cjs/dockview/defaultGroupPanelView.js +2 -4
  13. package/dist/cjs/dockview/defaultGroupPanelView.js.map +1 -1
  14. package/dist/cjs/dockview/dockviewComponent.js +2 -2
  15. package/dist/cjs/dockview/dockviewComponent.js.map +1 -1
  16. package/dist/cjs/dockview/dockviewGroupPanel.js +1 -1
  17. package/dist/cjs/dockview/dockviewGroupPanel.js.map +1 -1
  18. package/dist/cjs/gridview/basePanelView.js +1 -1
  19. package/dist/cjs/gridview/basePanelView.js.map +1 -1
  20. package/dist/cjs/gridview/gridview.js +1 -1
  21. package/dist/cjs/gridview/gridview.js.map +1 -1
  22. package/dist/cjs/gridview/gridviewComponent.d.ts +0 -2
  23. package/dist/cjs/gridview/gridviewComponent.js +2 -6
  24. package/dist/cjs/gridview/gridviewComponent.js.map +1 -1
  25. package/dist/cjs/gridview/gridviewPanel.d.ts +2 -3
  26. package/dist/cjs/gridview/gridviewPanel.js +4 -4
  27. package/dist/cjs/gridview/gridviewPanel.js.map +1 -1
  28. package/dist/cjs/groupview/types.d.ts +1 -3
  29. package/dist/cjs/paneview/paneviewComponent.js +2 -2
  30. package/dist/cjs/paneview/paneviewComponent.js.map +1 -1
  31. package/dist/cjs/react/dockview/reactContentPart.d.ts +2 -4
  32. package/dist/cjs/react/dockview/reactContentPart.js +0 -3
  33. package/dist/cjs/react/dockview/reactContentPart.js.map +1 -1
  34. package/dist/cjs/react/dockview/v2/reactContentRenderer.d.ts +0 -1
  35. package/dist/cjs/react/dockview/v2/reactContentRenderer.js +0 -3
  36. package/dist/cjs/react/dockview/v2/reactContentRenderer.js.map +1 -1
  37. package/dist/cjs/react/gridview/view.js +2 -2
  38. package/dist/cjs/react/gridview/view.js.map +1 -1
  39. package/dist/cjs/react/index.d.ts +0 -1
  40. package/dist/cjs/react/index.js +0 -1
  41. package/dist/cjs/react/index.js.map +1 -1
  42. package/dist/cjs/react/splitview/view.js +2 -2
  43. package/dist/cjs/react/splitview/view.js.map +1 -1
  44. package/dist/cjs/splitview/core/options.d.ts +2 -2
  45. package/dist/cjs/splitview/splitviewComponent.d.ts +0 -1
  46. package/dist/cjs/splitview/splitviewComponent.js +4 -5
  47. package/dist/cjs/splitview/splitviewComponent.js.map +1 -1
  48. package/dist/cjs/splitview/splitviewPanel.js +4 -6
  49. package/dist/cjs/splitview/splitviewPanel.js.map +1 -1
  50. package/dist/dockview.amd.js +34 -155
  51. package/dist/dockview.amd.min.js +2 -2
  52. package/dist/dockview.amd.min.noStyle.js +2 -2
  53. package/dist/dockview.amd.noStyle.js +34 -155
  54. package/dist/dockview.cjs.js +34 -155
  55. package/dist/dockview.esm.js +34 -154
  56. package/dist/dockview.esm.min.js +2 -2
  57. package/dist/dockview.js +34 -155
  58. package/dist/dockview.min.js +2 -2
  59. package/dist/dockview.min.noStyle.js +2 -2
  60. package/dist/dockview.noStyle.js +34 -155
  61. package/dist/esm/api/component.api.d.ts +0 -5
  62. package/dist/esm/api/component.api.js +0 -15
  63. package/dist/esm/api/panelApi.d.ts +1 -2
  64. package/dist/esm/api/panelApi.js +3 -3
  65. package/dist/esm/dockview/components/tab/defaultTab.d.ts +0 -17
  66. package/dist/esm/dockview/components/tab/defaultTab.js +8 -49
  67. package/dist/esm/dockview/defaultGroupPanelView.d.ts +1 -2
  68. package/dist/esm/dockview/defaultGroupPanelView.js +3 -5
  69. package/dist/esm/dockview/dockviewComponent.js +1 -1
  70. package/dist/esm/dockview/dockviewGroupPanel.js +1 -1
  71. package/dist/esm/gridview/basePanelView.js +1 -1
  72. package/dist/esm/gridview/gridviewComponent.d.ts +0 -2
  73. package/dist/esm/gridview/gridviewComponent.js +2 -6
  74. package/dist/esm/gridview/gridviewPanel.d.ts +2 -3
  75. package/dist/esm/gridview/gridviewPanel.js +4 -4
  76. package/dist/esm/groupview/types.d.ts +1 -3
  77. package/dist/esm/react/dockview/reactContentPart.d.ts +2 -4
  78. package/dist/esm/react/dockview/reactContentPart.js +0 -3
  79. package/dist/esm/react/dockview/v2/reactContentRenderer.d.ts +0 -1
  80. package/dist/esm/react/dockview/v2/reactContentRenderer.js +0 -3
  81. package/dist/esm/react/gridview/view.js +2 -2
  82. package/dist/esm/react/index.d.ts +0 -1
  83. package/dist/esm/react/index.js +0 -1
  84. package/dist/esm/react/splitview/view.js +2 -2
  85. package/dist/esm/splitview/core/options.d.ts +2 -2
  86. package/dist/esm/splitview/splitviewComponent.d.ts +0 -1
  87. package/dist/esm/splitview/splitviewComponent.js +2 -3
  88. package/dist/esm/splitview/splitviewPanel.js +4 -6
  89. package/package.json +2 -2
  90. package/dist/cjs/react/dockview/components.d.ts +0 -11
  91. package/dist/cjs/react/dockview/components.js +0 -81
  92. package/dist/cjs/react/dockview/components.js.map +0 -1
  93. package/dist/esm/react/dockview/components.d.ts +0 -11
  94. package/dist/esm/react/dockview/components.js +0 -54
package/dist/dockview.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * dockview
3
- * @version 1.4.0
3
+ * @version 1.4.1
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -2307,18 +2307,12 @@
2307
2307
  removePanel(panel, sizing) {
2308
2308
  this.component.removePanel(panel, sizing);
2309
2309
  }
2310
- setVisible(panel, isVisible) {
2311
- this.component.setVisible(panel, isVisible);
2312
- }
2313
2310
  focus() {
2314
2311
  this.component.focus();
2315
2312
  }
2316
2313
  getPanel(id) {
2317
2314
  return this.component.getPanel(id);
2318
2315
  }
2319
- setActive(panel) {
2320
- this.component.setActive(panel);
2321
- }
2322
2316
  layout(width, height) {
2323
2317
  return this.component.layout(width, height);
2324
2318
  }
@@ -2466,15 +2460,6 @@
2466
2460
  getPanel(id) {
2467
2461
  return this.component.getPanel(id);
2468
2462
  }
2469
- toggleVisibility(panel) {
2470
- this.component.toggleVisibility(panel);
2471
- }
2472
- setVisible(panel, visible) {
2473
- this.component.setVisible(panel, visible);
2474
- }
2475
- setActive(panel) {
2476
- this.component.setActive(panel);
2477
- }
2478
2463
  fromJSON(data) {
2479
2464
  return this.component.fromJSON(data);
2480
2465
  }
@@ -2711,7 +2696,7 @@
2711
2696
  MouseEventKind["CLICK"] = "CLICK";
2712
2697
  MouseEventKind["CONTEXT_MENU"] = "CONTEXT_MENU";
2713
2698
  })(exports.MouseEventKind || (exports.MouseEventKind = {}));
2714
- class Tab$1 extends CompositeDisposable {
2699
+ class Tab extends CompositeDisposable {
2715
2700
  constructor(panelId, accessor, group) {
2716
2701
  super();
2717
2702
  this.panelId = panelId;
@@ -2940,7 +2925,7 @@
2940
2925
  if (this.tabs.find((tab) => tab.value.panelId === panel.id)) {
2941
2926
  return;
2942
2927
  }
2943
- const tabToAdd = new Tab$1(panel.id, this.accessor, this.group);
2928
+ const tabToAdd = new Tab(panel.id, this.accessor, this.group);
2944
2929
  if (!((_a = panel.view) === null || _a === void 0 ? void 0 : _a.tab)) {
2945
2930
  throw new Error('invalid header component');
2946
2931
  }
@@ -3611,10 +3596,10 @@
3611
3596
  this._isVisible = true;
3612
3597
  this._width = 0;
3613
3598
  this._height = 0;
3614
- this._onDidPanelDimensionChange = new Emitter({
3599
+ this._onDidDimensionChange = new Emitter({
3615
3600
  replay: true,
3616
3601
  });
3617
- this.onDidDimensionsChange = this._onDidPanelDimensionChange.event;
3602
+ this.onDidDimensionsChange = this._onDidDimensionChange.event;
3618
3603
  //
3619
3604
  this._onDidChangeFocus = new Emitter({
3620
3605
  replay: true,
@@ -3639,7 +3624,7 @@
3639
3624
  //
3640
3625
  this._onActiveChange = new Emitter();
3641
3626
  this.onActiveChange = this._onActiveChange.event;
3642
- this.addDisposables(this._onDidPanelDimensionChange, this._onDidChangeFocus, this._onDidVisibilityChange, this._onDidActiveChange, this._onFocusEvent, this._onActiveChange, this._onVisibilityChange, this.onDidFocusChange((event) => {
3627
+ this.addDisposables(this._onDidDimensionChange, this._onDidChangeFocus, this._onDidVisibilityChange, this._onDidActiveChange, this._onFocusEvent, this._onActiveChange, this._onVisibilityChange, this.onDidFocusChange((event) => {
3643
3628
  this._isFocused = event.isFocused;
3644
3629
  }), this.onDidActiveChange((event) => {
3645
3630
  this._isActive = event.isActive;
@@ -3863,7 +3848,7 @@
3863
3848
  layout(width, height) {
3864
3849
  var _a;
3865
3850
  // the obtain the correct dimensions of the content panel we must deduct the tab height
3866
- this.api._onDidPanelDimensionChange.fire({
3851
+ this.api._onDidDimensionChange.fire({
3867
3852
  width,
3868
3853
  height: height - (this.group.model.header.height || 0),
3869
3854
  });
@@ -4013,53 +3998,6 @@
4013
3998
  return new Component(id, componentName);
4014
3999
  }
4015
4000
 
4016
- class WrappedTab {
4017
- constructor(renderer) {
4018
- this.renderer = renderer;
4019
- this._element = document.createElement('element');
4020
- this.show();
4021
- }
4022
- get innerRenderer() {
4023
- return this.renderer;
4024
- }
4025
- get element() {
4026
- return this._element;
4027
- }
4028
- get id() {
4029
- return this.renderer.id;
4030
- }
4031
- show() {
4032
- if (!this.renderer.element.parentElement) {
4033
- this._element.appendChild(this.renderer.element);
4034
- }
4035
- }
4036
- hide() {
4037
- if (this.renderer.element.parentElement) {
4038
- this.renderer.element.remove();
4039
- }
4040
- }
4041
- layout(width, height) {
4042
- this.renderer.layout(width, height);
4043
- }
4044
- update(event) {
4045
- this.renderer.update(event);
4046
- }
4047
- toJSON() {
4048
- return this.renderer.toJSON();
4049
- }
4050
- focus() {
4051
- this.renderer.focus();
4052
- }
4053
- init(parameters) {
4054
- this.renderer.init(parameters);
4055
- }
4056
- updateParentGroup(group, isPanelVisible) {
4057
- this.renderer.updateParentGroup(group, isPanelVisible);
4058
- }
4059
- dispose() {
4060
- this.renderer.dispose();
4061
- }
4062
- }
4063
4001
  class DefaultTab extends CompositeDisposable {
4064
4002
  constructor() {
4065
4003
  super();
@@ -4122,15 +4060,21 @@
4122
4060
  }
4123
4061
  }
4124
4062
  updateParentGroup(group, isPanelVisible) {
4063
+ const changed = this._isPanelVisible !== isPanelVisible ||
4064
+ this._isGroupActive !== group.isActive;
4125
4065
  this._isPanelVisible = isPanelVisible;
4126
4066
  this._isGroupActive = group.isActive;
4127
- this.render();
4067
+ if (changed) {
4068
+ this.render();
4069
+ }
4128
4070
  }
4129
4071
  layout(_width, _height) {
4130
4072
  // noop
4131
4073
  }
4132
4074
  render() {
4133
- this._content.textContent = this.params.title;
4075
+ if (this._content.textContent !== this.params.title) {
4076
+ this._content.textContent = this.params.title;
4077
+ }
4134
4078
  }
4135
4079
  }
4136
4080
 
@@ -4174,7 +4118,7 @@
4174
4118
  layout(width, height) {
4175
4119
  this._width = width;
4176
4120
  this._height = height;
4177
- this.api._onDidPanelDimensionChange.fire({ width, height });
4121
+ this.api._onDidDimensionChange.fire({ width, height });
4178
4122
  if (this.part) {
4179
4123
  if (this._params) {
4180
4124
  this.part.update(this._params.params);
@@ -4223,11 +4167,11 @@
4223
4167
  this.onDidChange = this._onDidChange.event;
4224
4168
  this.addDisposables(this._onDidChange, this.api.onVisibilityChange((event) => {
4225
4169
  const { isVisible } = event;
4226
- const { containerApi } = this._params;
4227
- containerApi.setVisible(this, isVisible);
4170
+ const { accessor } = this._params;
4171
+ accessor.setVisible(this, isVisible);
4228
4172
  }), this.api.onActiveChange(() => {
4229
- const { containerApi } = this._params;
4230
- containerApi.setActive(this);
4173
+ const { accessor } = this._params;
4174
+ accessor.setActive(this);
4231
4175
  }), this.api.onDidConstraintsChangeInternal((event) => {
4232
4176
  if (typeof event.minimumWidth === 'number' ||
4233
4177
  typeof event.minimumWidth === 'function') {
@@ -4406,7 +4350,7 @@
4406
4350
  constructor(renderers) {
4407
4351
  var _a;
4408
4352
  this._content = renderers.content;
4409
- this._tab = new WrappedTab((_a = renderers.tab) !== null && _a !== void 0 ? _a : new DefaultTab());
4353
+ this._tab = (_a = renderers.tab) !== null && _a !== void 0 ? _a : new DefaultTab();
4410
4354
  this._actions =
4411
4355
  renderers.actions ||
4412
4356
  (this.content.actions
@@ -4446,9 +4390,7 @@
4446
4390
  toJSON() {
4447
4391
  return {
4448
4392
  content: this.content.toJSON(),
4449
- tab: this.tab.innerRenderer instanceof DefaultTab
4450
- ? undefined
4451
- : this.tab.toJSON(),
4393
+ tab: this.tab instanceof DefaultTab ? undefined : this.tab.toJSON(),
4452
4394
  };
4453
4395
  }
4454
4396
  dispose() {
@@ -4836,7 +4778,7 @@
4836
4778
  }
4837
4779
  }
4838
4780
  const view = new GroupPanel(this, id, options);
4839
- view.init({ params: {}, containerApi: null }); // required to initialized .part and allow for correct disposal of group
4781
+ view.init({ params: {}, accessor: null }); // required to initialized .part and allow for correct disposal of group
4840
4782
  if (!this._groups.has(view.id)) {
4841
4783
  const disposable = new CompositeDisposable(view.model.onMove((event) => {
4842
4784
  const { groupId, itemId, target, index } = event;
@@ -4975,9 +4917,6 @@
4975
4917
  value.value.setActive(panel === value.value);
4976
4918
  });
4977
4919
  }
4978
- toggleVisibility(panel) {
4979
- this.setVisible(panel, !this.isVisible(panel));
4980
- }
4981
4920
  focus() {
4982
4921
  var _a;
4983
4922
  (_a = this.activeGroup) === null || _a === void 0 ? void 0 : _a.focus();
@@ -5008,7 +4947,7 @@
5008
4947
  maximumHeight: data.maximumHeight,
5009
4948
  priority: data.priority,
5010
4949
  snap: !!data.snap,
5011
- containerApi: new GridviewApi(this),
4950
+ accessor: this,
5012
4951
  isVisible: node.visible,
5013
4952
  }));
5014
4953
  this.registerPanel(view);
@@ -5074,7 +5013,7 @@
5074
5013
  maximumHeight: options.maximumHeight,
5075
5014
  priority: options.priority,
5076
5015
  snap: !!options.snap,
5077
- containerApi: new GridviewApi(this),
5016
+ accessor: this,
5078
5017
  isVisible: true,
5079
5018
  });
5080
5019
  this.registerPanel(view);
@@ -5270,7 +5209,7 @@
5270
5209
  maximumSize: options.maximumSize,
5271
5210
  snap: options.snap,
5272
5211
  priority: options.priority,
5273
- containerApi: new SplitviewApi(this),
5212
+ accessor: this,
5274
5213
  });
5275
5214
  const size = typeof options.size === 'number' ? options.size : exports.Sizing.Distribute;
5276
5215
  const index = typeof options.index === 'number' ? options.index : undefined;
@@ -5346,7 +5285,7 @@
5346
5285
  maximumSize: data.maximumSize,
5347
5286
  snap: view.snap,
5348
5287
  priority: view.priority,
5349
- containerApi: new SplitviewApi(this),
5288
+ accessor: this,
5350
5289
  });
5351
5290
  });
5352
5291
  panel.orientation = orientation;
@@ -5988,13 +5927,11 @@
5988
5927
  this.onDidChange = this._onDidChange.event;
5989
5928
  this.addDisposables(this._onDidChange, this.api.onVisibilityChange((event) => {
5990
5929
  const { isVisible } = event;
5991
- const { containerApi } = this
5992
- ._params;
5993
- containerApi.setVisible(this, isVisible);
5930
+ const { accessor } = this._params;
5931
+ accessor.setVisible(this, isVisible);
5994
5932
  }), this.api.onActiveChange(() => {
5995
- const { containerApi } = this
5996
- ._params;
5997
- containerApi.setActive(this);
5933
+ const { accessor } = this._params;
5934
+ accessor.setActive(this);
5998
5935
  }), this.api.onDidConstraintsChangeInternal((event) => {
5999
5936
  if (typeof event.minimumSize === 'number' ||
6000
5937
  typeof event.minimumSize === 'function') {
@@ -6246,9 +6183,6 @@
6246
6183
  layout(_width, _height) {
6247
6184
  // noop
6248
6185
  }
6249
- close() {
6250
- return Promise.resolve(true);
6251
- }
6252
6186
  dispose() {
6253
6187
  var _a, _b;
6254
6188
  this._onDidFocus.dispose();
@@ -6518,58 +6452,6 @@
6518
6452
  });
6519
6453
  DockviewReact.displayName = 'DockviewComponent';
6520
6454
 
6521
- const Tab = (props) => {
6522
- return React__namespace.createElement(React__namespace.Fragment, null, props.children);
6523
- };
6524
- const Content = (props) => {
6525
- return React__namespace.createElement(React__namespace.Fragment, null, props.children);
6526
- };
6527
- const Actions = (props) => {
6528
- return React__namespace.createElement(React__namespace.Fragment, null, props.children);
6529
- };
6530
- function isValidComponent(element) {
6531
- return [Content, Actions, Tab].find((comp) => element.type === comp);
6532
- }
6533
- const Panel = (props) => {
6534
- const context = React__namespace.useContext(ReactPartContext);
6535
- const sections = React__namespace.useMemo(() => {
6536
- var _a;
6537
- const childs = ((_a = React__namespace.Children.map(props.children, (_) => _)) === null || _a === void 0 ? void 0 : _a.filter(isReactElement)) || [];
6538
- const isInvalid = !!childs.find((_) => !isValidComponent(_));
6539
- if (isInvalid) {
6540
- throw new Error('Children of DockviewComponents.Panel must be one of the following: DockviewComponents.Content, DockviewComponents.Actions, DockviewComponents.Tab');
6541
- }
6542
- const body = childs.find((_) => _.type === Content);
6543
- const actions = childs.find((_) => _.type === Actions);
6544
- const tab = childs.find((_) => _.type === Tab);
6545
- return { body, actions, tab };
6546
- }, [props.children]);
6547
- React__namespace.useEffect(() => {
6548
- /**
6549
- * hide or show the default tab behavior based on whether we want to override
6550
- * with our own React tab.
6551
- */
6552
- if (sections.tab) {
6553
- context.tabPortalElement.hide();
6554
- }
6555
- else {
6556
- context.tabPortalElement.show();
6557
- }
6558
- }, [sections.tab]);
6559
- return (React__namespace.createElement(React__namespace.Fragment, null,
6560
- sections.actions &&
6561
- ReactDOM__namespace.createPortal(sections.actions, context.actionsPortalElement),
6562
- sections.tab &&
6563
- ReactDOM__namespace.createPortal(sections.tab, context.tabPortalElement.element),
6564
- sections.body || props.children));
6565
- };
6566
- const DockviewComponents = {
6567
- Tab,
6568
- Content,
6569
- Actions,
6570
- Panel,
6571
- };
6572
-
6573
6455
  class ReactPanelView extends SplitviewPanel {
6574
6456
  constructor(id, component, reactComponent, reactPortalStore) {
6575
6457
  super(id, component);
@@ -6581,8 +6463,7 @@
6581
6463
  return new ReactPart(this.element, this.reactPortalStore, this.reactComponent, {
6582
6464
  params: ((_a = this._params) === null || _a === void 0 ? void 0 : _a.params) || {},
6583
6465
  api: this.api,
6584
- containerApi: this._params
6585
- .containerApi,
6466
+ containerApi: new SplitviewApi(this._params.accessor),
6586
6467
  });
6587
6468
  }
6588
6469
  }
@@ -6658,8 +6539,7 @@
6658
6539
  return new ReactPart(this.element, this.reactPortalStore, this.reactComponent, {
6659
6540
  params: ((_a = this._params) === null || _a === void 0 ? void 0 : _a.params) || {},
6660
6541
  api: this.api,
6661
- containerApi: this._params
6662
- .containerApi,
6542
+ containerApi: new GridviewApi(this._params.accessor),
6663
6543
  });
6664
6544
  }
6665
6545
  }
@@ -6853,7 +6733,6 @@
6853
6733
  exports.ContentContainer = ContentContainer;
6854
6734
  exports.DockviewApi = DockviewApi;
6855
6735
  exports.DockviewComponent = DockviewComponent;
6856
- exports.DockviewComponents = DockviewComponents;
6857
6736
  exports.DockviewReact = DockviewReact;
6858
6737
  exports.Gridview = Gridview;
6859
6738
  exports.GridviewApi = GridviewApi;
@@ -6879,7 +6758,7 @@
6879
6758
  exports.SplitviewComponent = SplitviewComponent;
6880
6759
  exports.SplitviewPanel = SplitviewPanel;
6881
6760
  exports.SplitviewReact = SplitviewReact;
6882
- exports.Tab = Tab$1;
6761
+ exports.Tab = Tab;
6883
6762
  exports.getDirectionOrientation = getDirectionOrientation;
6884
6763
  exports.getGridLocation = getGridLocation;
6885
6764
  exports.getLocationOrientation = getLocationOrientation;