dockview-react 2.1.4 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * dockview-react
3
- * @version 2.1.4
3
+ * @version 3.0.0
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;
@@ -3127,15 +3170,10 @@ class PaneviewApi {
3127
3170
  * Invoked when a Drag'n'Drop event occurs that the component was unable to handle. Exposed for custom Drag'n'Drop functionality.
3128
3171
  */
3129
3172
  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;
3173
+ return this.component.onDidDrop;
3174
+ }
3175
+ get onUnhandledDragOverEvent() {
3176
+ return this.component.onUnhandledDragOverEvent;
3139
3177
  }
3140
3178
  constructor(component) {
3141
3179
  this.component = component;
@@ -4062,6 +4100,28 @@ function calculateQuadrantAsPixels(overlayType, x, y, width, height, threshold)
4062
4100
  return 'center';
4063
4101
  }
4064
4102
 
4103
+ const PROPERTY_KEYS_PANEVIEW = (() => {
4104
+ /**
4105
+ * by readong the keys from an empty value object TypeScript will error
4106
+ * when we add or remove new properties to `DockviewOptions`
4107
+ */
4108
+ const properties = {
4109
+ disableAutoResizing: undefined,
4110
+ disableDnd: undefined,
4111
+ className: undefined,
4112
+ };
4113
+ return Object.keys(properties);
4114
+ })();
4115
+ class PaneviewUnhandledDragOverEvent extends AcceptableEvent {
4116
+ constructor(nativeEvent, position, getData, panel) {
4117
+ super();
4118
+ this.nativeEvent = nativeEvent;
4119
+ this.position = position;
4120
+ this.getData = getData;
4121
+ this.panel = panel;
4122
+ }
4123
+ }
4124
+
4065
4125
  class WillFocusEvent extends DockviewEvent {
4066
4126
  constructor() {
4067
4127
  super();
@@ -4485,6 +4545,9 @@ class DraggablePaneviewPanel extends PaneviewPanel {
4485
4545
  this.accessor = accessor;
4486
4546
  this._onDidDrop = new Emitter();
4487
4547
  this.onDidDrop = this._onDidDrop.event;
4548
+ this._onUnhandledDragOverEvent = new Emitter();
4549
+ this.onUnhandledDragOverEvent = this._onUnhandledDragOverEvent.event;
4550
+ this.addDisposables(this._onDidDrop, this._onUnhandledDragOverEvent);
4488
4551
  if (!disableDnd) {
4489
4552
  this.initDragFeatures();
4490
4553
  }
@@ -4511,7 +4574,7 @@ class DraggablePaneviewPanel extends PaneviewPanel {
4511
4574
  overlayModel: {
4512
4575
  activationSize: { type: 'percentage', value: 50 },
4513
4576
  },
4514
- canDisplayOverlay: (event) => {
4577
+ canDisplayOverlay: (event, position) => {
4515
4578
  const data = getPaneData();
4516
4579
  if (data) {
4517
4580
  if (data.paneId !== this.id &&
@@ -4519,14 +4582,9 @@ class DraggablePaneviewPanel extends PaneviewPanel {
4519
4582
  return true;
4520
4583
  }
4521
4584
  }
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;
4585
+ const firedEvent = new PaneviewUnhandledDragOverEvent(event, position, getPaneData, this);
4586
+ this._onUnhandledDragOverEvent.fire(firedEvent);
4587
+ return firedEvent.isAccepted;
4530
4588
  },
4531
4589
  });
4532
4590
  this.addDisposables(this._onDidDrop, this.handler, this.target, this.target.onDrop((event) => {
@@ -4981,15 +5039,7 @@ class TabsContainer extends CompositeDisposable {
4981
5039
  this._element.appendChild(this.leftActionsContainer);
4982
5040
  this._element.appendChild(this.voidContainer.element);
4983
5041
  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) => {
5042
+ this.addDisposables(this._onWillShowOverlay, this._onDrop, this._onTabDragStart, this._onGroupDragStart, this.voidContainer, this.voidContainer.onDragStart((event) => {
4993
5043
  this._onGroupDragStart.fire({
4994
5044
  nativeEvent: event,
4995
5045
  group: this.group,
@@ -5034,20 +5084,6 @@ class TabsContainer extends CompositeDisposable {
5034
5084
  setActive(_isGroupActive) {
5035
5085
  // noop
5036
5086
  }
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
5087
  delete(id) {
5052
5088
  const index = this.tabs.findIndex((tab) => tab.value.panel.id === id);
5053
5089
  const tabToRemove = this.tabs.splice(index, 1)[0];
@@ -5055,6 +5091,7 @@ class TabsContainer extends CompositeDisposable {
5055
5091
  disposable.dispose();
5056
5092
  value.dispose();
5057
5093
  value.element.remove();
5094
+ this.updateClassnames();
5058
5095
  }
5059
5096
  setActivePanel(panel) {
5060
5097
  this.tabs.forEach((tab) => {
@@ -5123,25 +5160,37 @@ class TabsContainer extends CompositeDisposable {
5123
5160
  }
5124
5161
  this.tabs = [];
5125
5162
  }
5163
+ addTab(tab, index = this.tabs.length) {
5164
+ if (index < 0 || index > this.tabs.length) {
5165
+ throw new Error('invalid location');
5166
+ }
5167
+ this.tabContainer.insertBefore(tab.value.element, this.tabContainer.children[index]);
5168
+ this.tabs = [
5169
+ ...this.tabs.slice(0, index),
5170
+ tab,
5171
+ ...this.tabs.slice(index),
5172
+ ];
5173
+ if (this.selectedIndex < 0) {
5174
+ this.selectedIndex = index;
5175
+ }
5176
+ this.updateClassnames();
5177
+ }
5178
+ updateClassnames() {
5179
+ toggleClass(this._element, 'dv-single-tab', this.size === 1);
5180
+ }
5126
5181
  }
5127
5182
 
5128
- class DockviewUnhandledDragOverEvent {
5129
- get isAccepted() {
5130
- return this._isAccepted;
5131
- }
5183
+ class DockviewUnhandledDragOverEvent extends AcceptableEvent {
5132
5184
  constructor(nativeEvent, target, position, getData, group) {
5185
+ super();
5133
5186
  this.nativeEvent = nativeEvent;
5134
5187
  this.target = target;
5135
5188
  this.position = position;
5136
5189
  this.getData = getData;
5137
5190
  this.group = group;
5138
- this._isAccepted = false;
5139
- }
5140
- accept() {
5141
- this._isAccepted = true;
5142
5191
  }
5143
5192
  }
5144
- const PROPERTY_KEYS = (() => {
5193
+ const PROPERTY_KEYS_DOCKVIEW = (() => {
5145
5194
  /**
5146
5195
  * by readong the keys from an empty value object TypeScript will error
5147
5196
  * when we add or remove new properties to `DockviewOptions`
@@ -8987,31 +9036,6 @@ class DockviewComponent extends BaseGrid {
8987
9036
  }
8988
9037
  }
8989
9038
 
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
9039
  class GridviewComponent extends BaseGrid {
9016
9040
  get orientation() {
9017
9041
  return this.gridview.orientation;
@@ -9029,10 +9053,13 @@ class GridviewComponent extends BaseGrid {
9029
9053
  this._deserializer = value;
9030
9054
  }
9031
9055
  constructor(parentElement, options) {
9056
+ var _a;
9032
9057
  super(parentElement, {
9033
- proportionalLayout: options.proportionalLayout,
9058
+ proportionalLayout: (_a = options.proportionalLayout) !== null && _a !== void 0 ? _a : true,
9034
9059
  orientation: options.orientation,
9035
- styles: options.styles,
9060
+ styles: options.hideBorders
9061
+ ? { separatorBorder: 'transparent' }
9062
+ : undefined,
9036
9063
  disableAutoResizing: options.disableAutoResizing,
9037
9064
  className: options.className,
9038
9065
  });
@@ -9052,12 +9079,6 @@ class GridviewComponent extends BaseGrid {
9052
9079
  }), this.onDidActiveChange((event) => {
9053
9080
  this._onDidActiveGroupChange.fire(event);
9054
9081
  }));
9055
- if (!this.options.components) {
9056
- this.options.components = {};
9057
- }
9058
- if (!this.options.frameworkComponents) {
9059
- this.options.frameworkComponents = {};
9060
- }
9061
9082
  }
9062
9083
  updateOptions(options) {
9063
9084
  super.updateOptions(options);
@@ -9107,14 +9128,11 @@ class GridviewComponent extends BaseGrid {
9107
9128
  const height = this.height;
9108
9129
  this.gridview.deserialize(grid, {
9109
9130
  fromJSON: (node) => {
9110
- var _a, _b;
9111
9131
  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);
9132
+ const view = this.options.createComponent({
9133
+ id: data.id,
9134
+ name: data.component,
9135
+ });
9118
9136
  queue.push(() => view.init({
9119
9137
  params: data.params,
9120
9138
  minimumWidth: data.minimumWidth,
@@ -9192,7 +9210,7 @@ class GridviewComponent extends BaseGrid {
9192
9210
  this.doAddGroup(removedPanel, relativeLocation, options.size);
9193
9211
  }
9194
9212
  addPanel(options) {
9195
- var _a, _b, _c, _d, _e, _f;
9213
+ var _a, _b, _c, _d;
9196
9214
  let relativeLocation = (_a = options.location) !== null && _a !== void 0 ? _a : [0];
9197
9215
  if ((_b = options.position) === null || _b === void 0 ? void 0 : _b.referencePanel) {
9198
9216
  const referenceGroup = (_c = this._groups.get(options.position.referencePanel)) === null || _c === void 0 ? void 0 : _c.value;
@@ -9208,14 +9226,12 @@ class GridviewComponent extends BaseGrid {
9208
9226
  relativeLocation = getRelativeLocation(this.gridview.orientation, location, target);
9209
9227
  }
9210
9228
  }
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);
9229
+ const view = this.options.createComponent({
9230
+ id: options.id,
9231
+ name: options.component,
9232
+ });
9217
9233
  view.init({
9218
- params: (_f = options.params) !== null && _f !== void 0 ? _f : {},
9234
+ params: (_d = options.params) !== null && _d !== void 0 ? _d : {},
9219
9235
  minimumWidth: options.minimumWidth,
9220
9236
  maximumWidth: options.maximumWidth,
9221
9237
  minimumHeight: options.minimumHeight,
@@ -9343,12 +9359,6 @@ class SplitviewComponent extends Resizable {
9343
9359
  this._classNames = new Classnames(this.element);
9344
9360
  this._classNames.setClassNames((_a = options.className) !== null && _a !== void 0 ? _a : '');
9345
9361
  this._options = options;
9346
- if (!options.components) {
9347
- options.components = {};
9348
- }
9349
- if (!options.frameworkComponents) {
9350
- options.frameworkComponents = {};
9351
- }
9352
9362
  this.splitview = new Splitview(this.element, options);
9353
9363
  this.addDisposables(this._onDidAddView, this._onDidLayoutfromJSON, this._onDidRemoveView, this._onDidLayoutChange);
9354
9364
  }
@@ -9411,18 +9421,17 @@ class SplitviewComponent extends Resizable {
9411
9421
  return this.panels.find((view) => view.id === id);
9412
9422
  }
9413
9423
  addPanel(options) {
9414
- var _a, _b, _c;
9424
+ var _a;
9415
9425
  if (this._panels.has(options.id)) {
9416
9426
  throw new Error(`panel ${options.id} already exists`);
9417
9427
  }
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);
9428
+ const view = this.options.createComponent({
9429
+ id: options.id,
9430
+ name: options.component,
9431
+ });
9423
9432
  view.orientation = this.splitview.orientation;
9424
9433
  view.init({
9425
- params: (_c = options.params) !== null && _c !== void 0 ? _c : {},
9434
+ params: (_a = options.params) !== null && _a !== void 0 ? _a : {},
9426
9435
  minimumSize: options.minimumSize,
9427
9436
  maximumSize: options.maximumSize,
9428
9437
  snap: options.snap,
@@ -9484,17 +9493,14 @@ class SplitviewComponent extends Resizable {
9484
9493
  descriptor: {
9485
9494
  size,
9486
9495
  views: views.map((view) => {
9487
- var _a, _b;
9488
9496
  const data = view.data;
9489
9497
  if (this._panels.has(data.id)) {
9490
9498
  throw new Error(`panel ${data.id} already exists`);
9491
9499
  }
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);
9500
+ const panel = this.options.createComponent({
9501
+ id: data.id,
9502
+ name: data.component,
9503
+ });
9498
9504
  queue.push(() => {
9499
9505
  var _a;
9500
9506
  panel.init({
@@ -9677,16 +9683,12 @@ class PaneviewComponent extends Resizable {
9677
9683
  this.onDidAddView = this._onDidAddView.event;
9678
9684
  this._onDidRemoveView = new Emitter();
9679
9685
  this.onDidRemoveView = this._onDidRemoveView.event;
9680
- this.addDisposables(this._onDidLayoutChange, this._onDidLayoutfromJSON, this._onDidDrop, this._onDidAddView, this._onDidRemoveView);
9686
+ this._onUnhandledDragOverEvent = new Emitter();
9687
+ this.onUnhandledDragOverEvent = this._onUnhandledDragOverEvent.event;
9688
+ this.addDisposables(this._onDidLayoutChange, this._onDidLayoutfromJSON, this._onDidDrop, this._onDidAddView, this._onDidRemoveView, this._onUnhandledDragOverEvent);
9681
9689
  this._classNames = new Classnames(this.element);
9682
9690
  this._classNames.setClassNames((_a = options.className) !== null && _a !== void 0 ? _a : '');
9683
9691
  this._options = options;
9684
- if (!options.components) {
9685
- options.components = {};
9686
- }
9687
- if (!options.frameworkComponents) {
9688
- options.frameworkComponents = {};
9689
- }
9690
9692
  this.paneview = new Paneview(this.element, {
9691
9693
  // only allow paneview in the vertical orientation for now
9692
9694
  orientation: Orientation.VERTICAL,
@@ -9711,22 +9713,19 @@ class PaneviewComponent extends Resizable {
9711
9713
  this._options = Object.assign(Object.assign({}, this.options), options);
9712
9714
  }
9713
9715
  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);
9716
+ var _a;
9717
+ const body = this.options.createComponent({
9718
+ id: options.id,
9719
+ name: options.component,
9720
+ });
9720
9721
  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);
9722
+ if (options.headerComponent && this.options.createHeaderComponent) {
9723
+ header = this.options.createHeaderComponent({
9724
+ id: options.id,
9725
+ name: options.headerComponent,
9726
+ });
9728
9727
  }
9729
- else {
9728
+ if (!header) {
9730
9729
  header = new DefaultHeader();
9731
9730
  }
9732
9731
  const view = new PaneFramework({
@@ -9744,7 +9743,7 @@ class PaneviewComponent extends Resizable {
9744
9743
  const size = typeof options.size === 'number' ? options.size : Sizing.Distribute;
9745
9744
  const index = typeof options.index === 'number' ? options.index : undefined;
9746
9745
  view.init({
9747
- params: (_d = options.params) !== null && _d !== void 0 ? _d : {},
9746
+ params: (_a = options.params) !== null && _a !== void 0 ? _a : {},
9748
9747
  minimumBodySize: options.minimumBodySize,
9749
9748
  maximumBodySize: options.maximumBodySize,
9750
9749
  isExpanded: options.isExpanded,
@@ -9809,24 +9808,20 @@ class PaneviewComponent extends Resizable {
9809
9808
  descriptor: {
9810
9809
  size,
9811
9810
  views: views.map((view) => {
9812
- var _a, _b, _c, _d;
9813
9811
  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);
9812
+ const body = this.options.createComponent({
9813
+ id: data.id,
9814
+ name: data.component,
9815
+ });
9820
9816
  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);
9817
+ if (data.headerComponent &&
9818
+ this.options.createHeaderComponent) {
9819
+ header = this.options.createHeaderComponent({
9820
+ id: data.id,
9821
+ name: data.headerComponent,
9822
+ });
9828
9823
  }
9829
- else {
9824
+ if (!header) {
9830
9825
  header = new DefaultHeader();
9831
9826
  }
9832
9827
  const panel = new PaneFramework({
@@ -9874,9 +9869,11 @@ class PaneviewComponent extends Resizable {
9874
9869
  this.paneview.dispose();
9875
9870
  }
9876
9871
  doAddPanel(panel) {
9877
- const disposable = panel.onDidDrop((event) => {
9872
+ const disposable = new CompositeDisposable(panel.onDidDrop((event) => {
9878
9873
  this._onDidDrop.fire(event);
9879
- });
9874
+ }), panel.onUnhandledDragOverEvent((event) => {
9875
+ this._onUnhandledDragOverEvent.fire(event);
9876
+ }));
9880
9877
  this._viewDisposables.set(panel.id, disposable);
9881
9878
  }
9882
9879
  doRemovePanel(panel) {
@@ -10159,7 +10156,7 @@ class ReactPanelContentPart {
10159
10156
  this._onDidBlur = new Emitter();
10160
10157
  this.onDidBlur = this._onDidBlur.event;
10161
10158
  this._element = document.createElement('div');
10162
- this._element.className = 'dockview-react-part';
10159
+ this._element.className = 'dv-react-part';
10163
10160
  this._element.style.height = '100%';
10164
10161
  this._element.style.width = '100%';
10165
10162
  }
@@ -10197,7 +10194,7 @@ class ReactPanelHeaderPart {
10197
10194
  this.component = component;
10198
10195
  this.reactPortalStore = reactPortalStore;
10199
10196
  this._element = document.createElement('div');
10200
- this._element.className = 'dockview-react-part';
10197
+ this._element.className = 'dv-react-part';
10201
10198
  this._element.style.height = '100%';
10202
10199
  this._element.style.width = '100%';
10203
10200
  }
@@ -10233,7 +10230,7 @@ class ReactWatermarkPart {
10233
10230
  this.component = component;
10234
10231
  this.reactPortalStore = reactPortalStore;
10235
10232
  this._element = document.createElement('div');
10236
- this._element.className = 'dockview-react-part';
10233
+ this._element.className = 'dv-react-part';
10237
10234
  this._element.style.height = '100%';
10238
10235
  this._element.style.width = '100%';
10239
10236
  }
@@ -10275,7 +10272,7 @@ class ReactHeaderActionsRendererPart {
10275
10272
  this._group = _group;
10276
10273
  this.mutableDisposable = new MutableDisposable();
10277
10274
  this._element = document.createElement('div');
10278
- this._element.className = 'dockview-react-part';
10275
+ this._element.className = 'dv-react-part';
10279
10276
  this._element.style.height = '100%';
10280
10277
  this._element.style.width = '100%';
10281
10278
  }
@@ -10334,8 +10331,8 @@ function createGroupControlElement(component, store) {
10334
10331
  : undefined;
10335
10332
  }
10336
10333
  const DEFAULT_REACT_TAB = 'props.defaultTabComponent';
10337
- function extractCoreOptions(props) {
10338
- const coreOptions = PROPERTY_KEYS.reduce((obj, key) => {
10334
+ function extractCoreOptions$3(props) {
10335
+ const coreOptions = PROPERTY_KEYS_DOCKVIEW.reduce((obj, key) => {
10339
10336
  if (key in props) {
10340
10337
  obj[key] = props[key];
10341
10338
  }
@@ -10351,7 +10348,7 @@ const DockviewReact = React.forwardRef((props, ref) => {
10351
10348
  const prevProps = React.useRef({});
10352
10349
  React.useEffect(() => {
10353
10350
  const changes = {};
10354
- PROPERTY_KEYS.forEach((propKey) => {
10351
+ PROPERTY_KEYS_DOCKVIEW.forEach((propKey) => {
10355
10352
  const key = propKey;
10356
10353
  const propValue = props[key];
10357
10354
  if (key in props && propValue !== prevProps.current[key]) {
@@ -10362,7 +10359,7 @@ const DockviewReact = React.forwardRef((props, ref) => {
10362
10359
  dockviewRef.current.updateOptions(changes);
10363
10360
  }
10364
10361
  prevProps.current = props;
10365
- }, PROPERTY_KEYS.map((key) => props[key]));
10362
+ }, PROPERTY_KEYS_DOCKVIEW.map((key) => props[key]));
10366
10363
  React.useEffect(() => {
10367
10364
  var _a;
10368
10365
  if (!domRef.current) {
@@ -10398,7 +10395,7 @@ const DockviewReact = React.forwardRef((props, ref) => {
10398
10395
  ? DEFAULT_REACT_TAB
10399
10396
  : undefined,
10400
10397
  };
10401
- const api = createDockview(domRef.current, Object.assign(Object.assign({}, extractCoreOptions(props)), frameworkOptions));
10398
+ const api = createDockview(domRef.current, Object.assign(Object.assign({}, extractCoreOptions$3(props)), frameworkOptions));
10402
10399
  const { clientWidth, clientHeight } = domRef.current;
10403
10400
  api.layout(clientWidth, clientHeight);
10404
10401
  if (props.onReady) {
@@ -10586,31 +10583,47 @@ class ReactPanelView extends SplitviewPanel {
10586
10583
  }
10587
10584
  }
10588
10585
 
10586
+ function extractCoreOptions$2(props) {
10587
+ const coreOptions = PROPERTY_KEYS_SPLITVIEW.reduce((obj, key) => {
10588
+ if (key in props) {
10589
+ obj[key] = props[key];
10590
+ }
10591
+ return obj;
10592
+ }, {});
10593
+ return coreOptions;
10594
+ }
10589
10595
  const SplitviewReact = React.forwardRef((props, ref) => {
10590
10596
  const domRef = React.useRef(null);
10591
10597
  const splitviewRef = React.useRef();
10592
10598
  const [portals, addPortal] = usePortalsLifecycle();
10593
10599
  React.useImperativeHandle(ref, () => domRef.current, []);
10600
+ const prevProps = React.useRef({});
10594
10601
  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,
10602
+ const changes = {};
10603
+ PROPERTY_KEYS_SPLITVIEW.forEach((propKey) => {
10604
+ const key = propKey;
10605
+ const propValue = props[key];
10606
+ if (key in props && propValue !== prevProps.current[key]) {
10607
+ changes[key] = propValue;
10608
+ }
10613
10609
  });
10610
+ if (splitviewRef.current) {
10611
+ splitviewRef.current.updateOptions(changes);
10612
+ }
10613
+ prevProps.current = props;
10614
+ }, PROPERTY_KEYS_SPLITVIEW.map((key) => props[key]));
10615
+ React.useEffect(() => {
10616
+ if (!domRef.current) {
10617
+ return () => {
10618
+ // noop
10619
+ };
10620
+ }
10621
+ const frameworkOptions = {
10622
+ createComponent: (options) => {
10623
+ return new ReactPanelView(options.id, options.name, props.components[options.name], { addPortal });
10624
+ },
10625
+ };
10626
+ const api = createSplitview(domRef.current, Object.assign(Object.assign({}, extractCoreOptions$2(props)), frameworkOptions));
10614
10627
  const { clientWidth, clientHeight } = domRef.current;
10615
10628
  api.layout(clientWidth, clientHeight);
10616
10629
  if (props.onReady) {
@@ -10626,7 +10639,9 @@ const SplitviewReact = React.forwardRef((props, ref) => {
10626
10639
  return;
10627
10640
  }
10628
10641
  splitviewRef.current.updateOptions({
10629
- frameworkComponents: props.components,
10642
+ createComponent: (options) => {
10643
+ return new ReactPanelView(options.id, options.name, props.components[options.name], { addPortal });
10644
+ },
10630
10645
  });
10631
10646
  }, [props.components]);
10632
10647
  return (React.createElement("div", { className: props.className, style: { height: '100%', width: '100%' }, ref: domRef }, portals));
@@ -10651,36 +10666,47 @@ class ReactGridPanelView extends GridviewPanel {
10651
10666
  }
10652
10667
  }
10653
10668
 
10669
+ function extractCoreOptions$1(props) {
10670
+ const coreOptions = PROPERTY_KEYS_GRIDVIEW.reduce((obj, key) => {
10671
+ if (key in props) {
10672
+ obj[key] = props[key];
10673
+ }
10674
+ return obj;
10675
+ }, {});
10676
+ return coreOptions;
10677
+ }
10654
10678
  const GridviewReact = React.forwardRef((props, ref) => {
10655
10679
  const domRef = React.useRef(null);
10656
10680
  const gridviewRef = React.useRef();
10657
10681
  const [portals, addPortal] = usePortalsLifecycle();
10658
10682
  React.useImperativeHandle(ref, () => domRef.current, []);
10683
+ const prevProps = React.useRef({});
10684
+ React.useEffect(() => {
10685
+ const changes = {};
10686
+ PROPERTY_KEYS_GRIDVIEW.forEach((propKey) => {
10687
+ const key = propKey;
10688
+ const propValue = props[key];
10689
+ if (key in props && propValue !== prevProps.current[key]) {
10690
+ changes[key] = propValue;
10691
+ }
10692
+ });
10693
+ if (gridviewRef.current) {
10694
+ gridviewRef.current.updateOptions(changes);
10695
+ }
10696
+ prevProps.current = props;
10697
+ }, PROPERTY_KEYS_GRIDVIEW.map((key) => props[key]));
10659
10698
  React.useEffect(() => {
10660
- var _a;
10661
10699
  if (!domRef.current) {
10662
10700
  return () => {
10663
10701
  // noop
10664
10702
  };
10665
10703
  }
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
- },
10704
+ const frameworkOptions = {
10705
+ createComponent: (options) => {
10706
+ return new ReactGridPanelView(options.id, options.name, props.components[options.name], { addPortal });
10679
10707
  },
10680
- styles: props.hideBorders
10681
- ? { separatorBorder: 'transparent' }
10682
- : undefined,
10683
- });
10708
+ };
10709
+ const api = createGridview(domRef.current, Object.assign(Object.assign({}, extractCoreOptions$1(props)), frameworkOptions));
10684
10710
  const { clientWidth, clientHeight } = domRef.current;
10685
10711
  api.layout(clientWidth, clientHeight);
10686
10712
  if (props.onReady) {
@@ -10696,7 +10722,9 @@ const GridviewReact = React.forwardRef((props, ref) => {
10696
10722
  return;
10697
10723
  }
10698
10724
  gridviewRef.current.updateOptions({
10699
- frameworkComponents: props.components,
10725
+ createComponent: (options) => {
10726
+ return new ReactGridPanelView(options.id, options.name, props.components[options.name], { addPortal });
10727
+ },
10700
10728
  });
10701
10729
  }, [props.components]);
10702
10730
  return (React.createElement("div", { className: props.className, style: { height: '100%', width: '100%' }, ref: domRef }, portals));
@@ -10738,32 +10766,52 @@ class PanePanelSection {
10738
10766
  }
10739
10767
  }
10740
10768
 
10769
+ function extractCoreOptions(props) {
10770
+ const coreOptions = PROPERTY_KEYS_PANEVIEW.reduce((obj, key) => {
10771
+ if (key in props) {
10772
+ obj[key] = props[key];
10773
+ }
10774
+ return obj;
10775
+ }, {});
10776
+ return coreOptions;
10777
+ }
10741
10778
  const PaneviewReact = React.forwardRef((props, ref) => {
10742
10779
  const domRef = React.useRef(null);
10743
10780
  const paneviewRef = React.useRef();
10744
10781
  const [portals, addPortal] = usePortalsLifecycle();
10745
10782
  React.useImperativeHandle(ref, () => domRef.current, []);
10783
+ const prevProps = React.useRef({});
10746
10784
  React.useEffect(() => {
10747
- const createComponent = (id, _componentId, component) => new PanePanelSection(id, component, {
10748
- addPortal,
10785
+ const changes = {};
10786
+ PROPERTY_KEYS_PANEVIEW.forEach((propKey) => {
10787
+ const key = propKey;
10788
+ const propValue = props[key];
10789
+ if (key in props && propValue !== prevProps.current[key]) {
10790
+ changes[key] = propValue;
10791
+ }
10749
10792
  });
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
- },
10793
+ if (paneviewRef.current) {
10794
+ paneviewRef.current.updateOptions(changes);
10795
+ }
10796
+ prevProps.current = props;
10797
+ }, PROPERTY_KEYS_PANEVIEW.map((key) => props[key]));
10798
+ React.useEffect(() => {
10799
+ var _a;
10800
+ if (!domRef.current) {
10801
+ return () => {
10802
+ // noop
10803
+ };
10804
+ }
10805
+ const headerComponents = (_a = props.headerComponents) !== null && _a !== void 0 ? _a : {};
10806
+ const frameworkOptions = {
10807
+ createComponent: (options) => {
10808
+ return new PanePanelSection(options.id, props.components[options.name], { addPortal });
10764
10809
  },
10765
- showDndOverlay: props.showDndOverlay,
10766
- });
10810
+ createHeaderComponent: (options) => {
10811
+ return new PanePanelSection(options.id, headerComponents[options.name], { addPortal });
10812
+ },
10813
+ };
10814
+ const api = createPaneview(domRef.current, Object.assign(Object.assign({}, extractCoreOptions(props)), frameworkOptions));
10767
10815
  const { clientWidth, clientHeight } = domRef.current;
10768
10816
  api.layout(clientWidth, clientHeight);
10769
10817
  if (props.onReady) {
@@ -10779,44 +10827,41 @@ const PaneviewReact = React.forwardRef((props, ref) => {
10779
10827
  return;
10780
10828
  }
10781
10829
  paneviewRef.current.updateOptions({
10782
- frameworkComponents: props.components,
10830
+ createComponent: (options) => {
10831
+ return new PanePanelSection(options.id, props.components[options.name], { addPortal });
10832
+ },
10783
10833
  });
10784
10834
  }, [props.components]);
10785
10835
  React.useEffect(() => {
10836
+ var _a;
10786
10837
  if (!paneviewRef.current) {
10787
10838
  return;
10788
10839
  }
10840
+ const headerComponents = (_a = props.headerComponents) !== null && _a !== void 0 ? _a : {};
10789
10841
  paneviewRef.current.updateOptions({
10790
- headerframeworkComponents: props.headerComponents,
10842
+ createHeaderComponent: (options) => {
10843
+ return new PanePanelSection(options.id, headerComponents[options.name], { addPortal });
10844
+ },
10791
10845
  });
10792
10846
  }, [props.headerComponents]);
10793
10847
  React.useEffect(() => {
10794
10848
  if (!paneviewRef.current) {
10795
10849
  return () => {
10796
- //
10850
+ // noop
10797
10851
  };
10798
10852
  }
10799
- const api = paneviewRef.current;
10800
- const disposable = api.onDidDrop((event) => {
10853
+ const disposable = paneviewRef.current.onDidDrop((event) => {
10801
10854
  if (props.onDidDrop) {
10802
- props.onDidDrop(Object.assign(Object.assign({}, event), { api }));
10855
+ props.onDidDrop(event);
10803
10856
  }
10804
10857
  });
10805
10858
  return () => {
10806
10859
  disposable.dispose();
10807
10860
  };
10808
10861
  }, [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
10862
  return (React.createElement("div", { className: props.className, style: { height: '100%', width: '100%' }, ref: domRef }, portals));
10818
10863
  });
10819
10864
  PaneviewReact.displayName = 'PaneviewComponent';
10820
10865
 
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 };
10866
+ 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
10867
  //# sourceMappingURL=dockview-react.esm.js.map