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