@gridsheet/react-core 2.0.2 → 2.0.3

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.
package/dist/index.js CHANGED
@@ -255,15 +255,17 @@ const putMatrix = (dst, src, dstArea, filter = () => true) => {
255
255
  for (let y = top; y <= bottom; y++) {
256
256
  const lostRow = [];
257
257
  for (let x = left; x <= right; x++) {
258
+ const srcPoint = { y: y - top, x: x - left };
259
+ const dstPoint = { y, x };
258
260
  const value = src[y - top][x - left];
259
261
  if (y < dstNumRows - 1 && x < dstNumCols - 1) {
260
- if (filter(value, dst[y][x], { y, x })) {
262
+ if (filter({ srcValue: value, dstValue: dst[y][x], srcPoint, dstPoint })) {
261
263
  dst[y][x] = value;
262
264
  }
263
265
  continue;
264
266
  }
265
267
  if (lostRow.length === 0) {
266
- lostRows[p2a({ y, x })] = [lostRow];
268
+ lostRows[p2a(dstPoint)] = [lostRow];
267
269
  }
268
270
  lostRow.push(value);
269
271
  }
@@ -8344,7 +8346,7 @@ class Table {
8344
8346
  const matrixTo = this.getIdMatrixFromArea(dst);
8345
8347
  const diffBefore = {};
8346
8348
  const preserver = new ReferencePreserver(this);
8347
- const lostRows = putMatrix(this.idMatrix, matrixFrom, dst, (srcId, dstId, point) => {
8349
+ const lostRows = putMatrix(this.idMatrix, matrixFrom, dst, ({ srcValue: srcId, dstValue: dstId }) => {
8348
8350
  var _a;
8349
8351
  if (srcId == null || dstId == null) {
8350
8352
  return false;
@@ -8384,8 +8386,11 @@ class Table {
8384
8386
  });
8385
8387
  const srcTableRaw = srcTable.__raw__;
8386
8388
  const srcContext = this.wire.contextsBySheetId[srcTableRaw.sheetId];
8387
- putMatrix(srcTableRaw.idMatrix, matrixNew, src, (newId, srcId) => {
8389
+ putMatrix(srcTableRaw.idMatrix, matrixNew, src, ({ srcValue: newId, dstValue: srcId, dstPoint: srcPoint }) => {
8388
8390
  var _a;
8391
+ if (among(dst, srcPoint) && srcTable === this) {
8392
+ return false;
8393
+ }
8389
8394
  preserver.map[srcId] = newId;
8390
8395
  const srcCell = srcTableRaw.wire.data[srcId];
8391
8396
  if (operator === "USER" && hasOperation(srcCell == null ? void 0 : srcCell.prevention, MoveFrom)) {
@@ -8415,7 +8420,9 @@ class Table {
8415
8420
  Object.assign(diffBefore, resolvedDiff);
8416
8421
  if (srcTable !== this && srcContext !== null) {
8417
8422
  const { dispatch } = srcContext;
8418
- dispatch(updateTable(srcTableRaw));
8423
+ requestAnimationFrame(() => {
8424
+ dispatch(updateTable(srcTableRaw));
8425
+ });
8419
8426
  }
8420
8427
  if (historicize) {
8421
8428
  this.pushHistory({