@fileverse-dev/fortune-react 1.3.10 → 1.3.11-mixed

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.
Files changed (27) hide show
  1. package/es/components/ConditionFormat/ConditionRules.js +15 -5
  2. package/es/components/ConditionFormat/index.js +3 -0
  3. package/es/components/DataVerification/ColorPicker.js +1 -1
  4. package/es/components/SheetOverlay/InputBox.js +112 -75
  5. package/es/components/SheetOverlay/drag_and_drop/column-helpers.js +25 -1
  6. package/es/components/SheetOverlay/drag_and_drop/row-helpers.js +26 -2
  7. package/es/components/SheetOverlay/index.css +6 -0
  8. package/es/components/SheetOverlay/index.js +3 -3
  9. package/es/components/Toolbar/index.js +17 -12
  10. package/es/components/Workbook/api.d.ts +3 -0
  11. package/es/components/Workbook/index.d.ts +3 -0
  12. package/es/components/Workbook/index.js +146 -10
  13. package/es/utils/convertCellsToCrypto.js +17 -0
  14. package/lib/components/ConditionFormat/ConditionRules.js +15 -5
  15. package/lib/components/ConditionFormat/index.js +3 -0
  16. package/lib/components/DataVerification/ColorPicker.js +1 -1
  17. package/lib/components/SheetOverlay/InputBox.js +111 -74
  18. package/lib/components/SheetOverlay/drag_and_drop/column-helpers.js +25 -1
  19. package/lib/components/SheetOverlay/drag_and_drop/row-helpers.js +26 -2
  20. package/lib/components/SheetOverlay/index.css +6 -0
  21. package/lib/components/SheetOverlay/index.js +3 -3
  22. package/lib/components/Toolbar/index.js +16 -11
  23. package/lib/components/Workbook/api.d.ts +3 -0
  24. package/lib/components/Workbook/index.d.ts +3 -0
  25. package/lib/components/Workbook/index.js +146 -10
  26. package/lib/utils/convertCellsToCrypto.js +17 -0
  27. package/package.json +2 -2
@@ -219,7 +219,7 @@ var useColumnDragAndDrop = exports.useColumnDragAndDrop = function useColumnDrag
219
219
  var sheetIdx_1 = (0, _fortuneCore.getSheetIndex)(context, context.currentSheetId);
220
220
  if (sheetIdx_1 != null && sourceIndex_1 >= 0 && Number.isFinite(finalInsertionIndex_1) && finalInsertionIndex_1 >= 0) {
221
221
  setContext(function (draft) {
222
- var _a, _b, _c, _d, _e, _f, _g;
222
+ var _a, _b, _c, _d, _e, _f, _g, _h;
223
223
  var _sheet = draft.luckysheetfile[sheetIdx_1];
224
224
  if (!(_sheet === null || _sheet === void 0 ? void 0 : _sheet.data)) return;
225
225
  var rows = _sheet.data;
@@ -382,6 +382,30 @@ var useColumnDragAndDrop = exports.useColumnDragAndDrop = function useColumnDrag
382
382
  }
383
383
  });
384
384
  (_g = window === null || window === void 0 ? void 0 : window.updateDataBlockCalcFunctionAfterRowDrag) === null || _g === void 0 ? void 0 : _g.call(window, selectedSourceCol, selectedTargetCol, "column", context.currentSheetId, sourceIndex_1, targetIndex);
385
+ var cellChanges = [];
386
+ var affectedColStart = Math.min(sourceIndex_1, targetIndex);
387
+ var affectedColEnd = Math.max(sourceIndex_1, targetIndex) + selectedSourceCol.length - 1;
388
+ var numRows = rows.length;
389
+ for (var r = 0; r < numRows; r += 1) {
390
+ var row = rows[r];
391
+ for (var c = affectedColStart; c <= affectedColEnd; c += 1) {
392
+ var cell = row === null || row === void 0 ? void 0 : row[c];
393
+ cellChanges.push({
394
+ sheetId: draft.currentSheetId,
395
+ path: ["celldata"],
396
+ value: {
397
+ r: r,
398
+ c: c,
399
+ v: cell !== null && cell !== void 0 ? cell : null
400
+ },
401
+ key: "".concat(r, "_").concat(c),
402
+ type: "update"
403
+ });
404
+ }
405
+ }
406
+ if (cellChanges.length > 0 && ((_h = draft.hooks) === null || _h === void 0 ? void 0 : _h.updateCellYdoc)) {
407
+ draft.hooks.updateCellYdoc(cellChanges);
408
+ }
385
409
  var rowLen = (d === null || d === void 0 ? void 0 : d.length) || 0;
386
410
  _fortuneCore.api.setSelection(draft, [{
387
411
  row: [0, rowLen],
@@ -214,7 +214,7 @@ var useRowDragAndDrop = exports.useRowDragAndDrop = function useRowDragAndDrop(c
214
214
  var sheetIdx_1 = (0, _fortuneCore.getSheetIndex)(context, context.currentSheetId);
215
215
  if (sheetIdx_1 != null && sourceIndex_1 >= 0 && Number.isFinite(finalInsertionIndex_1) && finalInsertionIndex_1 >= 0) {
216
216
  setContext(function (draft) {
217
- var _a, _b, _c, _d, _e, _f;
217
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
218
218
  var _sheet = draft.luckysheetfile[sheetIdx_1];
219
219
  if (!(_sheet === null || _sheet === void 0 ? void 0 : _sheet.data)) return;
220
220
  var rows = _sheet.data;
@@ -371,7 +371,31 @@ var useRowDragAndDrop = exports.useRowDragAndDrop = function useRowDragAndDrop(c
371
371
  }
372
372
  });
373
373
  (_e = window === null || window === void 0 ? void 0 : window.updateDataBlockCalcFunctionAfterRowDrag) === null || _e === void 0 ? void 0 : _e.call(window, sourceIndex_1, targetIndex, "row", context.currentSheetId);
374
- var colLen = ((_f = d === null || d === void 0 ? void 0 : d[0]) === null || _f === void 0 ? void 0 : _f.length) || 0;
374
+ var cellChanges = [];
375
+ var affectedRowStart = Math.min(sourceIndex_1, targetIndex);
376
+ var affectedRowEnd = Math.max(sourceIndex_1, targetIndex) + selectedSourceRow.length - 1;
377
+ var numCols = (_g = (_f = d === null || d === void 0 ? void 0 : d[0]) === null || _f === void 0 ? void 0 : _f.length) !== null && _g !== void 0 ? _g : 0;
378
+ for (var r = affectedRowStart; r <= affectedRowEnd; r += 1) {
379
+ var row = rows[r];
380
+ for (var c = 0; c < numCols; c += 1) {
381
+ var cell = row === null || row === void 0 ? void 0 : row[c];
382
+ cellChanges.push({
383
+ sheetId: draft.currentSheetId,
384
+ path: ["celldata"],
385
+ value: {
386
+ r: r,
387
+ c: c,
388
+ v: cell !== null && cell !== void 0 ? cell : null
389
+ },
390
+ key: "".concat(r, "_").concat(c),
391
+ type: "update"
392
+ });
393
+ }
394
+ }
395
+ if (cellChanges.length > 0 && ((_h = draft.hooks) === null || _h === void 0 ? void 0 : _h.updateCellYdoc)) {
396
+ draft.hooks.updateCellYdoc(cellChanges);
397
+ }
398
+ var colLen = ((_j = d === null || d === void 0 ? void 0 : d[0]) === null || _j === void 0 ? void 0 : _j.length) || 0;
375
399
  _fortuneCore.api.setSelection(draft, [{
376
400
  row: [selectedTargetRow[0], selectedTargetRow[selectedTargetRow.length - 1]],
377
401
  column: [0, colLen]
@@ -830,6 +830,12 @@
830
830
  cursor: se-resize;
831
831
  }
832
832
 
833
+ /* FLV: show blue dashed border for active selection while in edit mode */
834
+ .luckysheet-cell-selected-edit-mode .luckysheet-cs-inner-border {
835
+ border: 2px dashed #12a5ff;
836
+ border-radius: 1px;
837
+ }
838
+
833
839
  .fortune-formula-functionrange-highlight .luckysheet-highlight {
834
840
  position: absolute;
835
841
  z-index: 19;
@@ -384,18 +384,18 @@ var SheetOverlay = function SheetOverlay() {
384
384
  }), ((_h = (_g = context.luckysheet_select_save) === null || _g === void 0 ? void 0 : _g.length) !== null && _h !== void 0 ? _h : 0) > 0 && (/*#__PURE__*/_react.default.createElement("div", {
385
385
  id: "luckysheet-cell-selected-boxs"
386
386
  }, context.luckysheet_select_save.map(function (selection, index) {
387
- var _a, _b;
387
+ var _a, _b, _c, _d;
388
388
  return /*#__PURE__*/_react.default.createElement("div", {
389
389
  key: index,
390
390
  id: "luckysheet-cell-selected",
391
- className: "luckysheet-cell-selected",
391
+ className: "luckysheet-cell-selected".concat(((_b = (_a = context.luckysheetCellUpdate) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) > 0 ? " luckysheet-cell-selected-edit-mode" : ""),
392
392
  style: _lodash.default.assign({
393
393
  left: selection.left_move,
394
394
  top: selection.top_move,
395
395
  width: selection.width_move ? selection.width_move - 1.8 : selection.width_move,
396
396
  height: selection.height_move ? selection.height_move - 1.8 : selection.height_move,
397
397
  display: "block"
398
- }, (0, _fortuneCore.fixRowStyleOverflowInFreeze)(context, selection.row[0], selection.row[1], (_a = refs.globalCache.freezen) === null || _a === void 0 ? void 0 : _a[context.currentSheetId]), (0, _fortuneCore.fixColumnStyleOverflowInFreeze)(context, selection.column[0], selection.column[1], (_b = refs.globalCache.freezen) === null || _b === void 0 ? void 0 : _b[context.currentSheetId])),
398
+ }, (0, _fortuneCore.fixRowStyleOverflowInFreeze)(context, selection.row[0], selection.row[1], (_c = refs.globalCache.freezen) === null || _c === void 0 ? void 0 : _c[context.currentSheetId]), (0, _fortuneCore.fixColumnStyleOverflowInFreeze)(context, selection.column[0], selection.column[1], (_d = refs.globalCache.freezen) === null || _d === void 0 ? void 0 : _d[context.currentSheetId])),
399
399
  onMouseDown: function onMouseDown(e) {
400
400
  e.stopPropagation();
401
401
  var nativeEvent = e.nativeEvent;
@@ -658,7 +658,7 @@ var Toolbar = function Toolbar(_a) {
658
658
  }
659
659
  }, [cell, refs.globalCache]);
660
660
  var getToolbarItem = (0, _react.useCallback)(function (name, i) {
661
- var _a, _b, _c, _d, _e, _f, _g;
661
+ var _a, _b, _c, _d, _e, _f;
662
662
  var tooltip = toolbar[name];
663
663
  if (name === "|") {
664
664
  return /*#__PURE__*/_react.default.createElement(_Divider.default, {
@@ -723,10 +723,15 @@ var Toolbar = function Toolbar(_a) {
723
723
  return v.value === (curr_2 === null || curr_2 === void 0 ? void 0 : curr_2.fa);
724
724
  });
725
725
  if ((curr_2 === null || curr_2 === void 0 ? void 0 : curr_2.fa) != null) {
726
- if (format != null) {
727
- currentFmt_1 = format.text;
728
- } else if (((_a = curr_2 === null || curr_2 === void 0 ? void 0 : curr_2.fa) === null || _a === void 0 ? void 0 : _a.includes("#,##0")) || (curr_2 === null || curr_2 === void 0 ? void 0 : curr_2.fa) === "0" || (curr_2 === null || curr_2 === void 0 ? void 0 : curr_2.fa) === "0.00") {
726
+ var hasTime = /[hH]:/.test(curr_2.fa);
727
+ if (curr_2.t === "d") {
728
+ currentFmt_1 = hasTime ? "Date time" : "Date";
729
+ } else if (curr_2.t === "n" || curr_2.fa.includes("#,##0") || curr_2.fa === "0" || curr_2.fa === "0.00") {
729
730
  currentFmt_1 = "Number";
731
+ } else if ((0, _fortuneCore.is_date)(curr_2.fa)) {
732
+ currentFmt_1 = hasTime ? "Date time" : "Date";
733
+ } else if (format != null) {
734
+ currentFmt_1 = format.text;
730
735
  } else {
731
736
  currentFmt_1 = defaultFormat[defaultFormat.length - 1].text;
732
737
  }
@@ -881,9 +886,9 @@ var Toolbar = function Toolbar(_a) {
881
886
  value: 2
882
887
  }];
883
888
  return /*#__PURE__*/_react.default.createElement(_Combo.default, {
884
- iconId: ((_b = _lodash.default.find(items_1, function (item) {
889
+ iconId: ((_a = _lodash.default.find(items_1, function (item) {
885
890
  return "".concat(item.value) === "".concat(cell === null || cell === void 0 ? void 0 : cell.ht);
886
- })) === null || _b === void 0 ? void 0 : _b.title) || "align-left",
891
+ })) === null || _a === void 0 ? void 0 : _a.title) || "align-left",
887
892
  key: name,
888
893
  tooltip: toolbar.horizontalAlign,
889
894
  showArrow: false
@@ -933,9 +938,9 @@ var Toolbar = function Toolbar(_a) {
933
938
  value: 2
934
939
  }];
935
940
  return /*#__PURE__*/_react.default.createElement(_Combo.default, {
936
- iconId: ((_c = _lodash.default.find(items_2, function (item) {
941
+ iconId: ((_b = _lodash.default.find(items_2, function (item) {
937
942
  return "".concat(item.value) === "".concat(cell === null || cell === void 0 ? void 0 : cell.vt);
938
- })) === null || _c === void 0 ? void 0 : _c.title) || "align-top",
943
+ })) === null || _b === void 0 ? void 0 : _b.title) || "align-top",
939
944
  key: name,
940
945
  tooltip: toolbar.verticalAlign,
941
946
  showArrow: false
@@ -1176,7 +1181,7 @@ var Toolbar = function Toolbar(_a) {
1176
1181
  });
1177
1182
  }
1178
1183
  if (name === "comment") {
1179
- var last = (_d = context.luckysheet_select_save) === null || _d === void 0 ? void 0 : _d[context.luckysheet_select_save.length - 1];
1184
+ var last = (_c = context.luckysheet_select_save) === null || _c === void 0 ? void 0 : _c[context.luckysheet_select_save.length - 1];
1180
1185
  var row_index_1 = last === null || last === void 0 ? void 0 : last.row_focus;
1181
1186
  var col_index_1 = last === null || last === void 0 ? void 0 : last.column_focus;
1182
1187
  if (!last) {
@@ -1191,7 +1196,7 @@ var Toolbar = function Toolbar(_a) {
1191
1196
  }
1192
1197
  }
1193
1198
  var itemData_1;
1194
- if (((_f = (_e = flowdata === null || flowdata === void 0 ? void 0 : flowdata[row_index_1]) === null || _e === void 0 ? void 0 : _e[col_index_1]) === null || _f === void 0 ? void 0 : _f.ps) != null) {
1199
+ if (((_e = (_d = flowdata === null || flowdata === void 0 ? void 0 : flowdata[row_index_1]) === null || _d === void 0 ? void 0 : _d[col_index_1]) === null || _e === void 0 ? void 0 : _e.ps) != null) {
1195
1200
  itemData_1 = [{
1196
1201
  key: "edit",
1197
1202
  text: comment.edit,
@@ -1704,7 +1709,7 @@ var Toolbar = function Toolbar(_a) {
1704
1709
  iconId: name,
1705
1710
  tooltip: tooltip,
1706
1711
  key: name,
1707
- selected: (_g = (0, _fortuneCore.toolbarItemSelectedFunc)(name)) === null || _g === void 0 ? void 0 : _g(cell),
1712
+ selected: (_f = (0, _fortuneCore.toolbarItemSelectedFunc)(name)) === null || _f === void 0 ? void 0 : _f(cell),
1708
1713
  onClick: function onClick() {
1709
1714
  return setContext(function (draftCtx) {
1710
1715
  var _a;
@@ -728,6 +728,8 @@ export declare function generateAPIs(context: Context, setContext: (recipe: (ctx
728
728
  conditionformat_equal_title: string;
729
729
  conditionformat_textContains: string;
730
730
  conditionformat_textContains_title: string;
731
+ conditionformat_empty: string;
732
+ conditionformat_empty_title: string;
731
733
  conditionformat_occurrenceDate: string;
732
734
  conditionformat_occurrenceDate_title: string;
733
735
  conditionformat_duplicateValue: string;
@@ -830,6 +832,7 @@ export declare function generateAPIs(context: Context, setContext: (recipe: (ctx
830
832
  between2: string;
831
833
  contain: string;
832
834
  textContains: string;
835
+ empty: string;
833
836
  duplicateValue: string;
834
837
  uniqueValue: string;
835
838
  top: string;
@@ -735,6 +735,8 @@ declare const Workbook: React.ForwardRefExoticComponent<Settings & AdditionalPro
735
735
  conditionformat_equal_title: string;
736
736
  conditionformat_textContains: string;
737
737
  conditionformat_textContains_title: string;
738
+ conditionformat_empty: string;
739
+ conditionformat_empty_title: string;
738
740
  conditionformat_occurrenceDate: string;
739
741
  conditionformat_occurrenceDate_title: string;
740
742
  conditionformat_duplicateValue: string;
@@ -837,6 +839,7 @@ declare const Workbook: React.ForwardRefExoticComponent<Settings & AdditionalPro
837
839
  between2: string;
838
840
  contain: string;
839
841
  textContains: string;
842
+ empty: string;
840
843
  duplicateValue: string;
841
844
  uniqueValue: string;
842
845
  top: string;
@@ -25,7 +25,7 @@ var _FilterMenu = _interopRequireDefault(require("../ContextMenu/FilterMenu"));
25
25
  var _SheetList = _interopRequireDefault(require("../SheetList"));
26
26
  var _DunePreview = _interopRequireDefault(require("../DunePreview/DunePreview"));
27
27
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
28
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
28
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t2 in e) "default" !== _t2 && {}.hasOwnProperty.call(e, _t2) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t2)) && (i.get || i.set) ? o(f, _t2, i) : f[_t2] = e[_t2]); return f; })(e, t); }
29
29
  var __assign = void 0 && (void 0).__assign || function () {
30
30
  __assign = Object.assign || function (t) {
31
31
  for (var s, i = 1, n = arguments.length; i < n; i++) {
@@ -133,6 +133,12 @@ var Workbook = /*#__PURE__*/_react.default.forwardRef(function (_a, ref) {
133
133
  });
134
134
  celldata === null || celldata === void 0 ? void 0 : celldata.forEach(function (d) {
135
135
  expandedData_1[d.r][d.c] = d.v;
136
+ var cell = d.v;
137
+ if (cell && cell.ct && cell.ct.t === "d" && (cell.m === undefined || cell.m === null)) {
138
+ try {
139
+ cell.m = (0, _fortuneCore.update)(cell.ct.fa || "General", cell.v);
140
+ } catch (e) {}
141
+ }
136
142
  });
137
143
  draftCtx.luckysheetfile = (0, _immer.default)(draftCtx.luckysheetfile, function (d) {
138
144
  d[index].data = expandedData_1;
@@ -151,6 +157,101 @@ var Workbook = /*#__PURE__*/_react.default.forwardRef(function (_a, ref) {
151
157
  onOp((0, _fortuneCore.patchToOp)(ctx, patches, options, undo));
152
158
  }
153
159
  }, [onOp]);
160
+ var emitYjsFromPatches = (0, _react.useCallback)(function (ctxBefore, ctxAfter, patches) {
161
+ var _a;
162
+ var _b = (_a = ctxBefore.hooks) !== null && _a !== void 0 ? _a : {},
163
+ updateCellYdoc = _b.updateCellYdoc,
164
+ updateAllCell = _b.updateAllCell;
165
+ if (!updateCellYdoc) return;
166
+ var mapFields = new Set(["celldata", "calcChain", "dataBlockCalcFunction", "liveQueryList", "dataVerification", "hyperlink", "conditionRules"]);
167
+ var changeMap = new Map();
168
+ var upsert = function upsert(change) {
169
+ var _a, _b, _c;
170
+ var k = "".concat(change.sheetId, ":").concat((_b = (_a = change.path) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : "", ":").concat((_c = change.key) !== null && _c !== void 0 ? _c : "");
171
+ changeMap.set(k, change);
172
+ };
173
+ var upsertCell = function upsertCell(sheetId, r, c) {
174
+ var _a, _b, _c;
175
+ var cell = (_c = (_b = (_a = (0, _fortuneCore.getFlowdata)(ctxAfter, sheetId)) === null || _a === void 0 ? void 0 : _a[r]) === null || _b === void 0 ? void 0 : _b[c]) !== null && _c !== void 0 ? _c : null;
176
+ var key = "".concat(r, "_").concat(c);
177
+ upsert({
178
+ sheetId: sheetId,
179
+ path: ["celldata"],
180
+ key: key,
181
+ value: {
182
+ r: r,
183
+ c: c,
184
+ v: cell
185
+ },
186
+ type: cell == null ? "delete" : "update"
187
+ });
188
+ };
189
+ patches.forEach(function (p) {
190
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
191
+ var path = p.path;
192
+ if ((path === null || path === void 0 ? void 0 : path[0]) !== "luckysheetfile") return;
193
+ var sheetIndex = path[1];
194
+ if (!_lodash.default.isNumber(sheetIndex)) return;
195
+ var sheetBefore = (_a = ctxBefore.luckysheetfile) === null || _a === void 0 ? void 0 : _a[sheetIndex];
196
+ var sheetAfter = (_b = ctxAfter.luckysheetfile) === null || _b === void 0 ? void 0 : _b[sheetIndex];
197
+ var sheetId = (sheetAfter === null || sheetAfter === void 0 ? void 0 : sheetAfter.id) || (sheetBefore === null || sheetBefore === void 0 ? void 0 : sheetBefore.id);
198
+ if (!sheetId) return;
199
+ var root = path[2];
200
+ if (root === "data") {
201
+ if (_lodash.default.isNumber(path[3]) && _lodash.default.isNumber(path[4])) {
202
+ upsertCell(sheetId, path[3], path[4]);
203
+ return;
204
+ }
205
+ if (_lodash.default.isNumber(path[3]) && path.length === 4) {
206
+ var r = path[3];
207
+ 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 : [];
208
+ 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 : [];
209
+ var max = Math.max((_g = beforeRow.length) !== null && _g !== void 0 ? _g : 0, (_h = afterRow.length) !== null && _h !== void 0 ? _h : 0);
210
+ for (var c = 0; c < max; c += 1) {
211
+ if (!_lodash.default.isEqual((_j = beforeRow[c]) !== null && _j !== void 0 ? _j : null, (_k = afterRow[c]) !== null && _k !== void 0 ? _k : null)) {
212
+ upsertCell(sheetId, r, c);
213
+ }
214
+ }
215
+ return;
216
+ }
217
+ if (path.length === 3) {
218
+ var dataAfter = sheetAfter === null || sheetAfter === void 0 ? void 0 : sheetAfter.data;
219
+ var rows = (_l = dataAfter === null || dataAfter === void 0 ? void 0 : dataAfter.length) !== null && _l !== void 0 ? _l : 0;
220
+ 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;
221
+ var size = rows * cols;
222
+ if (size > 50000 && updateAllCell) {
223
+ updateAllCell(sheetId);
224
+ return;
225
+ }
226
+ for (var r = 0; r < rows; r += 1) {
227
+ 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 : [];
228
+ 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 : [];
229
+ var max = Math.max((_t = beforeRow.length) !== null && _t !== void 0 ? _t : 0, (_u = afterRow.length) !== null && _u !== void 0 ? _u : 0);
230
+ for (var c = 0; c < max; c += 1) {
231
+ if (!_lodash.default.isEqual((_v = beforeRow[c]) !== null && _v !== void 0 ? _v : null, (_w = afterRow[c]) !== null && _w !== void 0 ? _w : null)) {
232
+ upsertCell(sheetId, r, c);
233
+ }
234
+ }
235
+ }
236
+ }
237
+ return;
238
+ }
239
+ if (typeof root === "string" && mapFields.has(root)) {
240
+ var key = path[3];
241
+ if (typeof key === "string") {
242
+ upsert({
243
+ sheetId: sheetId,
244
+ path: [root],
245
+ key: key,
246
+ value: p.value,
247
+ type: p.op === "remove" || p.value == null ? "delete" : "update"
248
+ });
249
+ }
250
+ }
251
+ });
252
+ var changes = Array.from(changeMap.values());
253
+ if (changes.length > 0) updateCellYdoc(changes);
254
+ }, []);
154
255
  function reduceUndoList(ctx, ctxBefore) {
155
256
  var sheetsId = ctx.luckysheetfile.map(function (sheet) {
156
257
  return sheet.id;
@@ -308,6 +409,7 @@ var Workbook = /*#__PURE__*/_react.default.forwardRef(function (_a, ref) {
308
409
  delete inversedOptions.addSheet.value.data;
309
410
  }
310
411
  emitOp(newContext, history.inversePatches, inversedOptions, true);
412
+ emitYjsFromPatches(ctx_, newContext, history.inversePatches);
311
413
  var sheetIdxAfterUndo = (0, _fortuneCore.getSheetIndex)(newContext, newContext.currentSheetId);
312
414
  var nw = __assign(__assign({}, newContext), sheetIdxAfterUndo != null && ((_f = newContext.luckysheetfile[sheetIdxAfterUndo]) === null || _f === void 0 ? void 0 : _f.config) != null ? {
313
415
  config: newContext.luckysheetfile[sheetIdxAfterUndo].config
@@ -336,6 +438,7 @@ var Workbook = /*#__PURE__*/_react.default.forwardRef(function (_a, ref) {
336
438
  });
337
439
  globalCache.current.undoList.push(history);
338
440
  emitOp(newContext, history.patches, history.options);
441
+ emitYjsFromPatches(ctx_, newContext, history.patches);
339
442
  var sheetIdxAfterRedo = (0, _fortuneCore.getSheetIndex)(newContext, newContext.currentSheetId);
340
443
  var nw = __assign(__assign({}, newContext), sheetIdxAfterRedo != null && ((_a = newContext.luckysheetfile[sheetIdxAfterRedo]) === null || _a === void 0 ? void 0 : _a.config) != null ? {
341
444
  config: newContext.luckysheetfile[sheetIdxAfterRedo].config
@@ -362,18 +465,13 @@ var Workbook = /*#__PURE__*/_react.default.forwardRef(function (_a, ref) {
362
465
  (0, _react.useEffect)(function () {
363
466
  var _a, _b;
364
467
  setContext(function (ctx) {
365
- var _a, _b;
366
468
  var gridData = (0, _fortuneCore.getFlowdata)(ctx);
367
469
  var cellData = _fortuneCore.api.dataToCelldata(gridData);
368
- var denominatedUsed = false;
369
- for (var _i = 0, cellData_1 = cellData; _i < cellData_1.length; _i++) {
370
- var cell = cellData_1[_i];
470
+ var denominatedUsed = (cellData !== null && cellData !== void 0 ? cellData : []).some(function (cell) {
471
+ var _a, _b;
371
472
  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();
372
- 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"))) {
373
- denominatedUsed = true;
374
- break;
375
- }
376
- }
473
+ 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"));
474
+ });
377
475
  var denoWarn = document.getElementById("denomination-warning");
378
476
  var scrollBar = document.getElementsByClassName("luckysheet-scrollbar-x")[0];
379
477
  if (denominatedUsed && denoWarn) {
@@ -447,6 +545,32 @@ var Workbook = /*#__PURE__*/_react.default.forwardRef(function (_a, ref) {
447
545
  context.hooks.afterOrderChanges();
448
546
  }
449
547
  }, [currentSheet === null || currentSheet === void 0 ? void 0 : currentSheet.order]);
548
+ var sheetColorSig = (0, _react.useMemo)(function () {
549
+ var _a;
550
+ return ((_a = context === null || context === void 0 ? void 0 : context.luckysheetfile) !== null && _a !== void 0 ? _a : []).map(function (s) {
551
+ var _a;
552
+ return "".concat(s.id, ":").concat((_a = s.color) !== null && _a !== void 0 ? _a : "");
553
+ }).join("|");
554
+ }, [context === null || context === void 0 ? void 0 : context.luckysheetfile]);
555
+ (0, _react.useEffect)(function () {
556
+ var _a;
557
+ if ((_a = context === null || context === void 0 ? void 0 : context.hooks) === null || _a === void 0 ? void 0 : _a.afterColorChanges) {
558
+ context.hooks.afterColorChanges();
559
+ }
560
+ }, [sheetColorSig]);
561
+ var sheetHideSig = (0, _react.useMemo)(function () {
562
+ var _a;
563
+ return ((_a = context === null || context === void 0 ? void 0 : context.luckysheetfile) !== null && _a !== void 0 ? _a : []).map(function (s) {
564
+ var _a;
565
+ return "".concat(s.id, ":").concat((_a = s.hide) !== null && _a !== void 0 ? _a : 0);
566
+ }).join("|");
567
+ }, [context === null || context === void 0 ? void 0 : context.luckysheetfile]);
568
+ (0, _react.useEffect)(function () {
569
+ var _a;
570
+ if ((_a = context === null || context === void 0 ? void 0 : context.hooks) === null || _a === void 0 ? void 0 : _a.afterHideChanges) {
571
+ context.hooks.afterHideChanges();
572
+ }
573
+ }, [sheetHideSig]);
450
574
  (0, _react.useEffect)(function () {
451
575
  var _a;
452
576
  if ((_a = context === null || context === void 0 ? void 0 : context.hooks) === null || _a === void 0 ? void 0 : _a.afterConfigChanges) {
@@ -513,6 +637,18 @@ var Workbook = /*#__PURE__*/_react.default.forwardRef(function (_a, ref) {
513
637
  context.hooks.conditionFormatChange();
514
638
  }
515
639
  }, [currentSheet === null || currentSheet === void 0 ? void 0 : currentSheet.luckysheet_conditionformat_save]);
640
+ (0, _react.useEffect)(function () {
641
+ var _a;
642
+ if ((_a = context === null || context === void 0 ? void 0 : context.hooks) === null || _a === void 0 ? void 0 : _a.filterSelectChange) {
643
+ context.hooks.filterSelectChange();
644
+ }
645
+ }, [currentSheet === null || currentSheet === void 0 ? void 0 : currentSheet.filter_select]);
646
+ (0, _react.useEffect)(function () {
647
+ var _a;
648
+ if ((_a = context === null || context === void 0 ? void 0 : context.hooks) === null || _a === void 0 ? void 0 : _a.filterChange) {
649
+ context.hooks.filterChange();
650
+ }
651
+ }, [currentSheet === null || currentSheet === void 0 ? void 0 : currentSheet.filter]);
516
652
  (0, _react.useEffect)(function () {
517
653
  var _a;
518
654
  if ((_a = context === null || context === void 0 ? void 0 : context.hooks) === null || _a === void 0 ? void 0 : _a.hyperlinkChange) {
@@ -281,9 +281,12 @@ function convertCellsToCrypto(_a) {
281
281
  });
282
282
  });
283
283
  setContext(function (ctx) {
284
+ var _a;
284
285
  var d = (0, _fortuneCore.getFlowdata)(ctx);
285
286
  if (!d || !Array.isArray(d)) return;
287
+ var ydocChanges = [];
286
288
  cellUpdates.forEach(function (_a) {
289
+ var _b, _c;
287
290
  var row = _a.row,
288
291
  col = _a.col,
289
292
  baseValue = _a.baseValue,
@@ -303,7 +306,21 @@ function convertCellsToCrypto(_a) {
303
306
  cellCp.baseCurrency = baseCurrency.toLowerCase();
304
307
  cellCp.baseCurrencyPrice = baseCurrencyPrice;
305
308
  d[row][col] = cellCp;
309
+ ydocChanges.push({
310
+ sheetId: ctx.currentSheetId,
311
+ path: ["celldata"],
312
+ value: {
313
+ r: row,
314
+ c: col,
315
+ v: (_c = (_b = d[row]) === null || _b === void 0 ? void 0 : _b[col]) !== null && _c !== void 0 ? _c : null
316
+ },
317
+ key: "".concat(row, "_").concat(col),
318
+ type: "update"
319
+ });
306
320
  });
321
+ if (ydocChanges.length > 0 && ((_a = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _a === void 0 ? void 0 : _a.updateCellYdoc)) {
322
+ ctx.hooks.updateCellYdoc(ydocChanges);
323
+ }
307
324
  });
308
325
  setContext(function (ctx) {
309
326
  _fortuneCore.api.calculateSheetFromula(ctx, ctx.currentSheetId);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fileverse-dev/fortune-react",
3
- "version": "1.3.10",
3
+ "version": "1.3.11-mixed",
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",
19
+ "@fileverse-dev/fortune-core": "1.3.11-mixed",
20
20
  "@fileverse/ui": "5.0.0",
21
21
  "@tippyjs/react": "^4.2.6",
22
22
  "@types/regenerator-runtime": "^0.13.6",