dockview-react 2.1.4 → 3.0.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.
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * dockview-react
3
- * @version 2.1.4
3
+ * @version 3.0.1
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -130,6 +130,17 @@ class DockviewEvent {
130
130
  this._defaultPrevented = true;
131
131
  }
132
132
  }
133
+ class AcceptableEvent {
134
+ constructor() {
135
+ this._isAccepted = false;
136
+ }
137
+ get isAccepted() {
138
+ return this._isAccepted;
139
+ }
140
+ accept() {
141
+ this._isAccepted = true;
142
+ }
143
+ }
133
144
  class LeakageMonitor {
134
145
  constructor() {
135
146
  this.events = new Map();
@@ -1521,6 +1532,23 @@ class Splitview {
1521
1532
  }
1522
1533
  }
1523
1534
 
1535
+ const PROPERTY_KEYS_SPLITVIEW = (() => {
1536
+ /**
1537
+ * by readong the keys from an empty value object TypeScript will error
1538
+ * when we add or remove new properties to `DockviewOptions`
1539
+ */
1540
+ const properties = {
1541
+ orientation: undefined,
1542
+ descriptor: undefined,
1543
+ proportionalLayout: undefined,
1544
+ styles: undefined,
1545
+ margin: undefined,
1546
+ disableAutoResizing: undefined,
1547
+ className: undefined,
1548
+ };
1549
+ return Object.keys(properties);
1550
+ })();
1551
+
1524
1552
  class Paneview extends CompositeDisposable {
1525
1553
  get onDidAddView() {
1526
1554
  return this.splitview.onDidAddView;
@@ -2650,6 +2678,21 @@ class Gridview {
2650
2678
  }
2651
2679
  }
2652
2680
 
2681
+ const PROPERTY_KEYS_GRIDVIEW = (() => {
2682
+ /**
2683
+ * by readong the keys from an empty value object TypeScript will error
2684
+ * when we add or remove new properties to `DockviewOptions`
2685
+ */
2686
+ const properties = {
2687
+ disableAutoResizing: undefined,
2688
+ proportionalLayout: undefined,
2689
+ orientation: undefined,
2690
+ hideBorders: undefined,
2691
+ className: undefined,
2692
+ };
2693
+ return Object.keys(properties);
2694
+ })();
2695
+
2653
2696
  class Resizable extends CompositeDisposable {
2654
2697
  get element() {
2655
2698
  return this._element;
@@ -2759,7 +2802,7 @@ class BaseGrid extends Resizable {
2759
2802
  }
2760
2803
  constructor(parentElement, options) {
2761
2804
  var _a;
2762
- super(document.createElement('div'), options.disableAutoResizing);
2805
+ super(parentElement, options.disableAutoResizing);
2763
2806
  this._id = nextLayoutId$1.next();
2764
2807
  this._groups = new Map();
2765
2808
  this._onDidRemove = new Emitter();
@@ -2778,7 +2821,6 @@ class BaseGrid extends Resizable {
2778
2821
  this.element.style.width = '100%';
2779
2822
  this._classNames = new Classnames(this.element);
2780
2823
  this._classNames.setClassNames((_a = options.className) !== null && _a !== void 0 ? _a : '');
2781
- parentElement.appendChild(this.element);
2782
2824
  this.gridview = new Gridview(!!options.proportionalLayout, options.styles, options.orientation, options.locked, options.margin);
2783
2825
  this.gridview.locked = !!options.locked;
2784
2826
  this.element.appendChild(this.gridview.element);
@@ -3127,15 +3169,10 @@ class PaneviewApi {
3127
3169
  * Invoked when a Drag'n'Drop event occurs that the component was unable to handle. Exposed for custom Drag'n'Drop functionality.
3128
3170
  */
3129
3171
  get onDidDrop() {
3130
- const emitter = new Emitter();
3131
- const disposable = this.component.onDidDrop((e) => {
3132
- emitter.fire(Object.assign(Object.assign({}, e), { api: this }));
3133
- });
3134
- emitter.dispose = () => {
3135
- disposable.dispose();
3136
- emitter.dispose();
3137
- };
3138
- return emitter.event;
3172
+ return this.component.onDidDrop;
3173
+ }
3174
+ get onUnhandledDragOverEvent() {
3175
+ return this.component.onUnhandledDragOverEvent;
3139
3176
  }
3140
3177
  constructor(component) {
3141
3178
  this.component = component;
@@ -4062,6 +4099,28 @@ function calculateQuadrantAsPixels(overlayType, x, y, width, height, threshold)
4062
4099
  return 'center';
4063
4100
  }
4064
4101
 
4102
+ const PROPERTY_KEYS_PANEVIEW = (() => {
4103
+ /**
4104
+ * by readong the keys from an empty value object TypeScript will error
4105
+ * when we add or remove new properties to `DockviewOptions`
4106
+ */
4107
+ const properties = {
4108
+ disableAutoResizing: undefined,
4109
+ disableDnd: undefined,
4110
+ className: undefined,
4111
+ };
4112
+ return Object.keys(properties);
4113
+ })();
4114
+ class PaneviewUnhandledDragOverEvent extends AcceptableEvent {
4115
+ constructor(nativeEvent, position, getData, panel) {
4116
+ super();
4117
+ this.nativeEvent = nativeEvent;
4118
+ this.position = position;
4119
+ this.getData = getData;
4120
+ this.panel = panel;
4121
+ }
4122
+ }
4123
+
4065
4124
  class WillFocusEvent extends DockviewEvent {
4066
4125
  constructor() {
4067
4126
  super();
@@ -4485,6 +4544,9 @@ class DraggablePaneviewPanel extends PaneviewPanel {
4485
4544
  this.accessor = accessor;
4486
4545
  this._onDidDrop = new Emitter();
4487
4546
  this.onDidDrop = this._onDidDrop.event;
4547
+ this._onUnhandledDragOverEvent = new Emitter();
4548
+ this.onUnhandledDragOverEvent = this._onUnhandledDragOverEvent.event;
4549
+ this.addDisposables(this._onDidDrop, this._onUnhandledDragOverEvent);
4488
4550
  if (!disableDnd) {
4489
4551
  this.initDragFeatures();
4490
4552
  }
@@ -4511,7 +4573,7 @@ class DraggablePaneviewPanel extends PaneviewPanel {
4511
4573
  overlayModel: {
4512
4574
  activationSize: { type: 'percentage', value: 50 },
4513
4575
  },
4514
- canDisplayOverlay: (event) => {
4576
+ canDisplayOverlay: (event, position) => {
4515
4577
  const data = getPaneData();
4516
4578
  if (data) {
4517
4579
  if (data.paneId !== this.id &&
@@ -4519,14 +4581,9 @@ class DraggablePaneviewPanel extends PaneviewPanel {
4519
4581
  return true;
4520
4582
  }
4521
4583
  }
4522
- if (this.accessor.options.showDndOverlay) {
4523
- return this.accessor.options.showDndOverlay({
4524
- nativeEvent: event,
4525
- getData: getPaneData,
4526
- panel: this,
4527
- });
4528
- }
4529
- return false;
4584
+ const firedEvent = new PaneviewUnhandledDragOverEvent(event, position, getPaneData, this);
4585
+ this._onUnhandledDragOverEvent.fire(firedEvent);
4586
+ return firedEvent.isAccepted;
4530
4587
  },
4531
4588
  });
4532
4589
  this.addDisposables(this._onDidDrop, this.handler, this.target, this.target.onDrop((event) => {
@@ -4981,15 +5038,7 @@ class TabsContainer extends CompositeDisposable {
4981
5038
  this._element.appendChild(this.leftActionsContainer);
4982
5039
  this._element.appendChild(this.voidContainer.element);
4983
5040
  this._element.appendChild(this.rightActionsContainer);
4984
- this.addDisposables(this.accessor.onDidAddPanel((e) => {
4985
- if (e.api.group === this.group) {
4986
- toggleClass(this._element, 'dv-single-tab', this.size === 1);
4987
- }
4988
- }), this.accessor.onDidRemovePanel((e) => {
4989
- if (e.api.group === this.group) {
4990
- toggleClass(this._element, 'dv-single-tab', this.size === 1);
4991
- }
4992
- }), this._onWillShowOverlay, this._onDrop, this._onTabDragStart, this._onGroupDragStart, this.voidContainer, this.voidContainer.onDragStart((event) => {
5041
+ this.addDisposables(this._onWillShowOverlay, this._onDrop, this._onTabDragStart, this._onGroupDragStart, this.voidContainer, this.voidContainer.onDragStart((event) => {
4993
5042
  this._onGroupDragStart.fire({
4994
5043
  nativeEvent: event,
4995
5044
  group: this.group,
@@ -5034,20 +5083,6 @@ class TabsContainer extends CompositeDisposable {
5034
5083
  setActive(_isGroupActive) {
5035
5084
  // noop
5036
5085
  }
5037
- addTab(tab, index = this.tabs.length) {
5038
- if (index < 0 || index > this.tabs.length) {
5039
- throw new Error('invalid location');
5040
- }
5041
- this.tabContainer.insertBefore(tab.value.element, this.tabContainer.children[index]);
5042
- this.tabs = [
5043
- ...this.tabs.slice(0, index),
5044
- tab,
5045
- ...this.tabs.slice(index),
5046
- ];
5047
- if (this.selectedIndex < 0) {
5048
- this.selectedIndex = index;
5049
- }
5050
- }
5051
5086
  delete(id) {
5052
5087
  const index = this.tabs.findIndex((tab) => tab.value.panel.id === id);
5053
5088
  const tabToRemove = this.tabs.splice(index, 1)[0];
@@ -5055,6 +5090,7 @@ class TabsContainer extends CompositeDisposable {
5055
5090
  disposable.dispose();
5056
5091
  value.dispose();
5057
5092
  value.element.remove();
5093
+ this.updateClassnames();
5058
5094
  }
5059
5095
  setActivePanel(panel) {
5060
5096
  this.tabs.forEach((tab) => {
@@ -5123,25 +5159,37 @@ class TabsContainer extends CompositeDisposable {
5123
5159
  }
5124
5160
  this.tabs = [];
5125
5161
  }
5162
+ addTab(tab, index = this.tabs.length) {
5163
+ if (index < 0 || index > this.tabs.length) {
5164
+ throw new Error('invalid location');
5165
+ }
5166
+ this.tabContainer.insertBefore(tab.value.element, this.tabContainer.children[index]);
5167
+ this.tabs = [
5168
+ ...this.tabs.slice(0, index),
5169
+ tab,
5170
+ ...this.tabs.slice(index),
5171
+ ];
5172
+ if (this.selectedIndex < 0) {
5173
+ this.selectedIndex = index;
5174
+ }
5175
+ this.updateClassnames();
5176
+ }
5177
+ updateClassnames() {
5178
+ toggleClass(this._element, 'dv-single-tab', this.size === 1);
5179
+ }
5126
5180
  }
5127
5181
 
5128
- class DockviewUnhandledDragOverEvent {
5129
- get isAccepted() {
5130
- return this._isAccepted;
5131
- }
5182
+ class DockviewUnhandledDragOverEvent extends AcceptableEvent {
5132
5183
  constructor(nativeEvent, target, position, getData, group) {
5184
+ super();
5133
5185
  this.nativeEvent = nativeEvent;
5134
5186
  this.target = target;
5135
5187
  this.position = position;
5136
5188
  this.getData = getData;
5137
5189
  this.group = group;
5138
- this._isAccepted = false;
5139
- }
5140
- accept() {
5141
- this._isAccepted = true;
5142
5190
  }
5143
5191
  }
5144
- const PROPERTY_KEYS = (() => {
5192
+ const PROPERTY_KEYS_DOCKVIEW = (() => {
5145
5193
  /**
5146
5194
  * by readong the keys from an empty value object TypeScript will error
5147
5195
  * when we add or remove new properties to `DockviewOptions`
@@ -8987,31 +9035,6 @@ class DockviewComponent extends BaseGrid {
8987
9035
  }
8988
9036
  }
8989
9037
 
8990
- function createComponent(id, componentName, components = {}, frameworkComponents = {}, createFrameworkComponent, fallback) {
8991
- const Component = typeof componentName === 'string'
8992
- ? components[componentName]
8993
- : undefined;
8994
- const FrameworkComponent = typeof componentName === 'string'
8995
- ? frameworkComponents[componentName]
8996
- : undefined;
8997
- if (Component && FrameworkComponent) {
8998
- throw new Error(`Cannot create '${id}'. component '${componentName}' registered as both a component and frameworkComponent`);
8999
- }
9000
- if (FrameworkComponent) {
9001
- if (!createFrameworkComponent) {
9002
- throw new Error(`Cannot create '${id}' for framework component '${componentName}'. you must register a frameworkPanelWrapper to use framework components`);
9003
- }
9004
- return createFrameworkComponent.createComponent(id, componentName, FrameworkComponent);
9005
- }
9006
- if (!Component) {
9007
- if (fallback) {
9008
- return fallback();
9009
- }
9010
- throw new Error(`Cannot create '${id}', no component '${componentName}' provided`);
9011
- }
9012
- return new Component(id, componentName);
9013
- }
9014
-
9015
9038
  class GridviewComponent extends BaseGrid {
9016
9039
  get orientation() {
9017
9040
  return this.gridview.orientation;
@@ -9029,10 +9052,13 @@ class GridviewComponent extends BaseGrid {
9029
9052
  this._deserializer = value;
9030
9053
  }
9031
9054
  constructor(parentElement, options) {
9055
+ var _a;
9032
9056
  super(parentElement, {
9033
- proportionalLayout: options.proportionalLayout,
9057
+ proportionalLayout: (_a = options.proportionalLayout) !== null && _a !== void 0 ? _a : true,
9034
9058
  orientation: options.orientation,
9035
- styles: options.styles,
9059
+ styles: options.hideBorders
9060
+ ? { separatorBorder: 'transparent' }
9061
+ : undefined,
9036
9062
  disableAutoResizing: options.disableAutoResizing,
9037
9063
  className: options.className,
9038
9064
  });
@@ -9052,12 +9078,6 @@ class GridviewComponent extends BaseGrid {
9052
9078
  }), this.onDidActiveChange((event) => {
9053
9079
  this._onDidActiveGroupChange.fire(event);
9054
9080
  }));
9055
- if (!this.options.components) {
9056
- this.options.components = {};
9057
- }
9058
- if (!this.options.frameworkComponents) {
9059
- this.options.frameworkComponents = {};
9060
- }
9061
9081
  }
9062
9082
  updateOptions(options) {
9063
9083
  super.updateOptions(options);
@@ -9107,14 +9127,11 @@ class GridviewComponent extends BaseGrid {
9107
9127
  const height = this.height;
9108
9128
  this.gridview.deserialize(grid, {
9109
9129
  fromJSON: (node) => {
9110
- var _a, _b;
9111
9130
  const { data } = node;
9112
- const view = createComponent(data.id, data.component, (_a = this.options.components) !== null && _a !== void 0 ? _a : {}, (_b = this.options.frameworkComponents) !== null && _b !== void 0 ? _b : {}, this.options.frameworkComponentFactory
9113
- ? {
9114
- createComponent: this.options.frameworkComponentFactory
9115
- .createComponent,
9116
- }
9117
- : undefined);
9131
+ const view = this.options.createComponent({
9132
+ id: data.id,
9133
+ name: data.component,
9134
+ });
9118
9135
  queue.push(() => view.init({
9119
9136
  params: data.params,
9120
9137
  minimumWidth: data.minimumWidth,
@@ -9192,7 +9209,7 @@ class GridviewComponent extends BaseGrid {
9192
9209
  this.doAddGroup(removedPanel, relativeLocation, options.size);
9193
9210
  }
9194
9211
  addPanel(options) {
9195
- var _a, _b, _c, _d, _e, _f;
9212
+ var _a, _b, _c, _d;
9196
9213
  let relativeLocation = (_a = options.location) !== null && _a !== void 0 ? _a : [0];
9197
9214
  if ((_b = options.position) === null || _b === void 0 ? void 0 : _b.referencePanel) {
9198
9215
  const referenceGroup = (_c = this._groups.get(options.position.referencePanel)) === null || _c === void 0 ? void 0 : _c.value;
@@ -9208,14 +9225,12 @@ class GridviewComponent extends BaseGrid {
9208
9225
  relativeLocation = getRelativeLocation(this.gridview.orientation, location, target);
9209
9226
  }
9210
9227
  }
9211
- const view = createComponent(options.id, options.component, (_d = this.options.components) !== null && _d !== void 0 ? _d : {}, (_e = this.options.frameworkComponents) !== null && _e !== void 0 ? _e : {}, this.options.frameworkComponentFactory
9212
- ? {
9213
- createComponent: this.options.frameworkComponentFactory
9214
- .createComponent,
9215
- }
9216
- : undefined);
9228
+ const view = this.options.createComponent({
9229
+ id: options.id,
9230
+ name: options.component,
9231
+ });
9217
9232
  view.init({
9218
- params: (_f = options.params) !== null && _f !== void 0 ? _f : {},
9233
+ params: (_d = options.params) !== null && _d !== void 0 ? _d : {},
9219
9234
  minimumWidth: options.minimumWidth,
9220
9235
  maximumWidth: options.maximumWidth,
9221
9236
  minimumHeight: options.minimumHeight,
@@ -9343,12 +9358,6 @@ class SplitviewComponent extends Resizable {
9343
9358
  this._classNames = new Classnames(this.element);
9344
9359
  this._classNames.setClassNames((_a = options.className) !== null && _a !== void 0 ? _a : '');
9345
9360
  this._options = options;
9346
- if (!options.components) {
9347
- options.components = {};
9348
- }
9349
- if (!options.frameworkComponents) {
9350
- options.frameworkComponents = {};
9351
- }
9352
9361
  this.splitview = new Splitview(this.element, options);
9353
9362
  this.addDisposables(this._onDidAddView, this._onDidLayoutfromJSON, this._onDidRemoveView, this._onDidLayoutChange);
9354
9363
  }
@@ -9411,18 +9420,17 @@ class SplitviewComponent extends Resizable {
9411
9420
  return this.panels.find((view) => view.id === id);
9412
9421
  }
9413
9422
  addPanel(options) {
9414
- var _a, _b, _c;
9423
+ var _a;
9415
9424
  if (this._panels.has(options.id)) {
9416
9425
  throw new Error(`panel ${options.id} already exists`);
9417
9426
  }
9418
- const view = createComponent(options.id, options.component, (_a = this.options.components) !== null && _a !== void 0 ? _a : {}, (_b = this.options.frameworkComponents) !== null && _b !== void 0 ? _b : {}, this.options.frameworkWrapper
9419
- ? {
9420
- createComponent: this.options.frameworkWrapper.createComponent,
9421
- }
9422
- : undefined);
9427
+ const view = this.options.createComponent({
9428
+ id: options.id,
9429
+ name: options.component,
9430
+ });
9423
9431
  view.orientation = this.splitview.orientation;
9424
9432
  view.init({
9425
- params: (_c = options.params) !== null && _c !== void 0 ? _c : {},
9433
+ params: (_a = options.params) !== null && _a !== void 0 ? _a : {},
9426
9434
  minimumSize: options.minimumSize,
9427
9435
  maximumSize: options.maximumSize,
9428
9436
  snap: options.snap,
@@ -9484,17 +9492,14 @@ class SplitviewComponent extends Resizable {
9484
9492
  descriptor: {
9485
9493
  size,
9486
9494
  views: views.map((view) => {
9487
- var _a, _b;
9488
9495
  const data = view.data;
9489
9496
  if (this._panels.has(data.id)) {
9490
9497
  throw new Error(`panel ${data.id} already exists`);
9491
9498
  }
9492
- const panel = createComponent(data.id, data.component, (_a = this.options.components) !== null && _a !== void 0 ? _a : {}, (_b = this.options.frameworkComponents) !== null && _b !== void 0 ? _b : {}, this.options.frameworkWrapper
9493
- ? {
9494
- createComponent: this.options.frameworkWrapper
9495
- .createComponent,
9496
- }
9497
- : undefined);
9499
+ const panel = this.options.createComponent({
9500
+ id: data.id,
9501
+ name: data.component,
9502
+ });
9498
9503
  queue.push(() => {
9499
9504
  var _a;
9500
9505
  panel.init({
@@ -9677,16 +9682,12 @@ class PaneviewComponent extends Resizable {
9677
9682
  this.onDidAddView = this._onDidAddView.event;
9678
9683
  this._onDidRemoveView = new Emitter();
9679
9684
  this.onDidRemoveView = this._onDidRemoveView.event;
9680
- this.addDisposables(this._onDidLayoutChange, this._onDidLayoutfromJSON, this._onDidDrop, this._onDidAddView, this._onDidRemoveView);
9685
+ this._onUnhandledDragOverEvent = new Emitter();
9686
+ this.onUnhandledDragOverEvent = this._onUnhandledDragOverEvent.event;
9687
+ this.addDisposables(this._onDidLayoutChange, this._onDidLayoutfromJSON, this._onDidDrop, this._onDidAddView, this._onDidRemoveView, this._onUnhandledDragOverEvent);
9681
9688
  this._classNames = new Classnames(this.element);
9682
9689
  this._classNames.setClassNames((_a = options.className) !== null && _a !== void 0 ? _a : '');
9683
9690
  this._options = options;
9684
- if (!options.components) {
9685
- options.components = {};
9686
- }
9687
- if (!options.frameworkComponents) {
9688
- options.frameworkComponents = {};
9689
- }
9690
9691
  this.paneview = new Paneview(this.element, {
9691
9692
  // only allow paneview in the vertical orientation for now
9692
9693
  orientation: Orientation.VERTICAL,
@@ -9711,22 +9712,19 @@ class PaneviewComponent extends Resizable {
9711
9712
  this._options = Object.assign(Object.assign({}, this.options), options);
9712
9713
  }
9713
9714
  addPanel(options) {
9714
- var _a, _b, _c, _d;
9715
- const body = createComponent(options.id, options.component, (_a = this.options.components) !== null && _a !== void 0 ? _a : {}, (_b = this.options.frameworkComponents) !== null && _b !== void 0 ? _b : {}, this.options.frameworkWrapper
9716
- ? {
9717
- createComponent: this.options.frameworkWrapper.body.createComponent,
9718
- }
9719
- : undefined);
9715
+ var _a;
9716
+ const body = this.options.createComponent({
9717
+ id: options.id,
9718
+ name: options.component,
9719
+ });
9720
9720
  let header;
9721
- if (options.headerComponent) {
9722
- header = createComponent(options.id, options.headerComponent, (_c = this.options.headerComponents) !== null && _c !== void 0 ? _c : {}, this.options.headerframeworkComponents, this.options.frameworkWrapper
9723
- ? {
9724
- createComponent: this.options.frameworkWrapper.header
9725
- .createComponent,
9726
- }
9727
- : undefined);
9721
+ if (options.headerComponent && this.options.createHeaderComponent) {
9722
+ header = this.options.createHeaderComponent({
9723
+ id: options.id,
9724
+ name: options.headerComponent,
9725
+ });
9728
9726
  }
9729
- else {
9727
+ if (!header) {
9730
9728
  header = new DefaultHeader();
9731
9729
  }
9732
9730
  const view = new PaneFramework({
@@ -9744,7 +9742,7 @@ class PaneviewComponent extends Resizable {
9744
9742
  const size = typeof options.size === 'number' ? options.size : Sizing.Distribute;
9745
9743
  const index = typeof options.index === 'number' ? options.index : undefined;
9746
9744
  view.init({
9747
- params: (_d = options.params) !== null && _d !== void 0 ? _d : {},
9745
+ params: (_a = options.params) !== null && _a !== void 0 ? _a : {},
9748
9746
  minimumBodySize: options.minimumBodySize,
9749
9747
  maximumBodySize: options.maximumBodySize,
9750
9748
  isExpanded: options.isExpanded,
@@ -9809,24 +9807,20 @@ class PaneviewComponent extends Resizable {
9809
9807
  descriptor: {
9810
9808
  size,
9811
9809
  views: views.map((view) => {
9812
- var _a, _b, _c, _d;
9813
9810
  const data = view.data;
9814
- const body = createComponent(data.id, data.component, (_a = this.options.components) !== null && _a !== void 0 ? _a : {}, (_b = this.options.frameworkComponents) !== null && _b !== void 0 ? _b : {}, this.options.frameworkWrapper
9815
- ? {
9816
- createComponent: this.options.frameworkWrapper.body
9817
- .createComponent,
9818
- }
9819
- : undefined);
9811
+ const body = this.options.createComponent({
9812
+ id: data.id,
9813
+ name: data.component,
9814
+ });
9820
9815
  let header;
9821
- if (data.headerComponent) {
9822
- header = createComponent(data.id, data.headerComponent, (_c = this.options.headerComponents) !== null && _c !== void 0 ? _c : {}, (_d = this.options.headerframeworkComponents) !== null && _d !== void 0 ? _d : {}, this.options.frameworkWrapper
9823
- ? {
9824
- createComponent: this.options.frameworkWrapper.header
9825
- .createComponent,
9826
- }
9827
- : undefined);
9816
+ if (data.headerComponent &&
9817
+ this.options.createHeaderComponent) {
9818
+ header = this.options.createHeaderComponent({
9819
+ id: data.id,
9820
+ name: data.headerComponent,
9821
+ });
9828
9822
  }
9829
- else {
9823
+ if (!header) {
9830
9824
  header = new DefaultHeader();
9831
9825
  }
9832
9826
  const panel = new PaneFramework({
@@ -9874,9 +9868,11 @@ class PaneviewComponent extends Resizable {
9874
9868
  this.paneview.dispose();
9875
9869
  }
9876
9870
  doAddPanel(panel) {
9877
- const disposable = panel.onDidDrop((event) => {
9871
+ const disposable = new CompositeDisposable(panel.onDidDrop((event) => {
9878
9872
  this._onDidDrop.fire(event);
9879
- });
9873
+ }), panel.onUnhandledDragOverEvent((event) => {
9874
+ this._onUnhandledDragOverEvent.fire(event);
9875
+ }));
9880
9876
  this._viewDisposables.set(panel.id, disposable);
9881
9877
  }
9882
9878
  doRemovePanel(panel) {
@@ -10159,7 +10155,7 @@ class ReactPanelContentPart {
10159
10155
  this._onDidBlur = new Emitter();
10160
10156
  this.onDidBlur = this._onDidBlur.event;
10161
10157
  this._element = document.createElement('div');
10162
- this._element.className = 'dockview-react-part';
10158
+ this._element.className = 'dv-react-part';
10163
10159
  this._element.style.height = '100%';
10164
10160
  this._element.style.width = '100%';
10165
10161
  }
@@ -10197,7 +10193,7 @@ class ReactPanelHeaderPart {
10197
10193
  this.component = component;
10198
10194
  this.reactPortalStore = reactPortalStore;
10199
10195
  this._element = document.createElement('div');
10200
- this._element.className = 'dockview-react-part';
10196
+ this._element.className = 'dv-react-part';
10201
10197
  this._element.style.height = '100%';
10202
10198
  this._element.style.width = '100%';
10203
10199
  }
@@ -10233,7 +10229,7 @@ class ReactWatermarkPart {
10233
10229
  this.component = component;
10234
10230
  this.reactPortalStore = reactPortalStore;
10235
10231
  this._element = document.createElement('div');
10236
- this._element.className = 'dockview-react-part';
10232
+ this._element.className = 'dv-react-part';
10237
10233
  this._element.style.height = '100%';
10238
10234
  this._element.style.width = '100%';
10239
10235
  }
@@ -10275,7 +10271,7 @@ class ReactHeaderActionsRendererPart {
10275
10271
  this._group = _group;
10276
10272
  this.mutableDisposable = new MutableDisposable();
10277
10273
  this._element = document.createElement('div');
10278
- this._element.className = 'dockview-react-part';
10274
+ this._element.className = 'dv-react-part';
10279
10275
  this._element.style.height = '100%';
10280
10276
  this._element.style.width = '100%';
10281
10277
  }
@@ -10334,8 +10330,8 @@ function createGroupControlElement(component, store) {
10334
10330
  : undefined;
10335
10331
  }
10336
10332
  const DEFAULT_REACT_TAB = 'props.defaultTabComponent';
10337
- function extractCoreOptions(props) {
10338
- const coreOptions = PROPERTY_KEYS.reduce((obj, key) => {
10333
+ function extractCoreOptions$3(props) {
10334
+ const coreOptions = PROPERTY_KEYS_DOCKVIEW.reduce((obj, key) => {
10339
10335
  if (key in props) {
10340
10336
  obj[key] = props[key];
10341
10337
  }
@@ -10351,7 +10347,7 @@ const DockviewReact = React.forwardRef((props, ref) => {
10351
10347
  const prevProps = React.useRef({});
10352
10348
  React.useEffect(() => {
10353
10349
  const changes = {};
10354
- PROPERTY_KEYS.forEach((propKey) => {
10350
+ PROPERTY_KEYS_DOCKVIEW.forEach((propKey) => {
10355
10351
  const key = propKey;
10356
10352
  const propValue = props[key];
10357
10353
  if (key in props && propValue !== prevProps.current[key]) {
@@ -10362,7 +10358,7 @@ const DockviewReact = React.forwardRef((props, ref) => {
10362
10358
  dockviewRef.current.updateOptions(changes);
10363
10359
  }
10364
10360
  prevProps.current = props;
10365
- }, PROPERTY_KEYS.map((key) => props[key]));
10361
+ }, PROPERTY_KEYS_DOCKVIEW.map((key) => props[key]));
10366
10362
  React.useEffect(() => {
10367
10363
  var _a;
10368
10364
  if (!domRef.current) {
@@ -10398,7 +10394,7 @@ const DockviewReact = React.forwardRef((props, ref) => {
10398
10394
  ? DEFAULT_REACT_TAB
10399
10395
  : undefined,
10400
10396
  };
10401
- const api = createDockview(domRef.current, Object.assign(Object.assign({}, extractCoreOptions(props)), frameworkOptions));
10397
+ const api = createDockview(domRef.current, Object.assign(Object.assign({}, extractCoreOptions$3(props)), frameworkOptions));
10402
10398
  const { clientWidth, clientHeight } = domRef.current;
10403
10399
  api.layout(clientWidth, clientHeight);
10404
10400
  if (props.onReady) {
@@ -10586,31 +10582,47 @@ class ReactPanelView extends SplitviewPanel {
10586
10582
  }
10587
10583
  }
10588
10584
 
10585
+ function extractCoreOptions$2(props) {
10586
+ const coreOptions = PROPERTY_KEYS_SPLITVIEW.reduce((obj, key) => {
10587
+ if (key in props) {
10588
+ obj[key] = props[key];
10589
+ }
10590
+ return obj;
10591
+ }, {});
10592
+ return coreOptions;
10593
+ }
10589
10594
  const SplitviewReact = React.forwardRef((props, ref) => {
10590
10595
  const domRef = React.useRef(null);
10591
10596
  const splitviewRef = React.useRef();
10592
10597
  const [portals, addPortal] = usePortalsLifecycle();
10593
10598
  React.useImperativeHandle(ref, () => domRef.current, []);
10599
+ const prevProps = React.useRef({});
10594
10600
  React.useEffect(() => {
10595
- var _a;
10596
- const api = createSplitview(domRef.current, {
10597
- disableAutoResizing: props.disableAutoResizing,
10598
- orientation: (_a = props.orientation) !== null && _a !== void 0 ? _a : Orientation.HORIZONTAL,
10599
- frameworkComponents: props.components,
10600
- frameworkWrapper: {
10601
- createComponent: (id, componentId, component) => {
10602
- return new ReactPanelView(id, componentId, component, {
10603
- addPortal,
10604
- });
10605
- },
10606
- },
10607
- proportionalLayout: typeof props.proportionalLayout === 'boolean'
10608
- ? props.proportionalLayout
10609
- : true,
10610
- styles: props.hideBorders
10611
- ? { separatorBorder: 'transparent' }
10612
- : undefined,
10601
+ const changes = {};
10602
+ PROPERTY_KEYS_SPLITVIEW.forEach((propKey) => {
10603
+ const key = propKey;
10604
+ const propValue = props[key];
10605
+ if (key in props && propValue !== prevProps.current[key]) {
10606
+ changes[key] = propValue;
10607
+ }
10613
10608
  });
10609
+ if (splitviewRef.current) {
10610
+ splitviewRef.current.updateOptions(changes);
10611
+ }
10612
+ prevProps.current = props;
10613
+ }, PROPERTY_KEYS_SPLITVIEW.map((key) => props[key]));
10614
+ React.useEffect(() => {
10615
+ if (!domRef.current) {
10616
+ return () => {
10617
+ // noop
10618
+ };
10619
+ }
10620
+ const frameworkOptions = {
10621
+ createComponent: (options) => {
10622
+ return new ReactPanelView(options.id, options.name, props.components[options.name], { addPortal });
10623
+ },
10624
+ };
10625
+ const api = createSplitview(domRef.current, Object.assign(Object.assign({}, extractCoreOptions$2(props)), frameworkOptions));
10614
10626
  const { clientWidth, clientHeight } = domRef.current;
10615
10627
  api.layout(clientWidth, clientHeight);
10616
10628
  if (props.onReady) {
@@ -10626,7 +10638,9 @@ const SplitviewReact = React.forwardRef((props, ref) => {
10626
10638
  return;
10627
10639
  }
10628
10640
  splitviewRef.current.updateOptions({
10629
- frameworkComponents: props.components,
10641
+ createComponent: (options) => {
10642
+ return new ReactPanelView(options.id, options.name, props.components[options.name], { addPortal });
10643
+ },
10630
10644
  });
10631
10645
  }, [props.components]);
10632
10646
  return (React.createElement("div", { className: props.className, style: { height: '100%', width: '100%' }, ref: domRef }, portals));
@@ -10651,36 +10665,47 @@ class ReactGridPanelView extends GridviewPanel {
10651
10665
  }
10652
10666
  }
10653
10667
 
10668
+ function extractCoreOptions$1(props) {
10669
+ const coreOptions = PROPERTY_KEYS_GRIDVIEW.reduce((obj, key) => {
10670
+ if (key in props) {
10671
+ obj[key] = props[key];
10672
+ }
10673
+ return obj;
10674
+ }, {});
10675
+ return coreOptions;
10676
+ }
10654
10677
  const GridviewReact = React.forwardRef((props, ref) => {
10655
10678
  const domRef = React.useRef(null);
10656
10679
  const gridviewRef = React.useRef();
10657
10680
  const [portals, addPortal] = usePortalsLifecycle();
10658
10681
  React.useImperativeHandle(ref, () => domRef.current, []);
10682
+ const prevProps = React.useRef({});
10683
+ React.useEffect(() => {
10684
+ const changes = {};
10685
+ PROPERTY_KEYS_GRIDVIEW.forEach((propKey) => {
10686
+ const key = propKey;
10687
+ const propValue = props[key];
10688
+ if (key in props && propValue !== prevProps.current[key]) {
10689
+ changes[key] = propValue;
10690
+ }
10691
+ });
10692
+ if (gridviewRef.current) {
10693
+ gridviewRef.current.updateOptions(changes);
10694
+ }
10695
+ prevProps.current = props;
10696
+ }, PROPERTY_KEYS_GRIDVIEW.map((key) => props[key]));
10659
10697
  React.useEffect(() => {
10660
- var _a;
10661
10698
  if (!domRef.current) {
10662
10699
  return () => {
10663
10700
  // noop
10664
10701
  };
10665
10702
  }
10666
- const api = createGridview(domRef.current, {
10667
- disableAutoResizing: props.disableAutoResizing,
10668
- proportionalLayout: typeof props.proportionalLayout === 'boolean'
10669
- ? props.proportionalLayout
10670
- : true,
10671
- orientation: (_a = props.orientation) !== null && _a !== void 0 ? _a : Orientation.HORIZONTAL,
10672
- frameworkComponents: props.components,
10673
- frameworkComponentFactory: {
10674
- createComponent: (id, componentId, component) => {
10675
- return new ReactGridPanelView(id, componentId, component, {
10676
- addPortal,
10677
- });
10678
- },
10703
+ const frameworkOptions = {
10704
+ createComponent: (options) => {
10705
+ return new ReactGridPanelView(options.id, options.name, props.components[options.name], { addPortal });
10679
10706
  },
10680
- styles: props.hideBorders
10681
- ? { separatorBorder: 'transparent' }
10682
- : undefined,
10683
- });
10707
+ };
10708
+ const api = createGridview(domRef.current, Object.assign(Object.assign({}, extractCoreOptions$1(props)), frameworkOptions));
10684
10709
  const { clientWidth, clientHeight } = domRef.current;
10685
10710
  api.layout(clientWidth, clientHeight);
10686
10711
  if (props.onReady) {
@@ -10696,7 +10721,9 @@ const GridviewReact = React.forwardRef((props, ref) => {
10696
10721
  return;
10697
10722
  }
10698
10723
  gridviewRef.current.updateOptions({
10699
- frameworkComponents: props.components,
10724
+ createComponent: (options) => {
10725
+ return new ReactGridPanelView(options.id, options.name, props.components[options.name], { addPortal });
10726
+ },
10700
10727
  });
10701
10728
  }, [props.components]);
10702
10729
  return (React.createElement("div", { className: props.className, style: { height: '100%', width: '100%' }, ref: domRef }, portals));
@@ -10738,32 +10765,52 @@ class PanePanelSection {
10738
10765
  }
10739
10766
  }
10740
10767
 
10768
+ function extractCoreOptions(props) {
10769
+ const coreOptions = PROPERTY_KEYS_PANEVIEW.reduce((obj, key) => {
10770
+ if (key in props) {
10771
+ obj[key] = props[key];
10772
+ }
10773
+ return obj;
10774
+ }, {});
10775
+ return coreOptions;
10776
+ }
10741
10777
  const PaneviewReact = React.forwardRef((props, ref) => {
10742
10778
  const domRef = React.useRef(null);
10743
10779
  const paneviewRef = React.useRef();
10744
10780
  const [portals, addPortal] = usePortalsLifecycle();
10745
10781
  React.useImperativeHandle(ref, () => domRef.current, []);
10782
+ const prevProps = React.useRef({});
10746
10783
  React.useEffect(() => {
10747
- const createComponent = (id, _componentId, component) => new PanePanelSection(id, component, {
10748
- addPortal,
10784
+ const changes = {};
10785
+ PROPERTY_KEYS_PANEVIEW.forEach((propKey) => {
10786
+ const key = propKey;
10787
+ const propValue = props[key];
10788
+ if (key in props && propValue !== prevProps.current[key]) {
10789
+ changes[key] = propValue;
10790
+ }
10749
10791
  });
10750
- const api = createPaneview(domRef.current, {
10751
- disableAutoResizing: props.disableAutoResizing,
10752
- frameworkComponents: props.components,
10753
- components: {},
10754
- headerComponents: {},
10755
- disableDnd: props.disableDnd,
10756
- headerframeworkComponents: props.headerComponents,
10757
- frameworkWrapper: {
10758
- header: {
10759
- createComponent,
10760
- },
10761
- body: {
10762
- createComponent,
10763
- },
10792
+ if (paneviewRef.current) {
10793
+ paneviewRef.current.updateOptions(changes);
10794
+ }
10795
+ prevProps.current = props;
10796
+ }, PROPERTY_KEYS_PANEVIEW.map((key) => props[key]));
10797
+ React.useEffect(() => {
10798
+ var _a;
10799
+ if (!domRef.current) {
10800
+ return () => {
10801
+ // noop
10802
+ };
10803
+ }
10804
+ const headerComponents = (_a = props.headerComponents) !== null && _a !== void 0 ? _a : {};
10805
+ const frameworkOptions = {
10806
+ createComponent: (options) => {
10807
+ return new PanePanelSection(options.id, props.components[options.name], { addPortal });
10764
10808
  },
10765
- showDndOverlay: props.showDndOverlay,
10766
- });
10809
+ createHeaderComponent: (options) => {
10810
+ return new PanePanelSection(options.id, headerComponents[options.name], { addPortal });
10811
+ },
10812
+ };
10813
+ const api = createPaneview(domRef.current, Object.assign(Object.assign({}, extractCoreOptions(props)), frameworkOptions));
10767
10814
  const { clientWidth, clientHeight } = domRef.current;
10768
10815
  api.layout(clientWidth, clientHeight);
10769
10816
  if (props.onReady) {
@@ -10779,44 +10826,41 @@ const PaneviewReact = React.forwardRef((props, ref) => {
10779
10826
  return;
10780
10827
  }
10781
10828
  paneviewRef.current.updateOptions({
10782
- frameworkComponents: props.components,
10829
+ createComponent: (options) => {
10830
+ return new PanePanelSection(options.id, props.components[options.name], { addPortal });
10831
+ },
10783
10832
  });
10784
10833
  }, [props.components]);
10785
10834
  React.useEffect(() => {
10835
+ var _a;
10786
10836
  if (!paneviewRef.current) {
10787
10837
  return;
10788
10838
  }
10839
+ const headerComponents = (_a = props.headerComponents) !== null && _a !== void 0 ? _a : {};
10789
10840
  paneviewRef.current.updateOptions({
10790
- headerframeworkComponents: props.headerComponents,
10841
+ createHeaderComponent: (options) => {
10842
+ return new PanePanelSection(options.id, headerComponents[options.name], { addPortal });
10843
+ },
10791
10844
  });
10792
10845
  }, [props.headerComponents]);
10793
10846
  React.useEffect(() => {
10794
10847
  if (!paneviewRef.current) {
10795
10848
  return () => {
10796
- //
10849
+ // noop
10797
10850
  };
10798
10851
  }
10799
- const api = paneviewRef.current;
10800
- const disposable = api.onDidDrop((event) => {
10852
+ const disposable = paneviewRef.current.onDidDrop((event) => {
10801
10853
  if (props.onDidDrop) {
10802
- props.onDidDrop(Object.assign(Object.assign({}, event), { api }));
10854
+ props.onDidDrop(event);
10803
10855
  }
10804
10856
  });
10805
10857
  return () => {
10806
10858
  disposable.dispose();
10807
10859
  };
10808
10860
  }, [props.onDidDrop]);
10809
- React.useEffect(() => {
10810
- if (!paneviewRef.current) {
10811
- return;
10812
- }
10813
- paneviewRef.current.updateOptions({
10814
- showDndOverlay: props.showDndOverlay,
10815
- });
10816
- }, [props.showDndOverlay]);
10817
10861
  return (React.createElement("div", { className: props.className, style: { height: '100%', width: '100%' }, ref: domRef }, portals));
10818
10862
  });
10819
10863
  PaneviewReact.displayName = 'PaneviewComponent';
10820
10864
 
10821
- export { BaseGrid, ContentContainer, DefaultDockviewDeserialzier, DefaultTab, DockviewApi, DockviewComponent, CompositeDisposable as DockviewCompositeDisposable, DockviewDefaultTab, DockviewDidDropEvent, Disposable as DockviewDisposable, Emitter as DockviewEmitter, Event as DockviewEvent, DockviewGroupPanel, DockviewGroupPanelModel, MutableDisposable as DockviewMutableDisposable, DockviewPanel, DockviewReact, DockviewUnhandledDragOverEvent, DockviewWillDropEvent, DraggablePaneviewPanel, Gridview, GridviewApi, GridviewComponent, GridviewPanel, GridviewReact, LayoutPriority, Orientation, PROPERTY_KEYS, PaneFramework, PaneTransfer, PanelTransfer, Paneview, PaneviewApi, PaneviewComponent, PaneviewPanel, PaneviewReact, ReactPart, ReactPartContext, SashState, Sizing, Splitview, SplitviewApi, SplitviewComponent, SplitviewPanel, SplitviewReact, Tab, WillShowOverlayLocationEvent, createDockview, createGridview, createPaneview, createSplitview, directionToPosition, getDirectionOrientation, getGridLocation, getLocationOrientation, getPaneData, getPanelData, getRelativeLocation, indexInParent, isGridBranchNode, isGroupOptionsWithGroup, isGroupOptionsWithPanel, isPanelOptionsWithGroup, isPanelOptionsWithPanel, isReactComponent, orthogonal, positionToDirection, toTarget, usePortalsLifecycle };
10865
+ export { BaseGrid, ContentContainer, DefaultDockviewDeserialzier, DefaultTab, DockviewApi, DockviewComponent, CompositeDisposable as DockviewCompositeDisposable, DockviewDefaultTab, DockviewDidDropEvent, Disposable as DockviewDisposable, Emitter as DockviewEmitter, Event as DockviewEvent, DockviewGroupPanel, DockviewGroupPanelModel, MutableDisposable as DockviewMutableDisposable, DockviewPanel, DockviewReact, DockviewUnhandledDragOverEvent, DockviewWillDropEvent, DraggablePaneviewPanel, Gridview, GridviewApi, GridviewComponent, GridviewPanel, GridviewReact, LayoutPriority, Orientation, PROPERTY_KEYS_DOCKVIEW, PROPERTY_KEYS_GRIDVIEW, PROPERTY_KEYS_PANEVIEW, PROPERTY_KEYS_SPLITVIEW, PaneFramework, PaneTransfer, PanelTransfer, Paneview, PaneviewApi, PaneviewComponent, PaneviewPanel, PaneviewReact, PaneviewUnhandledDragOverEvent, ReactPart, ReactPartContext, SashState, Sizing, Splitview, SplitviewApi, SplitviewComponent, SplitviewPanel, SplitviewReact, Tab, WillShowOverlayLocationEvent, createDockview, createGridview, createPaneview, createSplitview, directionToPosition, getDirectionOrientation, getGridLocation, getLocationOrientation, getPaneData, getPanelData, getRelativeLocation, indexInParent, isGridBranchNode, isGroupOptionsWithGroup, isGroupOptionsWithPanel, isPanelOptionsWithGroup, isPanelOptionsWithPanel, isReactComponent, orthogonal, positionToDirection, toTarget, usePortalsLifecycle };
10822
10866
  //# sourceMappingURL=dockview-react.esm.js.map