@fileverse-dev/fortune-react 1.3.10-yjs-8 → 1.3.10-yjs-9

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.
@@ -143,10 +143,10 @@ var Workbook = /*#__PURE__*/React.forwardRef(function (_a, ref) {
143
143
  }
144
144
  }, [onOp]);
145
145
  var emitYjsFromPatches = useCallback(function (ctxBefore, ctxAfter, patches) {
146
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
147
- var _y = (_a = ctxBefore.hooks) !== null && _a !== void 0 ? _a : {},
148
- updateCellYdoc = _y.updateCellYdoc,
149
- updateAllCell = _y.updateAllCell;
146
+ var _a;
147
+ var _b = (_a = ctxBefore.hooks) !== null && _a !== void 0 ? _a : {},
148
+ updateCellYdoc = _b.updateCellYdoc,
149
+ updateAllCell = _b.updateAllCell;
150
150
  if (!updateCellYdoc) return;
151
151
  var mapFields = new Set(["celldata", "calcChain", "dataBlockCalcFunction", "liveQueryList", "dataVerification", "hyperlink", "conditionRules"]);
152
152
  var changeMap = new Map();
@@ -171,55 +171,55 @@ var Workbook = /*#__PURE__*/React.forwardRef(function (_a, ref) {
171
171
  type: cell == null ? "delete" : "update"
172
172
  });
173
173
  };
174
- for (var _i = 0, patches_1 = patches; _i < patches_1.length; _i++) {
175
- var p = patches_1[_i];
174
+ patches.forEach(function (p) {
175
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
176
176
  var path = p.path;
177
- if ((path === null || path === void 0 ? void 0 : path[0]) !== "luckysheetfile") continue;
177
+ if ((path === null || path === void 0 ? void 0 : path[0]) !== "luckysheetfile") return;
178
178
  var sheetIndex = path[1];
179
- if (!_.isNumber(sheetIndex)) continue;
180
- var sheetBefore = (_b = ctxBefore.luckysheetfile) === null || _b === void 0 ? void 0 : _b[sheetIndex];
181
- var sheetAfter = (_c = ctxAfter.luckysheetfile) === null || _c === void 0 ? void 0 : _c[sheetIndex];
179
+ if (!_.isNumber(sheetIndex)) return;
180
+ var sheetBefore = (_a = ctxBefore.luckysheetfile) === null || _a === void 0 ? void 0 : _a[sheetIndex];
181
+ var sheetAfter = (_b = ctxAfter.luckysheetfile) === null || _b === void 0 ? void 0 : _b[sheetIndex];
182
182
  var sheetId = (sheetAfter === null || sheetAfter === void 0 ? void 0 : sheetAfter.id) || (sheetBefore === null || sheetBefore === void 0 ? void 0 : sheetBefore.id);
183
- if (!sheetId) continue;
183
+ if (!sheetId) return;
184
184
  var root = path[2];
185
185
  if (root === "data") {
186
186
  if (_.isNumber(path[3]) && _.isNumber(path[4])) {
187
187
  upsertCell(sheetId, path[3], path[4]);
188
- continue;
188
+ return;
189
189
  }
190
190
  if (_.isNumber(path[3]) && path.length === 4) {
191
191
  var r = path[3];
192
- var beforeRow = (_e = (_d = sheetBefore === null || sheetBefore === void 0 ? void 0 : sheetBefore.data) === null || _d === void 0 ? void 0 : _d[r]) !== null && _e !== void 0 ? _e : [];
193
- var afterRow = (_g = (_f = sheetAfter === null || sheetAfter === void 0 ? void 0 : sheetAfter.data) === null || _f === void 0 ? void 0 : _f[r]) !== null && _g !== void 0 ? _g : [];
194
- var max = Math.max((_h = beforeRow.length) !== null && _h !== void 0 ? _h : 0, (_j = afterRow.length) !== null && _j !== void 0 ? _j : 0);
192
+ var beforeRow = (_d = (_c = sheetBefore === null || sheetBefore === void 0 ? void 0 : sheetBefore.data) === null || _c === void 0 ? void 0 : _c[r]) !== null && _d !== void 0 ? _d : [];
193
+ var afterRow = (_f = (_e = sheetAfter === null || sheetAfter === void 0 ? void 0 : sheetAfter.data) === null || _e === void 0 ? void 0 : _e[r]) !== null && _f !== void 0 ? _f : [];
194
+ var max = Math.max((_g = beforeRow.length) !== null && _g !== void 0 ? _g : 0, (_h = afterRow.length) !== null && _h !== void 0 ? _h : 0);
195
195
  for (var c = 0; c < max; c += 1) {
196
- if (!_.isEqual((_k = beforeRow[c]) !== null && _k !== void 0 ? _k : null, (_l = afterRow[c]) !== null && _l !== void 0 ? _l : null)) {
196
+ if (!_.isEqual((_j = beforeRow[c]) !== null && _j !== void 0 ? _j : null, (_k = afterRow[c]) !== null && _k !== void 0 ? _k : null)) {
197
197
  upsertCell(sheetId, r, c);
198
198
  }
199
199
  }
200
- continue;
200
+ return;
201
201
  }
202
202
  if (path.length === 3) {
203
203
  var dataAfter = sheetAfter === null || sheetAfter === void 0 ? void 0 : sheetAfter.data;
204
- var rows = (_m = dataAfter === null || dataAfter === void 0 ? void 0 : dataAfter.length) !== null && _m !== void 0 ? _m : 0;
205
- var cols = rows > 0 ? (_p = (_o = dataAfter === null || dataAfter === void 0 ? void 0 : dataAfter[0]) === null || _o === void 0 ? void 0 : _o.length) !== null && _p !== void 0 ? _p : 0 : 0;
204
+ var rows = (_l = dataAfter === null || dataAfter === void 0 ? void 0 : dataAfter.length) !== null && _l !== void 0 ? _l : 0;
205
+ var cols = rows > 0 ? (_o = (_m = dataAfter === null || dataAfter === void 0 ? void 0 : dataAfter[0]) === null || _m === void 0 ? void 0 : _m.length) !== null && _o !== void 0 ? _o : 0 : 0;
206
206
  var size = rows * cols;
207
207
  if (size > 50000 && updateAllCell) {
208
208
  updateAllCell(sheetId);
209
- continue;
209
+ return;
210
210
  }
211
211
  for (var r = 0; r < rows; r += 1) {
212
- var beforeRow = (_r = (_q = sheetBefore === null || sheetBefore === void 0 ? void 0 : sheetBefore.data) === null || _q === void 0 ? void 0 : _q[r]) !== null && _r !== void 0 ? _r : [];
213
- var afterRow = (_t = (_s = sheetAfter === null || sheetAfter === void 0 ? void 0 : sheetAfter.data) === null || _s === void 0 ? void 0 : _s[r]) !== null && _t !== void 0 ? _t : [];
214
- var max = Math.max((_u = beforeRow.length) !== null && _u !== void 0 ? _u : 0, (_v = afterRow.length) !== null && _v !== void 0 ? _v : 0);
212
+ var beforeRow = (_q = (_p = sheetBefore === null || sheetBefore === void 0 ? void 0 : sheetBefore.data) === null || _p === void 0 ? void 0 : _p[r]) !== null && _q !== void 0 ? _q : [];
213
+ var afterRow = (_s = (_r = sheetAfter === null || sheetAfter === void 0 ? void 0 : sheetAfter.data) === null || _r === void 0 ? void 0 : _r[r]) !== null && _s !== void 0 ? _s : [];
214
+ var max = Math.max((_t = beforeRow.length) !== null && _t !== void 0 ? _t : 0, (_u = afterRow.length) !== null && _u !== void 0 ? _u : 0);
215
215
  for (var c = 0; c < max; c += 1) {
216
- if (!_.isEqual((_w = beforeRow[c]) !== null && _w !== void 0 ? _w : null, (_x = afterRow[c]) !== null && _x !== void 0 ? _x : null)) {
216
+ if (!_.isEqual((_v = beforeRow[c]) !== null && _v !== void 0 ? _v : null, (_w = afterRow[c]) !== null && _w !== void 0 ? _w : null)) {
217
217
  upsertCell(sheetId, r, c);
218
218
  }
219
219
  }
220
220
  }
221
221
  }
222
- continue;
222
+ return;
223
223
  }
224
224
  if (typeof root === "string" && mapFields.has(root)) {
225
225
  var key = path[3];
@@ -233,7 +233,7 @@ var Workbook = /*#__PURE__*/React.forwardRef(function (_a, ref) {
233
233
  });
234
234
  }
235
235
  }
236
- }
236
+ });
237
237
  var changes = Array.from(changeMap.values());
238
238
  if (changes.length > 0) updateCellYdoc(changes);
239
239
  }, []);
@@ -450,18 +450,13 @@ var Workbook = /*#__PURE__*/React.forwardRef(function (_a, ref) {
450
450
  useEffect(function () {
451
451
  var _a, _b;
452
452
  setContext(function (ctx) {
453
- var _a, _b;
454
453
  var gridData = getFlowdata(ctx);
455
454
  var cellData = api.dataToCelldata(gridData);
456
- var denominatedUsed = false;
457
- for (var _i = 0, cellData_1 = cellData; _i < cellData_1.length; _i++) {
458
- var cell = cellData_1[_i];
455
+ var denominatedUsed = (cellData !== null && cellData !== void 0 ? cellData : []).some(function (cell) {
456
+ var _a, _b;
459
457
  var value = (_b = (_a = cell === null || cell === void 0 ? void 0 : cell.v) === null || _a === void 0 ? void 0 : _a.m) === null || _b === void 0 ? void 0 : _b.toString();
460
- if ((value === null || value === void 0 ? void 0 : value.includes("BTC")) || (value === null || value === void 0 ? void 0 : value.includes("ETH")) || (value === null || value === void 0 ? void 0 : value.includes("SOL"))) {
461
- denominatedUsed = true;
462
- break;
463
- }
464
- }
458
+ return (value === null || value === void 0 ? void 0 : value.includes("BTC")) || (value === null || value === void 0 ? void 0 : value.includes("ETH")) || (value === null || value === void 0 ? void 0 : value.includes("SOL"));
459
+ });
465
460
  var denoWarn = document.getElementById("denomination-warning");
466
461
  var scrollBar = document.getElementsByClassName("luckysheet-scrollbar-x")[0];
467
462
  if (denominatedUsed && denoWarn) {
@@ -152,10 +152,10 @@ var Workbook = /*#__PURE__*/_react.default.forwardRef(function (_a, ref) {
152
152
  }
153
153
  }, [onOp]);
154
154
  var emitYjsFromPatches = (0, _react.useCallback)(function (ctxBefore, ctxAfter, patches) {
155
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
156
- var _y = (_a = ctxBefore.hooks) !== null && _a !== void 0 ? _a : {},
157
- updateCellYdoc = _y.updateCellYdoc,
158
- updateAllCell = _y.updateAllCell;
155
+ var _a;
156
+ var _b = (_a = ctxBefore.hooks) !== null && _a !== void 0 ? _a : {},
157
+ updateCellYdoc = _b.updateCellYdoc,
158
+ updateAllCell = _b.updateAllCell;
159
159
  if (!updateCellYdoc) return;
160
160
  var mapFields = new Set(["celldata", "calcChain", "dataBlockCalcFunction", "liveQueryList", "dataVerification", "hyperlink", "conditionRules"]);
161
161
  var changeMap = new Map();
@@ -180,55 +180,55 @@ var Workbook = /*#__PURE__*/_react.default.forwardRef(function (_a, ref) {
180
180
  type: cell == null ? "delete" : "update"
181
181
  });
182
182
  };
183
- for (var _i = 0, patches_1 = patches; _i < patches_1.length; _i++) {
184
- var p = patches_1[_i];
183
+ patches.forEach(function (p) {
184
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
185
185
  var path = p.path;
186
- if ((path === null || path === void 0 ? void 0 : path[0]) !== "luckysheetfile") continue;
186
+ if ((path === null || path === void 0 ? void 0 : path[0]) !== "luckysheetfile") return;
187
187
  var sheetIndex = path[1];
188
- if (!_lodash.default.isNumber(sheetIndex)) continue;
189
- var sheetBefore = (_b = ctxBefore.luckysheetfile) === null || _b === void 0 ? void 0 : _b[sheetIndex];
190
- var sheetAfter = (_c = ctxAfter.luckysheetfile) === null || _c === void 0 ? void 0 : _c[sheetIndex];
188
+ if (!_lodash.default.isNumber(sheetIndex)) return;
189
+ var sheetBefore = (_a = ctxBefore.luckysheetfile) === null || _a === void 0 ? void 0 : _a[sheetIndex];
190
+ var sheetAfter = (_b = ctxAfter.luckysheetfile) === null || _b === void 0 ? void 0 : _b[sheetIndex];
191
191
  var sheetId = (sheetAfter === null || sheetAfter === void 0 ? void 0 : sheetAfter.id) || (sheetBefore === null || sheetBefore === void 0 ? void 0 : sheetBefore.id);
192
- if (!sheetId) continue;
192
+ if (!sheetId) return;
193
193
  var root = path[2];
194
194
  if (root === "data") {
195
195
  if (_lodash.default.isNumber(path[3]) && _lodash.default.isNumber(path[4])) {
196
196
  upsertCell(sheetId, path[3], path[4]);
197
- continue;
197
+ return;
198
198
  }
199
199
  if (_lodash.default.isNumber(path[3]) && path.length === 4) {
200
200
  var r = path[3];
201
- var beforeRow = (_e = (_d = sheetBefore === null || sheetBefore === void 0 ? void 0 : sheetBefore.data) === null || _d === void 0 ? void 0 : _d[r]) !== null && _e !== void 0 ? _e : [];
202
- var afterRow = (_g = (_f = sheetAfter === null || sheetAfter === void 0 ? void 0 : sheetAfter.data) === null || _f === void 0 ? void 0 : _f[r]) !== null && _g !== void 0 ? _g : [];
203
- var max = Math.max((_h = beforeRow.length) !== null && _h !== void 0 ? _h : 0, (_j = afterRow.length) !== null && _j !== void 0 ? _j : 0);
201
+ var beforeRow = (_d = (_c = sheetBefore === null || sheetBefore === void 0 ? void 0 : sheetBefore.data) === null || _c === void 0 ? void 0 : _c[r]) !== null && _d !== void 0 ? _d : [];
202
+ var afterRow = (_f = (_e = sheetAfter === null || sheetAfter === void 0 ? void 0 : sheetAfter.data) === null || _e === void 0 ? void 0 : _e[r]) !== null && _f !== void 0 ? _f : [];
203
+ var max = Math.max((_g = beforeRow.length) !== null && _g !== void 0 ? _g : 0, (_h = afterRow.length) !== null && _h !== void 0 ? _h : 0);
204
204
  for (var c = 0; c < max; c += 1) {
205
- if (!_lodash.default.isEqual((_k = beforeRow[c]) !== null && _k !== void 0 ? _k : null, (_l = afterRow[c]) !== null && _l !== void 0 ? _l : null)) {
205
+ if (!_lodash.default.isEqual((_j = beforeRow[c]) !== null && _j !== void 0 ? _j : null, (_k = afterRow[c]) !== null && _k !== void 0 ? _k : null)) {
206
206
  upsertCell(sheetId, r, c);
207
207
  }
208
208
  }
209
- continue;
209
+ return;
210
210
  }
211
211
  if (path.length === 3) {
212
212
  var dataAfter = sheetAfter === null || sheetAfter === void 0 ? void 0 : sheetAfter.data;
213
- var rows = (_m = dataAfter === null || dataAfter === void 0 ? void 0 : dataAfter.length) !== null && _m !== void 0 ? _m : 0;
214
- var cols = rows > 0 ? (_p = (_o = dataAfter === null || dataAfter === void 0 ? void 0 : dataAfter[0]) === null || _o === void 0 ? void 0 : _o.length) !== null && _p !== void 0 ? _p : 0 : 0;
213
+ var rows = (_l = dataAfter === null || dataAfter === void 0 ? void 0 : dataAfter.length) !== null && _l !== void 0 ? _l : 0;
214
+ var cols = rows > 0 ? (_o = (_m = dataAfter === null || dataAfter === void 0 ? void 0 : dataAfter[0]) === null || _m === void 0 ? void 0 : _m.length) !== null && _o !== void 0 ? _o : 0 : 0;
215
215
  var size = rows * cols;
216
216
  if (size > 50000 && updateAllCell) {
217
217
  updateAllCell(sheetId);
218
- continue;
218
+ return;
219
219
  }
220
220
  for (var r = 0; r < rows; r += 1) {
221
- var beforeRow = (_r = (_q = sheetBefore === null || sheetBefore === void 0 ? void 0 : sheetBefore.data) === null || _q === void 0 ? void 0 : _q[r]) !== null && _r !== void 0 ? _r : [];
222
- var afterRow = (_t = (_s = sheetAfter === null || sheetAfter === void 0 ? void 0 : sheetAfter.data) === null || _s === void 0 ? void 0 : _s[r]) !== null && _t !== void 0 ? _t : [];
223
- var max = Math.max((_u = beforeRow.length) !== null && _u !== void 0 ? _u : 0, (_v = afterRow.length) !== null && _v !== void 0 ? _v : 0);
221
+ var beforeRow = (_q = (_p = sheetBefore === null || sheetBefore === void 0 ? void 0 : sheetBefore.data) === null || _p === void 0 ? void 0 : _p[r]) !== null && _q !== void 0 ? _q : [];
222
+ var afterRow = (_s = (_r = sheetAfter === null || sheetAfter === void 0 ? void 0 : sheetAfter.data) === null || _r === void 0 ? void 0 : _r[r]) !== null && _s !== void 0 ? _s : [];
223
+ var max = Math.max((_t = beforeRow.length) !== null && _t !== void 0 ? _t : 0, (_u = afterRow.length) !== null && _u !== void 0 ? _u : 0);
224
224
  for (var c = 0; c < max; c += 1) {
225
- if (!_lodash.default.isEqual((_w = beforeRow[c]) !== null && _w !== void 0 ? _w : null, (_x = afterRow[c]) !== null && _x !== void 0 ? _x : null)) {
225
+ if (!_lodash.default.isEqual((_v = beforeRow[c]) !== null && _v !== void 0 ? _v : null, (_w = afterRow[c]) !== null && _w !== void 0 ? _w : null)) {
226
226
  upsertCell(sheetId, r, c);
227
227
  }
228
228
  }
229
229
  }
230
230
  }
231
- continue;
231
+ return;
232
232
  }
233
233
  if (typeof root === "string" && mapFields.has(root)) {
234
234
  var key = path[3];
@@ -242,7 +242,7 @@ var Workbook = /*#__PURE__*/_react.default.forwardRef(function (_a, ref) {
242
242
  });
243
243
  }
244
244
  }
245
- }
245
+ });
246
246
  var changes = Array.from(changeMap.values());
247
247
  if (changes.length > 0) updateCellYdoc(changes);
248
248
  }, []);
@@ -459,18 +459,13 @@ var Workbook = /*#__PURE__*/_react.default.forwardRef(function (_a, ref) {
459
459
  (0, _react.useEffect)(function () {
460
460
  var _a, _b;
461
461
  setContext(function (ctx) {
462
- var _a, _b;
463
462
  var gridData = (0, _fortuneCore.getFlowdata)(ctx);
464
463
  var cellData = _fortuneCore.api.dataToCelldata(gridData);
465
- var denominatedUsed = false;
466
- for (var _i = 0, cellData_1 = cellData; _i < cellData_1.length; _i++) {
467
- var cell = cellData_1[_i];
464
+ var denominatedUsed = (cellData !== null && cellData !== void 0 ? cellData : []).some(function (cell) {
465
+ var _a, _b;
468
466
  var value = (_b = (_a = cell === null || cell === void 0 ? void 0 : cell.v) === null || _a === void 0 ? void 0 : _a.m) === null || _b === void 0 ? void 0 : _b.toString();
469
- if ((value === null || value === void 0 ? void 0 : value.includes("BTC")) || (value === null || value === void 0 ? void 0 : value.includes("ETH")) || (value === null || value === void 0 ? void 0 : value.includes("SOL"))) {
470
- denominatedUsed = true;
471
- break;
472
- }
473
- }
467
+ return (value === null || value === void 0 ? void 0 : value.includes("BTC")) || (value === null || value === void 0 ? void 0 : value.includes("ETH")) || (value === null || value === void 0 ? void 0 : value.includes("SOL"));
468
+ });
474
469
  var denoWarn = document.getElementById("denomination-warning");
475
470
  var scrollBar = document.getElementsByClassName("luckysheet-scrollbar-x")[0];
476
471
  if (denominatedUsed && denoWarn) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fileverse-dev/fortune-react",
3
- "version": "1.3.10-yjs-8",
3
+ "version": "1.3.10-yjs-9",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "module": "es/index.js",
@@ -16,7 +16,7 @@
16
16
  "tsc": "tsc"
17
17
  },
18
18
  "dependencies": {
19
- "@fileverse-dev/fortune-core": "1.3.10-yjs-8",
19
+ "@fileverse-dev/fortune-core": "1.3.10-yjs-9",
20
20
  "@fileverse/ui": "5.0.0",
21
21
  "@tippyjs/react": "^4.2.6",
22
22
  "@types/regenerator-runtime": "^0.13.6",