@gridsheet/preact-core 2.0.2 → 2.0.4

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,2 +1,6 @@
1
- export declare const FormulaBar: () => JSX.Element;
1
+ type FormulaBarProps = {
2
+ ready: boolean;
3
+ };
4
+ export declare const FormulaBar: ({ ready }: FormulaBarProps) => JSX.Element;
5
+ export {};
2
6
  //# sourceMappingURL=FormulaBar.d.ts.map
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({
@@ -10409,7 +10416,7 @@ const embedStyle = () => {
10409
10416
  style.setAttribute("data-modified-at", `${LAST_MODIFIED}`);
10410
10417
  style.innerText = CSS;
10411
10418
  };
10412
- const FormulaBar = () => {
10419
+ const FormulaBar = ({ ready }) => {
10413
10420
  var _a;
10414
10421
  const { store, dispatch } = useContext(Context);
10415
10422
  const [before, setBefore] = useState("");
@@ -10458,7 +10465,6 @@ const FormulaBar = () => {
10458
10465
  }, []);
10459
10466
  const largeInput = largeEditorRef.current;
10460
10467
  const handleInput = useCallback((e) => {
10461
- console.log("e.currentTarget.value", e.currentTarget.value);
10462
10468
  dispatch(setInputting(e.currentTarget.value));
10463
10469
  }, []);
10464
10470
  const updateScroll = useCallback(() => {
@@ -10550,14 +10556,15 @@ const FormulaBar = () => {
10550
10556
  },
10551
10557
  [table, choosing, before, writeCell, updateScroll]
10552
10558
  );
10559
+ const style = ready ? {} : { visibility: "hidden" };
10553
10560
  if (!table) {
10554
- return /* @__PURE__ */ jsxs("label", { className: "gs-formula-bar gs-hidden", children: [
10561
+ return /* @__PURE__ */ jsxs("label", { className: "gs-formula-bar gs-hidden", style, children: [
10555
10562
  /* @__PURE__ */ jsx("div", { className: "gs-selecting-address" }),
10556
10563
  /* @__PURE__ */ jsx("div", { className: "gs-fx", children: "Fx" }),
10557
10564
  /* @__PURE__ */ jsx("div", { className: "gs-formula-bar-editor-inner", children: /* @__PURE__ */ jsx("textarea", {}) })
10558
10565
  ] });
10559
10566
  }
10560
- return /* @__PURE__ */ jsxs("label", { className: "gs-formula-bar", children: [
10567
+ return /* @__PURE__ */ jsxs("label", { className: "gs-formula-bar", "data-sheet-id": store.sheetId, style, children: [
10561
10568
  /* @__PURE__ */ jsx(ScrollHandle, { style: { position: "absolute", left: 0, top: 0, zIndex: 2 }, vertical: -1 }),
10562
10569
  /* @__PURE__ */ jsx("div", { className: "gs-selecting-address", children: address }),
10563
10570
  /* @__PURE__ */ jsx("div", { className: "gs-fx", children: "Fx" }),
@@ -10845,7 +10852,7 @@ function GridSheet({
10845
10852
  /* @__PURE__ */ jsx(ScrollHandle, { style: { position: "fixed", top: 0, left: 0 } }),
10846
10853
  /* @__PURE__ */ jsx(ScrollHandle, { style: { position: "absolute", zIndex: 4, right: 0, top: 0, width: 5 }, horizontal: 1 }),
10847
10854
  /* @__PURE__ */ jsx(ScrollHandle, { style: { position: "absolute", zIndex: 4, left: 0, bottom: 0, height: 5 }, vertical: 1 }),
10848
- typeof store.searchQuery === "undefined" ? showFormulaBar && /* @__PURE__ */ jsx(FormulaBar, {}) : /* @__PURE__ */ jsx(SearchBar, {}),
10855
+ typeof store.searchQuery === "undefined" ? showFormulaBar && /* @__PURE__ */ jsx(FormulaBar, { ready: wire.ready }) : /* @__PURE__ */ jsx(SearchBar, {}),
10849
10856
  /* @__PURE__ */ jsxs(
10850
10857
  "div",
10851
10858
  {