@fileverse-dev/fortune-react 1.3.10-yjs → 1.3.10-yjs-2
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/es/components/SheetOverlay/drag_and_drop/column-helpers.js +20 -17
- package/es/components/SheetOverlay/drag_and_drop/row-helpers.js +23 -20
- package/es/components/Workbook/index.js +1 -0
- package/es/utils/convertCellsToCrypto.js +17 -0
- package/lib/components/SheetOverlay/drag_and_drop/column-helpers.js +20 -17
- package/lib/components/SheetOverlay/drag_and_drop/row-helpers.js +23 -20
- package/lib/components/Workbook/index.js +1 -0
- package/lib/utils/convertCellsToCrypto.js +17 -0
- package/package.json +2 -2
|
@@ -375,23 +375,26 @@ export var useColumnDragAndDrop = function useColumnDragAndDrop(containerRef, se
|
|
|
375
375
|
});
|
|
376
376
|
(_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);
|
|
377
377
|
var cellChanges = [];
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
378
|
+
var affectedColStart = Math.min(sourceIndex_1, targetIndex);
|
|
379
|
+
var affectedColEnd = Math.max(sourceIndex_1, targetIndex) + selectedSourceCol.length - 1;
|
|
380
|
+
var numRows = rows.length;
|
|
381
|
+
for (var r = 0; r < numRows; r += 1) {
|
|
382
|
+
var row = rows[r];
|
|
383
|
+
for (var c = affectedColStart; c <= affectedColEnd; c += 1) {
|
|
384
|
+
var cell = row === null || row === void 0 ? void 0 : row[c];
|
|
385
|
+
cellChanges.push({
|
|
386
|
+
sheetId: draft.currentSheetId,
|
|
387
|
+
path: ["celldata"],
|
|
388
|
+
value: {
|
|
389
|
+
r: r,
|
|
390
|
+
c: c,
|
|
391
|
+
v: cell !== null && cell !== void 0 ? cell : null
|
|
392
|
+
},
|
|
393
|
+
key: "".concat(r, "_").concat(c),
|
|
394
|
+
type: "update"
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
}
|
|
395
398
|
if (cellChanges.length > 0 && ((_h = draft.hooks) === null || _h === void 0 ? void 0 : _h.updateCellYdoc)) {
|
|
396
399
|
draft.hooks.updateCellYdoc(cellChanges);
|
|
397
400
|
}
|
|
@@ -207,7 +207,7 @@ export var useRowDragAndDrop = function useRowDragAndDrop(containerRef, selected
|
|
|
207
207
|
var sheetIdx_1 = getSheetIndex(context, context.currentSheetId);
|
|
208
208
|
if (sheetIdx_1 != null && sourceIndex_1 >= 0 && Number.isFinite(finalInsertionIndex_1) && finalInsertionIndex_1 >= 0) {
|
|
209
209
|
setContext(function (draft) {
|
|
210
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
210
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
211
211
|
var _sheet = draft.luckysheetfile[sheetIdx_1];
|
|
212
212
|
if (!(_sheet === null || _sheet === void 0 ? void 0 : _sheet.data)) return;
|
|
213
213
|
var rows = _sheet.data;
|
|
@@ -365,27 +365,30 @@ export var useRowDragAndDrop = function useRowDragAndDrop(containerRef, selected
|
|
|
365
365
|
});
|
|
366
366
|
(_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);
|
|
367
367
|
var cellChanges = [];
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
368
|
+
var affectedRowStart = Math.min(sourceIndex_1, targetIndex);
|
|
369
|
+
var affectedRowEnd = Math.max(sourceIndex_1, targetIndex) + selectedSourceRow.length - 1;
|
|
370
|
+
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;
|
|
371
|
+
for (var r = affectedRowStart; r <= affectedRowEnd; r += 1) {
|
|
372
|
+
var row = rows[r];
|
|
373
|
+
for (var c = 0; c < numCols; c += 1) {
|
|
374
|
+
var cell = row === null || row === void 0 ? void 0 : row[c];
|
|
375
|
+
cellChanges.push({
|
|
376
|
+
sheetId: draft.currentSheetId,
|
|
377
|
+
path: ["celldata"],
|
|
378
|
+
value: {
|
|
379
|
+
r: r,
|
|
380
|
+
c: c,
|
|
381
|
+
v: cell !== null && cell !== void 0 ? cell : null
|
|
382
|
+
},
|
|
383
|
+
key: "".concat(r, "_").concat(c),
|
|
384
|
+
type: "update"
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
if (cellChanges.length > 0 && ((_h = draft.hooks) === null || _h === void 0 ? void 0 : _h.updateCellYdoc)) {
|
|
386
389
|
draft.hooks.updateCellYdoc(cellChanges);
|
|
387
390
|
}
|
|
388
|
-
var colLen = ((
|
|
391
|
+
var colLen = ((_j = d === null || d === void 0 ? void 0 : d[0]) === null || _j === void 0 ? void 0 : _j.length) || 0;
|
|
389
392
|
api.setSelection(draft, [{
|
|
390
393
|
row: [selectedTargetRow[0], selectedTargetRow[selectedTargetRow.length - 1]],
|
|
391
394
|
column: [0, colLen]
|
|
@@ -470,6 +470,7 @@ var Workbook = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
470
470
|
}, [currentSheet === null || currentSheet === void 0 ? void 0 : currentSheet.status]);
|
|
471
471
|
useEffect(function () {
|
|
472
472
|
var _a;
|
|
473
|
+
console.log("dataVerificationChange", currentSheet === null || currentSheet === void 0 ? void 0 : currentSheet.dataVerification);
|
|
473
474
|
if ((_a = context === null || context === void 0 ? void 0 : context.hooks) === null || _a === void 0 ? void 0 : _a.dataVerificationChange) {
|
|
474
475
|
context.hooks.dataVerificationChange();
|
|
475
476
|
}
|
|
@@ -274,9 +274,12 @@ export function convertCellsToCrypto(_a) {
|
|
|
274
274
|
});
|
|
275
275
|
});
|
|
276
276
|
setContext(function (ctx) {
|
|
277
|
+
var _a;
|
|
277
278
|
var d = getFlowdata(ctx);
|
|
278
279
|
if (!d || !Array.isArray(d)) return;
|
|
280
|
+
var ydocChanges = [];
|
|
279
281
|
cellUpdates.forEach(function (_a) {
|
|
282
|
+
var _b, _c;
|
|
280
283
|
var row = _a.row,
|
|
281
284
|
col = _a.col,
|
|
282
285
|
baseValue = _a.baseValue,
|
|
@@ -296,7 +299,21 @@ export function convertCellsToCrypto(_a) {
|
|
|
296
299
|
cellCp.baseCurrency = baseCurrency.toLowerCase();
|
|
297
300
|
cellCp.baseCurrencyPrice = baseCurrencyPrice;
|
|
298
301
|
d[row][col] = cellCp;
|
|
302
|
+
ydocChanges.push({
|
|
303
|
+
sheetId: ctx.currentSheetId,
|
|
304
|
+
path: ["celldata"],
|
|
305
|
+
value: {
|
|
306
|
+
r: row,
|
|
307
|
+
c: col,
|
|
308
|
+
v: (_c = (_b = d[row]) === null || _b === void 0 ? void 0 : _b[col]) !== null && _c !== void 0 ? _c : null
|
|
309
|
+
},
|
|
310
|
+
key: "".concat(row, "_").concat(col),
|
|
311
|
+
type: "update"
|
|
312
|
+
});
|
|
299
313
|
});
|
|
314
|
+
if (ydocChanges.length > 0 && ((_a = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _a === void 0 ? void 0 : _a.updateCellYdoc)) {
|
|
315
|
+
ctx.hooks.updateCellYdoc(ydocChanges);
|
|
316
|
+
}
|
|
300
317
|
});
|
|
301
318
|
setContext(function (ctx) {
|
|
302
319
|
api.calculateSheetFromula(ctx, ctx.currentSheetId);
|
|
@@ -383,23 +383,26 @@ var useColumnDragAndDrop = exports.useColumnDragAndDrop = function useColumnDrag
|
|
|
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
385
|
var cellChanges = [];
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
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
|
+
}
|
|
403
406
|
if (cellChanges.length > 0 && ((_h = draft.hooks) === null || _h === void 0 ? void 0 : _h.updateCellYdoc)) {
|
|
404
407
|
draft.hooks.updateCellYdoc(cellChanges);
|
|
405
408
|
}
|
|
@@ -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, _g;
|
|
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;
|
|
@@ -372,27 +372,30 @@ var useRowDragAndDrop = exports.useRowDragAndDrop = function useRowDragAndDrop(c
|
|
|
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
374
|
var cellChanges = [];
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
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)) {
|
|
393
396
|
draft.hooks.updateCellYdoc(cellChanges);
|
|
394
397
|
}
|
|
395
|
-
var colLen = ((
|
|
398
|
+
var colLen = ((_j = d === null || d === void 0 ? void 0 : d[0]) === null || _j === void 0 ? void 0 : _j.length) || 0;
|
|
396
399
|
_fortuneCore.api.setSelection(draft, [{
|
|
397
400
|
row: [selectedTargetRow[0], selectedTargetRow[selectedTargetRow.length - 1]],
|
|
398
401
|
column: [0, colLen]
|
|
@@ -479,6 +479,7 @@ var Workbook = /*#__PURE__*/_react.default.forwardRef(function (_a, ref) {
|
|
|
479
479
|
}, [currentSheet === null || currentSheet === void 0 ? void 0 : currentSheet.status]);
|
|
480
480
|
(0, _react.useEffect)(function () {
|
|
481
481
|
var _a;
|
|
482
|
+
console.log("dataVerificationChange", currentSheet === null || currentSheet === void 0 ? void 0 : currentSheet.dataVerification);
|
|
482
483
|
if ((_a = context === null || context === void 0 ? void 0 : context.hooks) === null || _a === void 0 ? void 0 : _a.dataVerificationChange) {
|
|
483
484
|
context.hooks.dataVerificationChange();
|
|
484
485
|
}
|
|
@@ -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-yjs",
|
|
3
|
+
"version": "1.3.10-yjs-2",
|
|
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",
|
|
19
|
+
"@fileverse-dev/fortune-core": "1.3.10-yjs-2",
|
|
20
20
|
"@fileverse/ui": "5.0.0",
|
|
21
21
|
"@tippyjs/react": "^4.2.6",
|
|
22
22
|
"@types/regenerator-runtime": "^0.13.6",
|