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
  */
@@ -645,9 +645,7 @@
645
645
  function shiftAbsoluteElementIntoView(element, root, options = { buffer: 10 }) {
646
646
  const buffer = options.buffer;
647
647
  const rect = element.getBoundingClientRect();
648
- const rootRect = element.getBoundingClientRect();
649
- const viewportWidth = root.clientWidth;
650
- const viewportHeight = root.clientHeight;
648
+ const rootRect = root.getBoundingClientRect();
651
649
  let translateX = 0;
652
650
  let translateY = 0;
653
651
  const left = rect.left - rootRect.left;
@@ -658,15 +656,15 @@
658
656
  if (left < buffer) {
659
657
  translateX = buffer - left;
660
658
  }
661
- else if (right > viewportWidth - buffer) {
662
- translateX = viewportWidth - right - buffer;
659
+ else if (right > buffer) {
660
+ translateX = -buffer - right;
663
661
  }
664
662
  // Check vertical overflow
665
663
  if (top < buffer) {
666
664
  translateY = buffer - top;
667
665
  }
668
- else if (bottom > viewportHeight - buffer) {
669
- translateY = viewportHeight - bottom - buffer;
666
+ else if (bottom > buffer) {
667
+ translateY = -bottom - buffer;
670
668
  }
671
669
  // Apply the translation if needed
672
670
  if (translateX !== 0 || translateY !== 0) {
@@ -3959,9 +3957,9 @@
3959
3957
  onDragOver: (e) => {
3960
3958
  var _a, _b, _c, _d, _e, _f, _g;
3961
3959
  Droptarget.ACTUAL_TARGET = this;
3962
- const overrideTraget = (_b = (_a = this.options).getOverrideTarget) === null || _b === void 0 ? void 0 : _b.call(_a);
3960
+ const overrideTarget = (_b = (_a = this.options).getOverrideTarget) === null || _b === void 0 ? void 0 : _b.call(_a);
3963
3961
  if (this._acceptedTargetZonesSet.size === 0) {
3964
- if (overrideTraget) {
3962
+ if (overrideTarget) {
3965
3963
  return;
3966
3964
  }
3967
3965
  this.removeDropTarget();
@@ -3988,7 +3986,7 @@
3988
3986
  return;
3989
3987
  }
3990
3988
  if (!this.options.canDisplayOverlay(e, quadrant)) {
3991
- if (overrideTraget) {
3989
+ if (overrideTarget) {
3992
3990
  return;
3993
3991
  }
3994
3992
  this.removeDropTarget();
@@ -4008,7 +4006,7 @@
4008
4006
  return;
4009
4007
  }
4010
4008
  this.markAsUsed(e);
4011
- if (overrideTraget) ;
4009
+ if (overrideTarget) ;
4012
4010
  else if (!this.targetElement) {
4013
4011
  this.targetElement = document.createElement('div');
4014
4012
  this.targetElement.className = 'dv-drop-target-dropzone';
@@ -4947,6 +4945,8 @@
4947
4945
  var _a, _b;
4948
4946
  // class dockview provides to force ghost image to be drawn on a different layer and prevent weird rendering issues
4949
4947
  addClasses(ghostElement, 'dv-dragged');
4948
+ // move the element off-screen initially otherwise it may in some cases be rendered at (0,0) momentarily
4949
+ ghostElement.style.top = '-9999px';
4950
4950
  document.body.appendChild(ghostElement);
4951
4951
  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);
4952
4952
  setTimeout(() => {
@@ -5115,7 +5115,7 @@
5115
5115
  this.accessor.doSetGroupActive(this.group);
5116
5116
  }));
5117
5117
  const handler = new GroupDragHandler(this._element, accessor, group);
5118
- this.dropTraget = new Droptarget(this._element, {
5118
+ this.dropTarget = new Droptarget(this._element, {
5119
5119
  acceptedTargetZones: ['center'],
5120
5120
  canDisplayOverlay: (event, position) => {
5121
5121
  const data = getPanelData();
@@ -5126,12 +5126,12 @@
5126
5126
  },
5127
5127
  getOverrideTarget: () => { var _a; return (_a = group.model.dropTargetContainer) === null || _a === void 0 ? void 0 : _a.model; },
5128
5128
  });
5129
- this.onWillShowOverlay = this.dropTraget.onWillShowOverlay;
5129
+ this.onWillShowOverlay = this.dropTarget.onWillShowOverlay;
5130
5130
  this.addDisposables(handler, handler.onDragStart((event) => {
5131
5131
  this._onDragStart.fire(event);
5132
- }), this.dropTraget.onDrop((event) => {
5132
+ }), this.dropTarget.onDrop((event) => {
5133
5133
  this._onDrop.fire(event);
5134
- }), this.dropTraget);
5134
+ }), this.dropTarget);
5135
5135
  }
5136
5136
  }
5137
5137
 
@@ -8419,9 +8419,11 @@
8419
8419
  const gready = document.createElement('div');
8420
8420
  gready.className = 'dv-overlay-render-container';
8421
8421
  const overlayRenderContainer = new OverlayRenderContainer(gready, this);
8422
- const referenceGroup = itemToPopout instanceof DockviewPanel
8423
- ? itemToPopout.group
8424
- : itemToPopout;
8422
+ const referenceGroup = (options === null || options === void 0 ? void 0 : options.referenceGroup)
8423
+ ? options.referenceGroup
8424
+ : itemToPopout instanceof DockviewPanel
8425
+ ? itemToPopout.group
8426
+ : itemToPopout;
8425
8427
  const referenceLocation = itemToPopout.api.location.type;
8426
8428
  /**
8427
8429
  * The group that is being added doesn't already exist within the DOM, the most likely occurance
@@ -8909,7 +8911,7 @@
8909
8911
  return result;
8910
8912
  }
8911
8913
  fromJSON(data) {
8912
- var _a, _b, _c;
8914
+ var _a, _b;
8913
8915
  this.clear();
8914
8916
  if (typeof data !== 'object' || data === null) {
8915
8917
  throw new Error('serialized layout must be a non-null object');
@@ -8981,12 +8983,11 @@
8981
8983
  for (const serializedPopoutGroup of serializedPopoutGroups) {
8982
8984
  const { data, position, gridReferenceGroup, url } = serializedPopoutGroup;
8983
8985
  const group = createGroupFromSerializedState(data);
8984
- this.addPopoutGroup((_c = (gridReferenceGroup
8985
- ? this.getPanel(gridReferenceGroup)
8986
- : undefined)) !== null && _c !== void 0 ? _c : group, {
8986
+ this.addPopoutGroup(group, {
8987
8987
  position: position !== null && position !== void 0 ? position : undefined,
8988
- overridePopoutGroup: gridReferenceGroup
8989
- ? group
8988
+ overridePopoutGroup: gridReferenceGroup ? group : undefined,
8989
+ referenceGroup: gridReferenceGroup
8990
+ ? this.getPanel(gridReferenceGroup)
8990
8991
  : undefined,
8991
8992
  popoutUrl: url,
8992
8993
  });