@fileverse-dev/fortune-core 1.3.3 → 1.3.4-date-format-1
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/canvas.js +1 -1
- package/es/modules/cell.js +8 -6
- package/es/modules/ssf.js +1 -1
- package/es/modules/toolbar.js +30 -9
- package/lib/canvas.js +1 -1
- package/lib/modules/cell.js +8 -6
- package/lib/modules/ssf.js +1 -1
- package/lib/modules/toolbar.js +30 -9
- package/package.json +1 -1
package/es/canvas.js
CHANGED
|
@@ -1012,7 +1012,7 @@ var Canvas = function () {
|
|
|
1012
1012
|
renderCtx.clip();
|
|
1013
1013
|
renderCtx.scale(this.sheetCtx.zoomRatio, this.sheetCtx.zoomRatio);
|
|
1014
1014
|
var measureText = getMeasureText(value, renderCtx, this.sheetCtx);
|
|
1015
|
-
var textMetrics = measureText.width +
|
|
1015
|
+
var textMetrics = measureText.width + 18;
|
|
1016
1016
|
var oneLineTextHeight = measureText.actualBoundingBoxDescent + measureText.actualBoundingBoxAscent;
|
|
1017
1017
|
var horizonAlignPos = pos_x + space_width;
|
|
1018
1018
|
if (horizonAlign === 0) {
|
package/es/modules/cell.js
CHANGED
|
@@ -110,7 +110,7 @@ export function getCellValue(r, c, data, attr) {
|
|
|
110
110
|
return retv;
|
|
111
111
|
}
|
|
112
112
|
export function setCellValue(ctx, r, c, d, v) {
|
|
113
|
-
var _a, _b, _c, _d, _e, _f, _g
|
|
113
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
114
114
|
if (ctx.allowEdit === false || ctx.isFlvReadOnly) return;
|
|
115
115
|
if (_.isNil(d)) {
|
|
116
116
|
d = getFlowdata(ctx);
|
|
@@ -276,10 +276,7 @@ export function setCellValue(ctx, r, c, d, v) {
|
|
|
276
276
|
} else if (!_.isNil(cell.ct) && !_.isNil(cell.ct.fa) && cell.ct.fa !== "General") {
|
|
277
277
|
var fa = cell.ct.fa;
|
|
278
278
|
if (isRealNum(vupdate)) {
|
|
279
|
-
if (commaPresent && !fa.includes(",")
|
|
280
|
-
if (fa.includes(",") !== String(vupdate).includes(",")) {
|
|
281
|
-
commaPresent = true;
|
|
282
|
-
}
|
|
279
|
+
if (commaPresent && !fa.includes(",")) {
|
|
283
280
|
fa = getNumberFormat(String(vupdate), commaPresent);
|
|
284
281
|
}
|
|
285
282
|
vupdate = parseFloat(vupdate);
|
|
@@ -289,6 +286,9 @@ export function setCellValue(ctx, r, c, d, v) {
|
|
|
289
286
|
t: "n"
|
|
290
287
|
});
|
|
291
288
|
}
|
|
289
|
+
if (_.isNil(cell.ht)) {
|
|
290
|
+
cell.ht = 2;
|
|
291
|
+
}
|
|
292
292
|
}
|
|
293
293
|
var mask = update(fa, vupdate);
|
|
294
294
|
if (mask === vupdate) {
|
|
@@ -317,7 +317,9 @@ export function setCellValue(ctx, r, c, d, v) {
|
|
|
317
317
|
var strValue = String(vupdate);
|
|
318
318
|
var format = getNumberFormat(strValue, commaPresent);
|
|
319
319
|
cell.m = v.m ? v.m : update(format, cell.v);
|
|
320
|
-
|
|
320
|
+
if (_.isNil(cell.ht)) {
|
|
321
|
+
cell.ht = 2;
|
|
322
|
+
}
|
|
321
323
|
cell.ct = {
|
|
322
324
|
fa: format,
|
|
323
325
|
t: "n"
|
package/es/modules/ssf.js
CHANGED
|
@@ -1364,7 +1364,7 @@ var make_ssf = function make_ssf(SSF) {
|
|
|
1364
1364
|
if (typeof n !== "number" || !Number.isFinite(n)) return null;
|
|
1365
1365
|
if (!Number.isInteger(n)) return null;
|
|
1366
1366
|
if (n < 0) return null;
|
|
1367
|
-
var minSec =
|
|
1367
|
+
var minSec = 100000; // Excel serial numbers max ~73050 for year 2100; avoids collision
|
|
1368
1368
|
var maxSec = 4102444800; // ~2100-01-01
|
|
1369
1369
|
var minMs = minSec * 1000;
|
|
1370
1370
|
var maxMs = maxSec * 1000;
|
package/es/modules/toolbar.js
CHANGED
|
@@ -33,21 +33,42 @@ export function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_
|
|
|
33
33
|
} else {
|
|
34
34
|
value = cell;
|
|
35
35
|
}
|
|
36
|
+
var type = "n";
|
|
37
|
+
if (is_date(foucsStatus) || foucsStatus === 14 || foucsStatus === 15 || foucsStatus === 16 || foucsStatus === 17 || foucsStatus === 18 || foucsStatus === 19 || foucsStatus === 20 || foucsStatus === 21 || foucsStatus === 22 || foucsStatus === 45 || foucsStatus === 46 || foucsStatus === 47) {
|
|
38
|
+
type = "d";
|
|
39
|
+
} else if (foucsStatus === "@" || foucsStatus === 49) {
|
|
40
|
+
type = "s";
|
|
41
|
+
}
|
|
36
42
|
if (_.isNil(value)) {
|
|
43
|
+
if (!_.isNil(d[r])) {
|
|
44
|
+
if (_.isNil(d[r][c])) {
|
|
45
|
+
d[r][c] = {
|
|
46
|
+
ct: {
|
|
47
|
+
fa: foucsStatus,
|
|
48
|
+
t: type
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
} else if (_.isPlainObject(d[r][c])) {
|
|
52
|
+
if (_.isNil(d[r][c].ct)) d[r][c].ct = {};
|
|
53
|
+
d[r][c].ct.fa = foucsStatus;
|
|
54
|
+
d[r][c].ct.t = type;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
37
57
|
continue;
|
|
38
58
|
}
|
|
39
59
|
if (foucsStatus !== "@" && isRealNum(value)) {
|
|
40
60
|
value = Number(value);
|
|
61
|
+
} else if (type === "d" && typeof value === "string") {
|
|
62
|
+
var dateMask = genarate(value);
|
|
63
|
+
if (dateMask && dateMask[1].t === "d") {
|
|
64
|
+
var numericSerial = dateMask[2];
|
|
65
|
+
value = numericSerial;
|
|
66
|
+
}
|
|
41
67
|
}
|
|
42
|
-
|
|
43
|
-
var type = "n";
|
|
44
|
-
if (is_date(foucsStatus) || foucsStatus === 14 || foucsStatus === 15 || foucsStatus === 16 || foucsStatus === 17 || foucsStatus === 18 || foucsStatus === 19 || foucsStatus === 20 || foucsStatus === 21 || foucsStatus === 22 || foucsStatus === 45 || foucsStatus === 46 || foucsStatus === 47) {
|
|
45
|
-
type = "d";
|
|
46
|
-
} else if (foucsStatus === "@" || foucsStatus === 49) {
|
|
47
|
-
type = "s";
|
|
48
|
-
} else if (foucsStatus === "General" || foucsStatus === 0) {
|
|
68
|
+
if (foucsStatus === "General" || foucsStatus === 0) {
|
|
49
69
|
type = isRealNum(value) ? "n" : "g";
|
|
50
70
|
}
|
|
71
|
+
var mask = update(foucsStatus, value);
|
|
51
72
|
if (cell && _.isPlainObject(cell)) {
|
|
52
73
|
cell.m = "".concat(mask);
|
|
53
74
|
if (_.isNil(cell.ct)) {
|
|
@@ -55,7 +76,7 @@ export function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_
|
|
|
55
76
|
}
|
|
56
77
|
cell.ct.fa = foucsStatus;
|
|
57
78
|
cell.ct.t = type;
|
|
58
|
-
cell.v = String(value);
|
|
79
|
+
cell.v = typeof value === "number" ? value : String(value);
|
|
59
80
|
cell.fc = cell.fc || ((_f = (_e = (_d = cell.ct) === null || _d === void 0 ? void 0 : _d.s) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.fc);
|
|
60
81
|
cell.bl = cell.bl || ((_j = (_h = (_g = cell.ct) === null || _g === void 0 ? void 0 : _g.s) === null || _h === void 0 ? void 0 : _h[0]) === null || _j === void 0 ? void 0 : _j.bl);
|
|
61
82
|
cell.it = cell.it || ((_m = (_l = (_k = cell.ct) === null || _k === void 0 ? void 0 : _k.s) === null || _l === void 0 ? void 0 : _l[0]) === null || _m === void 0 ? void 0 : _m.it);
|
|
@@ -68,7 +89,7 @@ export function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_
|
|
|
68
89
|
fa: foucsStatus,
|
|
69
90
|
t: type
|
|
70
91
|
},
|
|
71
|
-
v: value,
|
|
92
|
+
v: typeof value === "number" ? value : value,
|
|
72
93
|
m: mask
|
|
73
94
|
};
|
|
74
95
|
}
|
package/lib/canvas.js
CHANGED
|
@@ -1019,7 +1019,7 @@ var Canvas = exports.Canvas = function () {
|
|
|
1019
1019
|
renderCtx.clip();
|
|
1020
1020
|
renderCtx.scale(this.sheetCtx.zoomRatio, this.sheetCtx.zoomRatio);
|
|
1021
1021
|
var measureText = (0, _text.getMeasureText)(value, renderCtx, this.sheetCtx);
|
|
1022
|
-
var textMetrics = measureText.width +
|
|
1022
|
+
var textMetrics = measureText.width + 18;
|
|
1023
1023
|
var oneLineTextHeight = measureText.actualBoundingBoxDescent + measureText.actualBoundingBoxAscent;
|
|
1024
1024
|
var horizonAlignPos = pos_x + space_width;
|
|
1025
1025
|
if (horizonAlign === 0) {
|
package/lib/modules/cell.js
CHANGED
|
@@ -143,7 +143,7 @@ function getCellValue(r, c, data, attr) {
|
|
|
143
143
|
return retv;
|
|
144
144
|
}
|
|
145
145
|
function setCellValue(ctx, r, c, d, v) {
|
|
146
|
-
var _a, _b, _c, _d, _e, _f, _g
|
|
146
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
147
147
|
if (ctx.allowEdit === false || ctx.isFlvReadOnly) return;
|
|
148
148
|
if (_lodash.default.isNil(d)) {
|
|
149
149
|
d = (0, _context.getFlowdata)(ctx);
|
|
@@ -309,10 +309,7 @@ function setCellValue(ctx, r, c, d, v) {
|
|
|
309
309
|
} else if (!_lodash.default.isNil(cell.ct) && !_lodash.default.isNil(cell.ct.fa) && cell.ct.fa !== "General") {
|
|
310
310
|
var fa = cell.ct.fa;
|
|
311
311
|
if ((0, _validation.isRealNum)(vupdate)) {
|
|
312
|
-
if (commaPresent && !fa.includes(",")
|
|
313
|
-
if (fa.includes(",") !== String(vupdate).includes(",")) {
|
|
314
|
-
commaPresent = true;
|
|
315
|
-
}
|
|
312
|
+
if (commaPresent && !fa.includes(",")) {
|
|
316
313
|
fa = (0, _utils.getNumberFormat)(String(vupdate), commaPresent);
|
|
317
314
|
}
|
|
318
315
|
vupdate = parseFloat(vupdate);
|
|
@@ -322,6 +319,9 @@ function setCellValue(ctx, r, c, d, v) {
|
|
|
322
319
|
t: "n"
|
|
323
320
|
});
|
|
324
321
|
}
|
|
322
|
+
if (_lodash.default.isNil(cell.ht)) {
|
|
323
|
+
cell.ht = 2;
|
|
324
|
+
}
|
|
325
325
|
}
|
|
326
326
|
var mask = (0, _format.update)(fa, vupdate);
|
|
327
327
|
if (mask === vupdate) {
|
|
@@ -350,7 +350,9 @@ function setCellValue(ctx, r, c, d, v) {
|
|
|
350
350
|
var strValue = String(vupdate);
|
|
351
351
|
var format = (0, _utils.getNumberFormat)(strValue, commaPresent);
|
|
352
352
|
cell.m = v.m ? v.m : (0, _format.update)(format, cell.v);
|
|
353
|
-
|
|
353
|
+
if (_lodash.default.isNil(cell.ht)) {
|
|
354
|
+
cell.ht = 2;
|
|
355
|
+
}
|
|
354
356
|
cell.ct = {
|
|
355
357
|
fa: format,
|
|
356
358
|
t: "n"
|
package/lib/modules/ssf.js
CHANGED
|
@@ -1370,7 +1370,7 @@ var make_ssf = function make_ssf(SSF) {
|
|
|
1370
1370
|
if (typeof n !== "number" || !Number.isFinite(n)) return null;
|
|
1371
1371
|
if (!Number.isInteger(n)) return null;
|
|
1372
1372
|
if (n < 0) return null;
|
|
1373
|
-
var minSec =
|
|
1373
|
+
var minSec = 100000; // Excel serial numbers max ~73050 for year 2100; avoids collision
|
|
1374
1374
|
var maxSec = 4102444800; // ~2100-01-01
|
|
1375
1375
|
var minMs = minSec * 1000;
|
|
1376
1376
|
var maxMs = maxSec * 1000;
|
package/lib/modules/toolbar.js
CHANGED
|
@@ -66,21 +66,42 @@ function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_st, col
|
|
|
66
66
|
} else {
|
|
67
67
|
value = cell;
|
|
68
68
|
}
|
|
69
|
+
var type = "n";
|
|
70
|
+
if ((0, _format.is_date)(foucsStatus) || foucsStatus === 14 || foucsStatus === 15 || foucsStatus === 16 || foucsStatus === 17 || foucsStatus === 18 || foucsStatus === 19 || foucsStatus === 20 || foucsStatus === 21 || foucsStatus === 22 || foucsStatus === 45 || foucsStatus === 46 || foucsStatus === 47) {
|
|
71
|
+
type = "d";
|
|
72
|
+
} else if (foucsStatus === "@" || foucsStatus === 49) {
|
|
73
|
+
type = "s";
|
|
74
|
+
}
|
|
69
75
|
if (_lodash.default.isNil(value)) {
|
|
76
|
+
if (!_lodash.default.isNil(d[r])) {
|
|
77
|
+
if (_lodash.default.isNil(d[r][c])) {
|
|
78
|
+
d[r][c] = {
|
|
79
|
+
ct: {
|
|
80
|
+
fa: foucsStatus,
|
|
81
|
+
t: type
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
} else if (_lodash.default.isPlainObject(d[r][c])) {
|
|
85
|
+
if (_lodash.default.isNil(d[r][c].ct)) d[r][c].ct = {};
|
|
86
|
+
d[r][c].ct.fa = foucsStatus;
|
|
87
|
+
d[r][c].ct.t = type;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
70
90
|
continue;
|
|
71
91
|
}
|
|
72
92
|
if (foucsStatus !== "@" && (0, _validation.isRealNum)(value)) {
|
|
73
93
|
value = Number(value);
|
|
94
|
+
} else if (type === "d" && typeof value === "string") {
|
|
95
|
+
var dateMask = (0, _format.genarate)(value);
|
|
96
|
+
if (dateMask && dateMask[1].t === "d") {
|
|
97
|
+
var numericSerial = dateMask[2];
|
|
98
|
+
value = numericSerial;
|
|
99
|
+
}
|
|
74
100
|
}
|
|
75
|
-
|
|
76
|
-
var type = "n";
|
|
77
|
-
if ((0, _format.is_date)(foucsStatus) || foucsStatus === 14 || foucsStatus === 15 || foucsStatus === 16 || foucsStatus === 17 || foucsStatus === 18 || foucsStatus === 19 || foucsStatus === 20 || foucsStatus === 21 || foucsStatus === 22 || foucsStatus === 45 || foucsStatus === 46 || foucsStatus === 47) {
|
|
78
|
-
type = "d";
|
|
79
|
-
} else if (foucsStatus === "@" || foucsStatus === 49) {
|
|
80
|
-
type = "s";
|
|
81
|
-
} else if (foucsStatus === "General" || foucsStatus === 0) {
|
|
101
|
+
if (foucsStatus === "General" || foucsStatus === 0) {
|
|
82
102
|
type = (0, _validation.isRealNum)(value) ? "n" : "g";
|
|
83
103
|
}
|
|
104
|
+
var mask = (0, _format.update)(foucsStatus, value);
|
|
84
105
|
if (cell && _lodash.default.isPlainObject(cell)) {
|
|
85
106
|
cell.m = "".concat(mask);
|
|
86
107
|
if (_lodash.default.isNil(cell.ct)) {
|
|
@@ -88,7 +109,7 @@ function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_st, col
|
|
|
88
109
|
}
|
|
89
110
|
cell.ct.fa = foucsStatus;
|
|
90
111
|
cell.ct.t = type;
|
|
91
|
-
cell.v = String(value);
|
|
112
|
+
cell.v = typeof value === "number" ? value : String(value);
|
|
92
113
|
cell.fc = cell.fc || ((_f = (_e = (_d = cell.ct) === null || _d === void 0 ? void 0 : _d.s) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.fc);
|
|
93
114
|
cell.bl = cell.bl || ((_j = (_h = (_g = cell.ct) === null || _g === void 0 ? void 0 : _g.s) === null || _h === void 0 ? void 0 : _h[0]) === null || _j === void 0 ? void 0 : _j.bl);
|
|
94
115
|
cell.it = cell.it || ((_m = (_l = (_k = cell.ct) === null || _k === void 0 ? void 0 : _k.s) === null || _l === void 0 ? void 0 : _l[0]) === null || _m === void 0 ? void 0 : _m.it);
|
|
@@ -101,7 +122,7 @@ function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_st, col
|
|
|
101
122
|
fa: foucsStatus,
|
|
102
123
|
t: type
|
|
103
124
|
},
|
|
104
|
-
v: value,
|
|
125
|
+
v: typeof value === "number" ? value : value,
|
|
105
126
|
m: mask
|
|
106
127
|
};
|
|
107
128
|
}
|