@fileverse-dev/fortune-core 1.1.46 → 1.1.47
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/modules/cell.js +12 -9
- package/es/utils/index.js +18 -19
- package/lib/modules/cell.js +12 -9
- package/lib/utils/index.js +18 -19
- package/package.json +1 -1
package/es/modules/cell.js
CHANGED
|
@@ -93,7 +93,8 @@ export function getCellValue(r, c, data, attr) {
|
|
|
93
93
|
return retv;
|
|
94
94
|
}
|
|
95
95
|
export function setCellValue(ctx, r, c, d, v) {
|
|
96
|
-
var _a, _b, _c, _d, _e, _f;
|
|
96
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
97
|
+
console.log("setCellValue", r, c, v);
|
|
97
98
|
if (_.isNil(d)) {
|
|
98
99
|
d = getFlowdata(ctx);
|
|
99
100
|
}
|
|
@@ -132,7 +133,7 @@ export function setCellValue(ctx, r, c, d, v) {
|
|
|
132
133
|
commaPresent = vupdate.includes(",");
|
|
133
134
|
decimalPresent = vupdate.includes(".");
|
|
134
135
|
var removeCommasValidated = function removeCommasValidated(str) {
|
|
135
|
-
return /^[\d
|
|
136
|
+
return /^[\d,\.]+$/.test(str) ? str === null || str === void 0 ? void 0 : str.replace(/,/g, "") : str;
|
|
136
137
|
};
|
|
137
138
|
vupdate = removeCommasValidated(vupdate);
|
|
138
139
|
}
|
|
@@ -273,13 +274,15 @@ export function setCellValue(ctx, r, c, d, v) {
|
|
|
273
274
|
}
|
|
274
275
|
}
|
|
275
276
|
cell.v = vupdate;
|
|
277
|
+
var strValue = String(vupdate);
|
|
276
278
|
var format = void 0;
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
279
|
+
var hasDecimal = strValue.includes(".");
|
|
280
|
+
var hasComma = commaPresent;
|
|
281
|
+
if (hasDecimal) {
|
|
282
|
+
var decimalCount = ((_g = strValue.split(".")[1]) === null || _g === void 0 ? void 0 : _g.length) || 0;
|
|
283
|
+
format = hasComma ? "#,##0.".concat("0".repeat(decimalCount)) : "0.".concat("0".repeat(decimalCount));
|
|
284
|
+
} else if (hasComma) {
|
|
285
|
+
format = "#,##0";
|
|
283
286
|
} else {
|
|
284
287
|
format = "0";
|
|
285
288
|
}
|
|
@@ -670,7 +673,7 @@ export function updateCell(ctx, r, c, $input, value, canvas) {
|
|
|
670
673
|
f: v[2]
|
|
671
674
|
};
|
|
672
675
|
if (/^[\d.,]+$/.test(value.v)) {
|
|
673
|
-
var args = getContentInParentheses(value === null || value === void 0 ? void 0 : value.f).split(
|
|
676
|
+
var args = getContentInParentheses(value === null || value === void 0 ? void 0 : value.f).split(",");
|
|
674
677
|
var cellRefs = args.map(function (arg) {
|
|
675
678
|
return arg.trim().toUpperCase();
|
|
676
679
|
});
|
package/es/utils/index.js
CHANGED
|
@@ -224,10 +224,10 @@ export function processArray(cellReferences, d, flowData) {
|
|
|
224
224
|
var match = cell.match(/^([A-Za-z]+)(\d+)$/);
|
|
225
225
|
if (!match) return null;
|
|
226
226
|
var letters = match[1].toLowerCase();
|
|
227
|
-
var number = parseInt(match[2]);
|
|
227
|
+
var number = parseInt(match[2], 10);
|
|
228
228
|
var col = 0;
|
|
229
|
-
for (var i = 0; i < letters.length; i
|
|
230
|
-
col = col * 26 + (letters.charCodeAt(i) -
|
|
229
|
+
for (var i = 0; i < letters.length; i += 1) {
|
|
230
|
+
col = col * 26 + (letters.charCodeAt(i) - "a".charCodeAt(0) + 1);
|
|
231
231
|
}
|
|
232
232
|
col -= 1;
|
|
233
233
|
var row = number - 1;
|
|
@@ -239,31 +239,30 @@ export function processArray(cellReferences, d, flowData) {
|
|
|
239
239
|
};
|
|
240
240
|
}
|
|
241
241
|
var validCellReferences = cellReferences.filter(function (cellRef) {
|
|
242
|
-
if (cellRef.includes(
|
|
243
|
-
var _a = cellRef.split(
|
|
242
|
+
if (cellRef.includes(":")) {
|
|
243
|
+
var _a = cellRef.split(":"),
|
|
244
244
|
startCell = _a[0],
|
|
245
245
|
endCell = _a[1];
|
|
246
246
|
return isValidCellReference(startCell.trim()) && isValidCellReference(endCell.trim());
|
|
247
|
-
} else {
|
|
248
|
-
return isValidCellReference(cellRef.trim());
|
|
249
247
|
}
|
|
248
|
+
return isValidCellReference(cellRef.trim());
|
|
250
249
|
});
|
|
251
250
|
var expandedCellReferences = [];
|
|
252
251
|
validCellReferences.forEach(function (cellRef) {
|
|
253
|
-
if (cellRef.includes(
|
|
254
|
-
var _a = cellRef.split(
|
|
252
|
+
if (cellRef.includes(":")) {
|
|
253
|
+
var _a = cellRef.split(":"),
|
|
255
254
|
startCell = _a[0],
|
|
256
255
|
endCell = _a[1];
|
|
257
256
|
var startParsed = parseCellReference(startCell.trim());
|
|
258
257
|
var endParsed = parseCellReference(endCell.trim());
|
|
259
258
|
if (!startParsed || !endParsed) return;
|
|
260
|
-
for (var row = startParsed.number; row <= endParsed.number; row
|
|
261
|
-
for (var col = startParsed.col; col <= endParsed.col; col
|
|
262
|
-
var letters =
|
|
259
|
+
for (var row = startParsed.number; row <= endParsed.number; row += 1) {
|
|
260
|
+
for (var col = startParsed.col; col <= endParsed.col; col += 1) {
|
|
261
|
+
var letters = "";
|
|
263
262
|
var tempCol = col + 1;
|
|
264
263
|
while (tempCol > 0) {
|
|
265
|
-
tempCol
|
|
266
|
-
letters = String.fromCharCode(
|
|
264
|
+
tempCol -= 1;
|
|
265
|
+
letters = String.fromCharCode("A".charCodeAt(0) + tempCol % 26) + letters;
|
|
267
266
|
tempCol = Math.floor(tempCol / 26);
|
|
268
267
|
}
|
|
269
268
|
var cellName = letters + row;
|
|
@@ -283,15 +282,15 @@ export function processArray(cellReferences, d, flowData) {
|
|
|
283
282
|
}
|
|
284
283
|
});
|
|
285
284
|
var formated;
|
|
286
|
-
coordinates.forEach(function (coord
|
|
285
|
+
coordinates.forEach(function (coord) {
|
|
287
286
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
288
287
|
var row = coord[0],
|
|
289
288
|
col = coord[1];
|
|
290
289
|
if (row >= 0 && row < d.length && col >= 0 && col < d[row].length) {
|
|
291
|
-
if (((_b = (_a = flowData === null || flowData === void 0 ? void 0 : flowData[row][col]) === null || _a === void 0 ? void 0 : _a.ct) === null || _b === void 0 ? void 0 : _b.fa) && ((_e = (_d = (_c = flowData === null || flowData === void 0 ? void 0 : flowData[row][col]) === null || _c === void 0 ? void 0 : _c.ct) === null || _d === void 0 ? void 0 : _d.fa) === null || _e === void 0 ? void 0 : _e.includes(
|
|
292
|
-
formated =
|
|
293
|
-
} else if (((_g = (_f = flowData === null || flowData === void 0 ? void 0 : flowData[row][col]) === null || _f === void 0 ? void 0 : _f.ct) === null || _g === void 0 ? void 0 : _g.fa) && ((_k = (_j = (_h = flowData === null || flowData === void 0 ? void 0 : flowData[row][col]) === null || _h === void 0 ? void 0 : _h.ct) === null || _j === void 0 ? void 0 : _j.fa) === null || _k === void 0 ? void 0 : _k.includes(
|
|
294
|
-
formated =
|
|
290
|
+
if (((_b = (_a = flowData === null || flowData === void 0 ? void 0 : flowData[row][col]) === null || _a === void 0 ? void 0 : _a.ct) === null || _b === void 0 ? void 0 : _b.fa) && ((_e = (_d = (_c = flowData === null || flowData === void 0 ? void 0 : flowData[row][col]) === null || _c === void 0 ? void 0 : _c.ct) === null || _d === void 0 ? void 0 : _d.fa) === null || _e === void 0 ? void 0 : _e.includes("#,##0"))) {
|
|
291
|
+
formated = "#,##0";
|
|
292
|
+
} else if (((_g = (_f = flowData === null || flowData === void 0 ? void 0 : flowData[row][col]) === null || _f === void 0 ? void 0 : _f.ct) === null || _g === void 0 ? void 0 : _g.fa) && ((_k = (_j = (_h = flowData === null || flowData === void 0 ? void 0 : flowData[row][col]) === null || _h === void 0 ? void 0 : _h.ct) === null || _j === void 0 ? void 0 : _j.fa) === null || _k === void 0 ? void 0 : _k.includes("#,##0.00"))) {
|
|
293
|
+
formated = "#,##0.00";
|
|
295
294
|
}
|
|
296
295
|
}
|
|
297
296
|
});
|
package/lib/modules/cell.js
CHANGED
|
@@ -123,7 +123,8 @@ function getCellValue(r, c, data, attr) {
|
|
|
123
123
|
return retv;
|
|
124
124
|
}
|
|
125
125
|
function setCellValue(ctx, r, c, d, v) {
|
|
126
|
-
var _a, _b, _c, _d, _e, _f;
|
|
126
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
127
|
+
console.log("setCellValue", r, c, v);
|
|
127
128
|
if (_lodash.default.isNil(d)) {
|
|
128
129
|
d = (0, _context.getFlowdata)(ctx);
|
|
129
130
|
}
|
|
@@ -162,7 +163,7 @@ function setCellValue(ctx, r, c, d, v) {
|
|
|
162
163
|
commaPresent = vupdate.includes(",");
|
|
163
164
|
decimalPresent = vupdate.includes(".");
|
|
164
165
|
var removeCommasValidated = function removeCommasValidated(str) {
|
|
165
|
-
return /^[\d
|
|
166
|
+
return /^[\d,\.]+$/.test(str) ? str === null || str === void 0 ? void 0 : str.replace(/,/g, "") : str;
|
|
166
167
|
};
|
|
167
168
|
vupdate = removeCommasValidated(vupdate);
|
|
168
169
|
}
|
|
@@ -303,13 +304,15 @@ function setCellValue(ctx, r, c, d, v) {
|
|
|
303
304
|
}
|
|
304
305
|
}
|
|
305
306
|
cell.v = vupdate;
|
|
307
|
+
var strValue = String(vupdate);
|
|
306
308
|
var format = void 0;
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
309
|
+
var hasDecimal = strValue.includes(".");
|
|
310
|
+
var hasComma = commaPresent;
|
|
311
|
+
if (hasDecimal) {
|
|
312
|
+
var decimalCount = ((_g = strValue.split(".")[1]) === null || _g === void 0 ? void 0 : _g.length) || 0;
|
|
313
|
+
format = hasComma ? "#,##0.".concat("0".repeat(decimalCount)) : "0.".concat("0".repeat(decimalCount));
|
|
314
|
+
} else if (hasComma) {
|
|
315
|
+
format = "#,##0";
|
|
313
316
|
} else {
|
|
314
317
|
format = "0";
|
|
315
318
|
}
|
|
@@ -700,7 +703,7 @@ function updateCell(ctx, r, c, $input, value, canvas) {
|
|
|
700
703
|
f: v[2]
|
|
701
704
|
};
|
|
702
705
|
if (/^[\d.,]+$/.test(value.v)) {
|
|
703
|
-
var args = (0, _utils.getContentInParentheses)(value === null || value === void 0 ? void 0 : value.f).split(
|
|
706
|
+
var args = (0, _utils.getContentInParentheses)(value === null || value === void 0 ? void 0 : value.f).split(",");
|
|
704
707
|
var cellRefs = args.map(function (arg) {
|
|
705
708
|
return arg.trim().toUpperCase();
|
|
706
709
|
});
|
package/lib/utils/index.js
CHANGED
|
@@ -292,10 +292,10 @@ function processArray(cellReferences, d, flowData) {
|
|
|
292
292
|
var match = cell.match(/^([A-Za-z]+)(\d+)$/);
|
|
293
293
|
if (!match) return null;
|
|
294
294
|
var letters = match[1].toLowerCase();
|
|
295
|
-
var number = parseInt(match[2]);
|
|
295
|
+
var number = parseInt(match[2], 10);
|
|
296
296
|
var col = 0;
|
|
297
|
-
for (var i = 0; i < letters.length; i
|
|
298
|
-
col = col * 26 + (letters.charCodeAt(i) -
|
|
297
|
+
for (var i = 0; i < letters.length; i += 1) {
|
|
298
|
+
col = col * 26 + (letters.charCodeAt(i) - "a".charCodeAt(0) + 1);
|
|
299
299
|
}
|
|
300
300
|
col -= 1;
|
|
301
301
|
var row = number - 1;
|
|
@@ -307,31 +307,30 @@ function processArray(cellReferences, d, flowData) {
|
|
|
307
307
|
};
|
|
308
308
|
}
|
|
309
309
|
var validCellReferences = cellReferences.filter(function (cellRef) {
|
|
310
|
-
if (cellRef.includes(
|
|
311
|
-
var _a = cellRef.split(
|
|
310
|
+
if (cellRef.includes(":")) {
|
|
311
|
+
var _a = cellRef.split(":"),
|
|
312
312
|
startCell = _a[0],
|
|
313
313
|
endCell = _a[1];
|
|
314
314
|
return isValidCellReference(startCell.trim()) && isValidCellReference(endCell.trim());
|
|
315
|
-
} else {
|
|
316
|
-
return isValidCellReference(cellRef.trim());
|
|
317
315
|
}
|
|
316
|
+
return isValidCellReference(cellRef.trim());
|
|
318
317
|
});
|
|
319
318
|
var expandedCellReferences = [];
|
|
320
319
|
validCellReferences.forEach(function (cellRef) {
|
|
321
|
-
if (cellRef.includes(
|
|
322
|
-
var _a = cellRef.split(
|
|
320
|
+
if (cellRef.includes(":")) {
|
|
321
|
+
var _a = cellRef.split(":"),
|
|
323
322
|
startCell = _a[0],
|
|
324
323
|
endCell = _a[1];
|
|
325
324
|
var startParsed = parseCellReference(startCell.trim());
|
|
326
325
|
var endParsed = parseCellReference(endCell.trim());
|
|
327
326
|
if (!startParsed || !endParsed) return;
|
|
328
|
-
for (var row = startParsed.number; row <= endParsed.number; row
|
|
329
|
-
for (var col = startParsed.col; col <= endParsed.col; col
|
|
330
|
-
var letters =
|
|
327
|
+
for (var row = startParsed.number; row <= endParsed.number; row += 1) {
|
|
328
|
+
for (var col = startParsed.col; col <= endParsed.col; col += 1) {
|
|
329
|
+
var letters = "";
|
|
331
330
|
var tempCol = col + 1;
|
|
332
331
|
while (tempCol > 0) {
|
|
333
|
-
tempCol
|
|
334
|
-
letters = String.fromCharCode(
|
|
332
|
+
tempCol -= 1;
|
|
333
|
+
letters = String.fromCharCode("A".charCodeAt(0) + tempCol % 26) + letters;
|
|
335
334
|
tempCol = Math.floor(tempCol / 26);
|
|
336
335
|
}
|
|
337
336
|
var cellName = letters + row;
|
|
@@ -351,15 +350,15 @@ function processArray(cellReferences, d, flowData) {
|
|
|
351
350
|
}
|
|
352
351
|
});
|
|
353
352
|
var formated;
|
|
354
|
-
coordinates.forEach(function (coord
|
|
353
|
+
coordinates.forEach(function (coord) {
|
|
355
354
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
356
355
|
var row = coord[0],
|
|
357
356
|
col = coord[1];
|
|
358
357
|
if (row >= 0 && row < d.length && col >= 0 && col < d[row].length) {
|
|
359
|
-
if (((_b = (_a = flowData === null || flowData === void 0 ? void 0 : flowData[row][col]) === null || _a === void 0 ? void 0 : _a.ct) === null || _b === void 0 ? void 0 : _b.fa) && ((_e = (_d = (_c = flowData === null || flowData === void 0 ? void 0 : flowData[row][col]) === null || _c === void 0 ? void 0 : _c.ct) === null || _d === void 0 ? void 0 : _d.fa) === null || _e === void 0 ? void 0 : _e.includes(
|
|
360
|
-
formated =
|
|
361
|
-
} else if (((_g = (_f = flowData === null || flowData === void 0 ? void 0 : flowData[row][col]) === null || _f === void 0 ? void 0 : _f.ct) === null || _g === void 0 ? void 0 : _g.fa) && ((_k = (_j = (_h = flowData === null || flowData === void 0 ? void 0 : flowData[row][col]) === null || _h === void 0 ? void 0 : _h.ct) === null || _j === void 0 ? void 0 : _j.fa) === null || _k === void 0 ? void 0 : _k.includes(
|
|
362
|
-
formated =
|
|
358
|
+
if (((_b = (_a = flowData === null || flowData === void 0 ? void 0 : flowData[row][col]) === null || _a === void 0 ? void 0 : _a.ct) === null || _b === void 0 ? void 0 : _b.fa) && ((_e = (_d = (_c = flowData === null || flowData === void 0 ? void 0 : flowData[row][col]) === null || _c === void 0 ? void 0 : _c.ct) === null || _d === void 0 ? void 0 : _d.fa) === null || _e === void 0 ? void 0 : _e.includes("#,##0"))) {
|
|
359
|
+
formated = "#,##0";
|
|
360
|
+
} else if (((_g = (_f = flowData === null || flowData === void 0 ? void 0 : flowData[row][col]) === null || _f === void 0 ? void 0 : _f.ct) === null || _g === void 0 ? void 0 : _g.fa) && ((_k = (_j = (_h = flowData === null || flowData === void 0 ? void 0 : flowData[row][col]) === null || _h === void 0 ? void 0 : _h.ct) === null || _j === void 0 ? void 0 : _j.fa) === null || _k === void 0 ? void 0 : _k.includes("#,##0.00"))) {
|
|
361
|
+
formated = "#,##0.00";
|
|
363
362
|
}
|
|
364
363
|
}
|
|
365
364
|
});
|