dockview-react 4.2.4 → 4.3.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 4.2.4
3
+ * @version 4.3.0
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -675,9 +675,7 @@
675
675
  function shiftAbsoluteElementIntoView(element, root, options = { buffer: 10 }) {
676
676
  const buffer = options.buffer;
677
677
  const rect = element.getBoundingClientRect();
678
- const rootRect = element.getBoundingClientRect();
679
- const viewportWidth = root.clientWidth;
680
- const viewportHeight = root.clientHeight;
678
+ const rootRect = root.getBoundingClientRect();
681
679
  let translateX = 0;
682
680
  let translateY = 0;
683
681
  const left = rect.left - rootRect.left;
@@ -688,15 +686,15 @@
688
686
  if (left < buffer) {
689
687
  translateX = buffer - left;
690
688
  }
691
- else if (right > viewportWidth - buffer) {
692
- translateX = viewportWidth - right - buffer;
689
+ else if (right > buffer) {
690
+ translateX = -buffer - right;
693
691
  }
694
692
  // Check vertical overflow
695
693
  if (top < buffer) {
696
694
  translateY = buffer - top;
697
695
  }
698
- else if (bottom > viewportHeight - buffer) {
699
- translateY = viewportHeight - bottom - buffer;
696
+ else if (bottom > buffer) {
697
+ translateY = -bottom - buffer;
700
698
  }
701
699
  // Apply the translation if needed
702
700
  if (translateX !== 0 || translateY !== 0) {
@@ -3989,9 +3987,9 @@
3989
3987
  onDragOver: (e) => {
3990
3988
  var _a, _b, _c, _d, _e, _f, _g;
3991
3989
  Droptarget.ACTUAL_TARGET = this;
3992
- const overrideTraget = (_b = (_a = this.options).getOverrideTarget) === null || _b === void 0 ? void 0 : _b.call(_a);
3990
+ const overrideTarget = (_b = (_a = this.options).getOverrideTarget) === null || _b === void 0 ? void 0 : _b.call(_a);
3993
3991
  if (this._acceptedTargetZonesSet.size === 0) {
3994
- if (overrideTraget) {
3992
+ if (overrideTarget) {
3995
3993
  return;
3996
3994
  }
3997
3995
  this.removeDropTarget();
@@ -4018,7 +4016,7 @@
4018
4016
  return;
4019
4017
  }
4020
4018
  if (!this.options.canDisplayOverlay(e, quadrant)) {
4021
- if (overrideTraget) {
4019
+ if (overrideTarget) {
4022
4020
  return;
4023
4021
  }
4024
4022
  this.removeDropTarget();
@@ -4038,7 +4036,7 @@
4038
4036
  return;
4039
4037
  }
4040
4038
  this.markAsUsed(e);
4041
- if (overrideTraget) ;
4039
+ if (overrideTarget) ;
4042
4040
  else if (!this.targetElement) {
4043
4041
  this.targetElement = document.createElement('div');
4044
4042
  this.targetElement.className = 'dv-drop-target-dropzone';
@@ -4977,6 +4975,8 @@
4977
4975
  var _a, _b;
4978
4976
  // class dockview provides to force ghost image to be drawn on a different layer and prevent weird rendering issues
4979
4977
  addClasses(ghostElement, 'dv-dragged');
4978
+ // move the element off-screen initially otherwise it may in some cases be rendered at (0,0) momentarily
4979
+ ghostElement.style.top = '-9999px';
4980
4980
  document.body.appendChild(ghostElement);
4981
4981
  dataTransfer.setDragImage(ghostElement, (_a = options === null || options === void 0 ? void 0 : options.x) !== null && _a !== void 0 ? _a : 0, (_b = options === null || options === void 0 ? void 0 : options.y) !== null && _b !== void 0 ? _b : 0);
4982
4982
  setTimeout(() => {
@@ -5145,7 +5145,7 @@
5145
5145
  this.accessor.doSetGroupActive(this.group);
5146
5146
  }));
5147
5147
  const handler = new GroupDragHandler(this._element, accessor, group);
5148
- this.dropTraget = new Droptarget(this._element, {
5148
+ this.dropTarget = new Droptarget(this._element, {
5149
5149
  acceptedTargetZones: ['center'],
5150
5150
  canDisplayOverlay: (event, position) => {
5151
5151
  const data = getPanelData();
@@ -5156,12 +5156,12 @@
5156
5156
  },
5157
5157
  getOverrideTarget: () => { var _a; return (_a = group.model.dropTargetContainer) === null || _a === void 0 ? void 0 : _a.model; },
5158
5158
  });
5159
- this.onWillShowOverlay = this.dropTraget.onWillShowOverlay;
5159
+ this.onWillShowOverlay = this.dropTarget.onWillShowOverlay;
5160
5160
  this.addDisposables(handler, handler.onDragStart((event) => {
5161
5161
  this._onDragStart.fire(event);
5162
- }), this.dropTraget.onDrop((event) => {
5162
+ }), this.dropTarget.onDrop((event) => {
5163
5163
  this._onDrop.fire(event);
5164
- }), this.dropTraget);
5164
+ }), this.dropTarget);
5165
5165
  }
5166
5166
  }
5167
5167
 
@@ -8449,9 +8449,11 @@
8449
8449
  const gready = document.createElement('div');
8450
8450
  gready.className = 'dv-overlay-render-container';
8451
8451
  const overlayRenderContainer = new OverlayRenderContainer(gready, this);
8452
- const referenceGroup = itemToPopout instanceof DockviewPanel
8453
- ? itemToPopout.group
8454
- : itemToPopout;
8452
+ const referenceGroup = (options === null || options === void 0 ? void 0 : options.referenceGroup)
8453
+ ? options.referenceGroup
8454
+ : itemToPopout instanceof DockviewPanel
8455
+ ? itemToPopout.group
8456
+ : itemToPopout;
8455
8457
  const referenceLocation = itemToPopout.api.location.type;
8456
8458
  /**
8457
8459
  * The group that is being added doesn't already exist within the DOM, the most likely occurance
@@ -8939,7 +8941,7 @@
8939
8941
  return result;
8940
8942
  }
8941
8943
  fromJSON(data) {
8942
- var _a, _b, _c;
8944
+ var _a, _b;
8943
8945
  this.clear();
8944
8946
  if (typeof data !== 'object' || data === null) {
8945
8947
  throw new Error('serialized layout must be a non-null object');
@@ -9011,12 +9013,11 @@
9011
9013
  for (const serializedPopoutGroup of serializedPopoutGroups) {
9012
9014
  const { data, position, gridReferenceGroup, url } = serializedPopoutGroup;
9013
9015
  const group = createGroupFromSerializedState(data);
9014
- this.addPopoutGroup((_c = (gridReferenceGroup
9015
- ? this.getPanel(gridReferenceGroup)
9016
- : undefined)) !== null && _c !== void 0 ? _c : group, {
9016
+ this.addPopoutGroup(group, {
9017
9017
  position: position !== null && position !== void 0 ? position : undefined,
9018
- overridePopoutGroup: gridReferenceGroup
9019
- ? group
9018
+ overridePopoutGroup: gridReferenceGroup ? group : undefined,
9019
+ referenceGroup: gridReferenceGroup
9020
+ ? this.getPanel(gridReferenceGroup)
9020
9021
  : undefined,
9021
9022
  popoutUrl: url,
9022
9023
  });