@fileverse-dev/fortune-core 1.3.5-hyper-2 → 1.3.6-right

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 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 + 14;
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) {
@@ -34,10 +34,10 @@ import { handlePastedTable } from "../paste-table-helpers";
34
34
  import { getFlowdata } from "../context";
35
35
  import { execfunction } from "../modules/formula";
36
36
  import { getdatabyselection } from "../modules/cell";
37
- import { genarate, update } from "../modules/format";
37
+ import { update, datenum_local } from "../modules/format";
38
38
  import { normalizeSelection, selectionCache } from "../modules/selection";
39
39
  import { getSheetIndex, isAllowEdit } from "../utils";
40
- import { hasPartMC, isRealNum } from "../modules/validation";
40
+ import { hasPartMC, isRealNum, detectDateFormat } from "../modules/validation";
41
41
  import { getBorderInfoCompute } from "../modules/border";
42
42
  import { expandRowsAndColumns, storeSheetParamALL } from "../modules/sheet";
43
43
  import { jfrefreshgrid } from "../modules/refresh";
@@ -207,14 +207,13 @@ var handleFormulaOnPaste = function handleFormulaOnPaste(ctx, d) {
207
207
  }
208
208
  };
209
209
  function pasteHandler(ctx, data, borderInfo) {
210
- var _a;
211
- var _b, _c, _d, _e, _f, _g;
210
+ var _a, _b, _c, _d, _e, _f;
212
211
  if (ctx.luckysheet_selection_range) {
213
212
  ctx.luckysheet_selection_range = [];
214
213
  }
215
214
  var allowEdit = isAllowEdit(ctx);
216
215
  if (!allowEdit || ctx.isFlvReadOnly) return;
217
- if (((_c = (_b = ctx.luckysheet_select_save) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0) !== 1) {
216
+ if (((_b = (_a = ctx.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) !== 1) {
218
217
  return;
219
218
  }
220
219
  if (_typeof(data) === "object") {
@@ -263,7 +262,7 @@ function pasteHandler(ctx, data, borderInfo) {
263
262
  currentRowLen = cfg.rowlen[h];
264
263
  }
265
264
  for (var c = minc; c <= maxc; c += 1) {
266
- if ((_d = x === null || x === void 0 ? void 0 : x[c]) === null || _d === void 0 ? void 0 : _d.mc) {
265
+ if ((_c = x === null || x === void 0 ? void 0 : x[c]) === null || _c === void 0 ? void 0 : _c.mc) {
267
266
  if ("rs" in x[c].mc) {
268
267
  delete cfg.merge["".concat(x[c].mc.r, "_").concat(x[c].mc.c)];
269
268
  }
@@ -274,7 +273,7 @@ function pasteHandler(ctx, data, borderInfo) {
274
273
  value = data[h - minh][c - minc];
275
274
  }
276
275
  x[c] = value;
277
- if (value != null && ((_e = x === null || x === void 0 ? void 0 : x[c]) === null || _e === void 0 ? void 0 : _e.mc)) {
276
+ if (value != null && ((_d = x === null || x === void 0 ? void 0 : x[c]) === null || _d === void 0 ? void 0 : _d.mc)) {
278
277
  if (x[c].mc.rs != null) {
279
278
  x[c].mc.r = h;
280
279
  x[c].mc.c = c;
@@ -301,7 +300,7 @@ function pasteHandler(ctx, data, borderInfo) {
301
300
  b: borderInfo["".concat(h - minh, "_").concat(c - minc)].b
302
301
  }
303
302
  };
304
- (_f = cfg.borderInfo) === null || _f === void 0 ? void 0 : _f.push(bd_obj);
303
+ (_e = cfg.borderInfo) === null || _e === void 0 ? void 0 : _e.push(bd_obj);
305
304
  }
306
305
  }
307
306
  d[h] = x;
@@ -333,7 +332,7 @@ function pasteHandler(ctx, data, borderInfo) {
333
332
  }
334
333
  var d = getFlowdata(ctx);
335
334
  if (!d) return;
336
- var last = (_g = ctx.luckysheet_select_save) === null || _g === void 0 ? void 0 : _g[ctx.luckysheet_select_save.length - 1];
335
+ var last = (_f = ctx.luckysheet_select_save) === null || _f === void 0 ? void 0 : _f[ctx.luckysheet_select_save.length - 1];
337
336
  if (!last) return;
338
337
  var curR = last.row == null ? 0 : last.row[0];
339
338
  var curC = last.column == null ? 0 : last.column[0];
@@ -374,9 +373,23 @@ function pasteHandler(ctx, data, borderInfo) {
374
373
  }
375
374
  }
376
375
  if (originCell) {
377
- originCell.v = isUrl ? originalValueStr : value;
376
+ if (originCell.ct && originCell.ct.t === "d" && !isUrl) {
377
+ var df = detectDateFormat(originalValueStr);
378
+ if (df) {
379
+ var dateObj = new Date(df.year, df.month - 1, df.day, df.hours, df.minutes, df.seconds);
380
+ originCell.v = datenum_local(dateObj);
381
+ } else {
382
+ originCell.v = originalValueStr;
383
+ }
384
+ } else {
385
+ originCell.v = isUrl ? originalValueStr : value;
386
+ }
378
387
  if (originCell.ct != null && originCell.ct.fa != null) {
379
- originCell.m = update(originCell.ct.fa, originCell.v);
388
+ if (originCell.ct.t === "d" && typeof originCell.v !== "number") {
389
+ originCell.m = String(originCell.v);
390
+ } else {
391
+ originCell.m = update(originCell.ct.fa, originCell.v);
392
+ }
380
393
  } else {
381
394
  originCell.m = typeof originCell.v === "boolean" ? String(originCell.v) : originCell.v;
382
395
  }
@@ -405,8 +418,12 @@ function pasteHandler(ctx, data, borderInfo) {
405
418
  t: "s"
406
419
  };
407
420
  } else {
408
- var mask = genarate(value);
409
- _a = mask, cell.m = _a[0], cell.ct = _a[1], cell.v = _a[2];
421
+ cell.v = originalValueStr;
422
+ cell.m = originalValueStr;
423
+ cell.ct = {
424
+ fa: "General",
425
+ t: "g"
426
+ };
410
427
  if (/^0x?[a-fA-F0-9]+$/.test(value)) {
411
428
  cell.m = value;
412
429
  cell.ct = {
@@ -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, _h, _j, _k, _l;
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);
@@ -135,6 +135,9 @@ export function setCellValue(ctx, r, c, d, v) {
135
135
  if (!_.isNil(v.ct)) {
136
136
  cell.ct = v.ct;
137
137
  }
138
+ if (!_.isNil(v.ht)) {
139
+ cell.ht = v.ht;
140
+ }
138
141
  }
139
142
  if (_.isPlainObject(v.v)) {
140
143
  vupdate = v.v.v;
@@ -276,10 +279,7 @@ export function setCellValue(ctx, r, c, d, v) {
276
279
  } else if (!_.isNil(cell.ct) && !_.isNil(cell.ct.fa) && cell.ct.fa !== "General") {
277
280
  var fa = cell.ct.fa;
278
281
  if (isRealNum(vupdate)) {
279
- if (commaPresent && !fa.includes(",") || String(vupdate).includes(".") && ((_j = (_h = String(vupdate).split(".")) === null || _h === void 0 ? void 0 : _h[1]) === null || _j === void 0 ? void 0 : _j.length) !== ((_l = (_k = fa.split(".")) === null || _k === void 0 ? void 0 : _k[1]) === null || _l === void 0 ? void 0 : _l.length) || fa.includes(",") !== String(vupdate).includes(",")) {
280
- if (fa.includes(",") !== String(vupdate).includes(",")) {
281
- commaPresent = true;
282
- }
282
+ if (commaPresent && !fa.includes(",")) {
283
283
  fa = getNumberFormat(String(vupdate), commaPresent);
284
284
  }
285
285
  vupdate = parseFloat(vupdate);
@@ -289,12 +289,16 @@ export function setCellValue(ctx, r, c, d, v) {
289
289
  t: "n"
290
290
  });
291
291
  }
292
+ cell.ht = 2;
292
293
  }
293
294
  var mask = update(fa, vupdate);
294
295
  if (mask === vupdate) {
295
296
  mask = genarate(vupdate);
296
297
  cell.m = mask[0].toString();
297
298
  cell.ct = mask[1], cell.v = mask[2];
299
+ if (isRealNum(vupdate)) {
300
+ cell.ht = 2;
301
+ }
298
302
  } else {
299
303
  if (v.m) {
300
304
  cell.m = v.m;
@@ -317,7 +321,7 @@ export function setCellValue(ctx, r, c, d, v) {
317
321
  var strValue = String(vupdate);
318
322
  var format = getNumberFormat(strValue, commaPresent);
319
323
  cell.m = v.m ? v.m : update(format, cell.v);
320
- cell.ht = (v === null || v === void 0 ? void 0 : v.ht) ? cell.ht : 2;
324
+ cell.ht = 2;
321
325
  cell.ct = {
322
326
  fa: format,
323
327
  t: "n"
@@ -1,6 +1,6 @@
1
1
  import numeral from "numeral";
2
2
  import _ from "lodash";
3
- import { isRealNum, valueIsError, isdatetime } from "./validation";
3
+ import { isRealNum, valueIsError, detectDateFormat } from "./validation";
4
4
  import SSF from "./ssf";
5
5
  import { getCellValue } from "./cell";
6
6
  var base1904 = new Date(1900, 2, 1, 0, 0, 0);
@@ -10,29 +10,6 @@ export function datenum_local(v, date1904) {
10
10
  if (date1904) epoch -= 1461 * 24 * 60 * 60 * 1000;else if (v >= base1904) epoch += 24 * 60 * 60 * 1000;
11
11
  return (epoch - dnthresh_utc) / (24 * 60 * 60 * 1000);
12
12
  }
13
- var good_pd_date = new Date("2017-02-19T19:06:09.000Z");
14
- if (Number.isNaN(good_pd_date.getFullYear())) good_pd_date = new Date("2/19/17");
15
- var good_pd = good_pd_date.getFullYear() === 2017;
16
- function parseDate(str, fixdate) {
17
- var d = new Date(str);
18
- if (good_pd) {
19
- if (!_.isNil(fixdate)) {
20
- if (fixdate > 0) d.setTime(d.getTime() + d.getTimezoneOffset() * 60 * 1000);else if (fixdate < 0) d.setTime(d.getTime() - d.getTimezoneOffset() * 60 * 1000);
21
- }
22
- return d;
23
- }
24
- if (str instanceof Date) return str;
25
- if (good_pd_date.getFullYear() === 1917 && !Number.isNaN(d.getFullYear())) {
26
- var s = d.getFullYear();
27
- if (str.indexOf("".concat(s)) > -1) return d;
28
- d.setFullYear(d.getFullYear() + 100);
29
- return d;
30
- }
31
- var n = str.match(/\d+/g) || ["2017", "2", "19", "0", "0", "0"];
32
- var out = new Date(+n[0], +n[1] - 1, +n[2], +n[3] || 0, +n[4] || 0, +n[5] || 0);
33
- if (str.indexOf("Z") > -1) out = new Date(out.getTime() - out.getTimezoneOffset() * 60 * 1000);
34
- return out;
35
- }
36
13
  export function genarate(value) {
37
14
  var m = null;
38
15
  var ct = {};
@@ -256,23 +233,37 @@ export function genarate(value) {
256
233
  t: "n"
257
234
  };
258
235
  v = parseFloat(value);
259
- } else if (isdatetime(value) && (value.toString().indexOf(".") > -1 || value.toString().indexOf(":") > -1 || value.toString().length < 16)) {
260
- v = datenum_local(parseDate(value.toString().replace(/-/g, "/")));
261
- if (v.toString().indexOf(".") > -1) {
262
- if (value.toString().length > 18) {
263
- ct.fa = "yyyy-MM-dd hh:mm:ss";
264
- } else if (value.toString().length > 11) {
265
- ct.fa = "yyyy-MM-dd hh:mm";
266
- } else {
267
- ct.fa = "yyyy-MM-dd";
268
- }
236
+ } else if (typeof value === "string") {
237
+ var df = detectDateFormat(value.toString());
238
+ if (df) {
239
+ var dateObj = new Date(df.year, df.month - 1, df.day, df.hours, df.minutes, df.seconds);
240
+ v = datenum_local(dateObj);
241
+ ct.t = "d";
242
+ var map = {
243
+ "yyyy-MM-dd": "dd/MM/yyyy",
244
+ "yyyy-MM-dd HH:mm": "dd/MM/yyyy",
245
+ "yyyy-MM-ddTHH:mm": "dd/MM/yyyy",
246
+ "yyyy/MM/dd": "dd/MM/yyyy",
247
+ "yyyy/MM/dd HH:mm": "dd/MM/yyyy",
248
+ "yyyy.MM.dd": "yyyy.MM.dd",
249
+ "MM/dd/yyyy h:mm AM/PM": "MM/dd/yyyy h:mm AM/PM",
250
+ "MM/dd/yyyy": "MM/dd/yyyy",
251
+ "M/d/yyyy": "M/d/yyyy",
252
+ "MM/dd/yy": "MM/dd/yy",
253
+ "dd/MM/yyyy": "dd/MM/yyyy",
254
+ "dd-MM-yyyy": "dd/MM/yyyy",
255
+ "dd.MM.yyyy": "dd.MM.yyyy",
256
+ named: "dd/MM/yyyy"
257
+ };
258
+ ct.fa = map[df.formatType] || "dd/MM/yyyy";
259
+ m = SSF.format(ct.fa, v);
269
260
  } else {
270
- ct.fa = "yyyy-MM-dd";
261
+ m = String(value);
262
+ ct.fa = "General";
263
+ ct.t = "g";
271
264
  }
272
- ct.t = "d";
273
- m = SSF.format(ct.fa, v);
274
265
  } else {
275
- m = value;
266
+ m = String(value);
276
267
  ct.fa = "General";
277
268
  ct.t = "g";
278
269
  }
@@ -1541,6 +1541,8 @@ export function deleteSelectedCellText(ctx) {
1541
1541
  var cell = d[r][c];
1542
1542
  delete cell.m;
1543
1543
  delete cell.v;
1544
+ delete cell.fc;
1545
+ delete cell.un;
1544
1546
  if (cell.f != null) {
1545
1547
  delete cell.f;
1546
1548
  delFunctionGroup(ctx, r, c, ctx.currentSheetId);
@@ -1613,7 +1615,8 @@ export function deleteSelectedCellFormat(ctx) {
1613
1615
  return "success";
1614
1616
  }
1615
1617
  export function fillRightData(ctx) {
1616
- var _a, _b;
1618
+ var _a, _b, _c, _d;
1619
+ var _e, _f, _g;
1617
1620
  var allowEdit = isAllowEdit(ctx);
1618
1621
  if (allowEdit === false) {
1619
1622
  return "allowEdit";
@@ -1641,18 +1644,109 @@ export function fillRightData(ctx) {
1641
1644
  var r2 = selection[s].row[1];
1642
1645
  var c1 = selection[s].column[0];
1643
1646
  var c2 = selection[s].column[1];
1647
+ var sheetIndex = getSheetIndex(ctx, ctx.currentSheetId);
1648
+ var file = sheetIndex != null ? ctx.luckysheetfile[sheetIndex] : null;
1649
+ var dataVerification = file === null || file === void 0 ? void 0 : file.dataVerification;
1650
+ var hyperlink = file === null || file === void 0 ? void 0 : file.hyperlink;
1651
+ var cdformat = file === null || file === void 0 ? void 0 : file.luckysheet_conditionformat_save;
1644
1652
  var isSingleCell = r1 === r2 && c1 === c2;
1645
1653
  if (isSingleCell) {
1646
1654
  if (c1 - 1 >= 0 && d[r1]) {
1655
+ var srcRow = r1;
1656
+ var srcCol = c1 - 1;
1647
1657
  var prev = d[r1][c1 - 1];
1648
1658
  d[r1][c1] = prev != null ? __assign({}, prev) : {};
1659
+ if (file != null) {
1660
+ var srcKey = "".concat(srcRow, "_").concat(srcCol);
1661
+ var tgtKey = "".concat(r1, "_").concat(c1);
1662
+ if (dataVerification != null) {
1663
+ var dv = dataVerification[srcKey];
1664
+ if (dv != null) {
1665
+ console.log("[fillRightData] dataVerification copy from", {
1666
+ row: srcRow,
1667
+ col: srcCol
1668
+ }, "→", {
1669
+ row: r1,
1670
+ col: c1
1671
+ }, dv);
1672
+ file.dataVerification = __assign(__assign({}, file.dataVerification || {}), (_a = {}, _a[tgtKey] = _.cloneDeep(dv), _a));
1673
+ }
1674
+ }
1675
+ if (hyperlink != null && hyperlink[srcKey] != null) {
1676
+ file.hyperlink = __assign(__assign({}, file.hyperlink || {}), (_b = {}, _b[tgtKey] = _.cloneDeep(hyperlink[srcKey]), _b));
1677
+ var tgtCell = d[r1][c1];
1678
+ if (tgtCell != null) tgtCell.hl = {
1679
+ r: r1,
1680
+ c: c1,
1681
+ id: ctx.currentSheetId
1682
+ };
1683
+ }
1684
+ if (cdformat != null && cdformat.length > 0) {
1685
+ for (var i = 0; i < cdformat.length; i += 1) {
1686
+ var ranges = cdformat[i].cellrange;
1687
+ if (!ranges) continue;
1688
+ for (var j = 0; j < ranges.length; j += 1) {
1689
+ var cr = ranges[j];
1690
+ if (srcRow >= cr.row[0] && srcRow <= cr.row[1] && srcCol >= cr.column[0] && srcCol <= cr.column[1]) {
1691
+ ranges.push({
1692
+ row: [r1, r1],
1693
+ column: [c1, c1]
1694
+ });
1695
+ break;
1696
+ }
1697
+ }
1698
+ }
1699
+ }
1700
+ }
1649
1701
  }
1650
1702
  } else {
1651
1703
  for (var r = r1; r <= r2; r += 1) {
1652
- var sourceCell = (_a = d[r]) === null || _a === void 0 ? void 0 : _a[c1];
1704
+ var sourceCell = (_e = d[r]) === null || _e === void 0 ? void 0 : _e[c1];
1653
1705
  for (var c = c1 + 1; c <= c2; c += 1) {
1654
1706
  if (d[r]) {
1655
- d[r][c] = sourceCell != null ? __assign({}, sourceCell) : (_b = d[r][c]) !== null && _b !== void 0 ? _b : {};
1707
+ d[r][c] = sourceCell != null ? __assign({}, sourceCell) : (_f = d[r][c]) !== null && _f !== void 0 ? _f : {};
1708
+ }
1709
+ if (file != null) {
1710
+ var srcKey = "".concat(r, "_").concat(c1);
1711
+ var tgtKey = "".concat(r, "_").concat(c);
1712
+ if (dataVerification != null) {
1713
+ var dv = dataVerification[srcKey];
1714
+ if (dv != null) {
1715
+ console.log("[fillRightData] dataVerification copy from", {
1716
+ row: r,
1717
+ col: c1
1718
+ }, "→", {
1719
+ row: r,
1720
+ col: c
1721
+ }, dv);
1722
+ file.dataVerification = __assign(__assign({}, file.dataVerification || {}), (_c = {}, _c[tgtKey] = _.cloneDeep(dv), _c));
1723
+ }
1724
+ }
1725
+ if (hyperlink != null && hyperlink[srcKey] != null) {
1726
+ file.hyperlink = __assign(__assign({}, file.hyperlink || {}), (_d = {}, _d[tgtKey] = _.cloneDeep(hyperlink[srcKey]), _d));
1727
+ var tgtCell = (_g = d[r]) === null || _g === void 0 ? void 0 : _g[c];
1728
+ if (tgtCell != null) tgtCell.hl = {
1729
+ r: r,
1730
+ c: c,
1731
+ id: ctx.currentSheetId
1732
+ };
1733
+ }
1734
+ if (cdformat != null && cdformat.length > 0) {
1735
+ for (var i = 0; i < cdformat.length; i += 1) {
1736
+ var ranges = cdformat[i].cellrange;
1737
+ if (!ranges) continue;
1738
+ for (var j = 0; j < ranges.length; j += 1) {
1739
+ var cr = ranges[j];
1740
+ if (r >= cr.row[0] && r <= cr.row[1] && c1 >= cr.column[0] && c1 <= cr.column[1]) {
1741
+ ranges.push({
1742
+ row: [r, r],
1743
+ column: [c, c]
1744
+ });
1745
+ break;
1746
+ }
1747
+ }
1748
+ }
1749
+ }
1656
1750
  }
1657
1751
  }
1658
1752
  }
@@ -1662,7 +1756,8 @@ export function fillRightData(ctx) {
1662
1756
  return "success";
1663
1757
  }
1664
1758
  export function fillDownData(ctx) {
1665
- var _a, _b;
1759
+ var _a, _b, _c, _d;
1760
+ var _e, _f, _g;
1666
1761
  var allowEdit = isAllowEdit(ctx);
1667
1762
  if (allowEdit === false) {
1668
1763
  return "allowEdit";
@@ -1690,19 +1785,110 @@ export function fillDownData(ctx) {
1690
1785
  var r2 = selection[s].row[1];
1691
1786
  var c1 = selection[s].column[0];
1692
1787
  var c2 = selection[s].column[1];
1788
+ var sheetIndex = getSheetIndex(ctx, ctx.currentSheetId);
1789
+ var file = sheetIndex != null ? ctx.luckysheetfile[sheetIndex] : null;
1790
+ var dataVerification = file === null || file === void 0 ? void 0 : file.dataVerification;
1791
+ var hyperlink = file === null || file === void 0 ? void 0 : file.hyperlink;
1792
+ var cdformat = file === null || file === void 0 ? void 0 : file.luckysheet_conditionformat_save;
1693
1793
  var isSingleCell = r1 === r2 && c1 === c2;
1694
1794
  if (isSingleCell) {
1695
1795
  if (r1 - 1 >= 0 && d[r1 - 1]) {
1796
+ var srcRow = r1 - 1;
1797
+ var srcCol = c1;
1696
1798
  var prev = d[r1 - 1][c1];
1697
1799
  if (!d[r1]) d[r1] = [];
1698
1800
  d[r1][c1] = prev != null ? __assign({}, prev) : {};
1801
+ if (file != null) {
1802
+ var srcKey = "".concat(srcRow, "_").concat(srcCol);
1803
+ var tgtKey = "".concat(r1, "_").concat(c1);
1804
+ if (dataVerification != null) {
1805
+ var dv = dataVerification[srcKey];
1806
+ if (dv != null) {
1807
+ console.log("[fillDownData] dataVerification copy from", {
1808
+ row: srcRow,
1809
+ col: srcCol
1810
+ }, "→", {
1811
+ row: r1,
1812
+ col: c1
1813
+ }, dv);
1814
+ file.dataVerification = __assign(__assign({}, file.dataVerification || {}), (_a = {}, _a[tgtKey] = _.cloneDeep(dv), _a));
1815
+ }
1816
+ }
1817
+ if (hyperlink != null && hyperlink[srcKey] != null) {
1818
+ file.hyperlink = __assign(__assign({}, file.hyperlink || {}), (_b = {}, _b[tgtKey] = _.cloneDeep(hyperlink[srcKey]), _b));
1819
+ var tgtCell = d[r1][c1];
1820
+ if (tgtCell != null) tgtCell.hl = {
1821
+ r: r1,
1822
+ c: c1,
1823
+ id: ctx.currentSheetId
1824
+ };
1825
+ }
1826
+ if (cdformat != null && cdformat.length > 0) {
1827
+ for (var i = 0; i < cdformat.length; i += 1) {
1828
+ var ranges = cdformat[i].cellrange;
1829
+ if (!ranges) continue;
1830
+ for (var j = 0; j < ranges.length; j += 1) {
1831
+ var cr = ranges[j];
1832
+ if (srcRow >= cr.row[0] && srcRow <= cr.row[1] && srcCol >= cr.column[0] && srcCol <= cr.column[1]) {
1833
+ ranges.push({
1834
+ row: [r1, r1],
1835
+ column: [c1, c1]
1836
+ });
1837
+ break;
1838
+ }
1839
+ }
1840
+ }
1841
+ }
1842
+ }
1699
1843
  }
1700
1844
  } else {
1701
1845
  for (var c = c1; c <= c2; c += 1) {
1702
- var sourceCell = (_a = d[r1]) === null || _a === void 0 ? void 0 : _a[c];
1846
+ var sourceCell = (_e = d[r1]) === null || _e === void 0 ? void 0 : _e[c];
1703
1847
  for (var r = r1 + 1; r <= r2; r += 1) {
1704
1848
  if (!d[r]) d[r] = [];
1705
- d[r][c] = sourceCell != null ? __assign({}, sourceCell) : (_b = d[r][c]) !== null && _b !== void 0 ? _b : {};
1849
+ d[r][c] = sourceCell != null ? __assign({}, sourceCell) : (_f = d[r][c]) !== null && _f !== void 0 ? _f : {};
1850
+ if (file != null) {
1851
+ var srcKey = "".concat(r1, "_").concat(c);
1852
+ var tgtKey = "".concat(r, "_").concat(c);
1853
+ if (dataVerification != null) {
1854
+ var dv = dataVerification[srcKey];
1855
+ if (dv != null) {
1856
+ console.log("[fillDownData] dataVerification copy from", {
1857
+ row: r1,
1858
+ col: c
1859
+ }, "→", {
1860
+ row: r,
1861
+ col: c
1862
+ }, dv);
1863
+ file.dataVerification = __assign(__assign({}, file.dataVerification || {}), (_c = {}, _c[tgtKey] = _.cloneDeep(dv), _c));
1864
+ }
1865
+ }
1866
+ if (hyperlink != null && hyperlink[srcKey] != null) {
1867
+ file.hyperlink = __assign(__assign({}, file.hyperlink || {}), (_d = {}, _d[tgtKey] = _.cloneDeep(hyperlink[srcKey]), _d));
1868
+ var tgtCell = (_g = d[r]) === null || _g === void 0 ? void 0 : _g[c];
1869
+ if (tgtCell != null) tgtCell.hl = {
1870
+ r: r,
1871
+ c: c,
1872
+ id: ctx.currentSheetId
1873
+ };
1874
+ }
1875
+ if (cdformat != null && cdformat.length > 0) {
1876
+ for (var i = 0; i < cdformat.length; i += 1) {
1877
+ var ranges = cdformat[i].cellrange;
1878
+ if (!ranges) continue;
1879
+ for (var j = 0; j < ranges.length; j += 1) {
1880
+ var cr = ranges[j];
1881
+ if (r1 >= cr.row[0] && r1 <= cr.row[1] && c >= cr.column[0] && c <= cr.column[1]) {
1882
+ ranges.push({
1883
+ row: [r, r],
1884
+ column: [c, c]
1885
+ });
1886
+ break;
1887
+ }
1888
+ }
1889
+ }
1890
+ }
1891
+ }
1706
1892
  }
1707
1893
  }
1708
1894
  }
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 = 0; // 1970-01-01
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;
@@ -4,14 +4,14 @@ import { getFlowdata } from "../context";
4
4
  import { getSheetIndex, isAllowEdit, getLineCount } from "../utils";
5
5
  import { getRangetxt, isAllSelectedCellsInStatus, normalizedAttr, setCellValue } from "./cell";
6
6
  import { colors } from "./color";
7
- import { genarate, is_date, update } from "./format";
8
7
  import { getSelectionCharacterOffsets } from "./cursor";
8
+ import { datenum_local, genarate, is_date, update } from "./format";
9
9
  import { execfunction, execFunctionGroup, israngeseleciton, rangeSetValue, setCaretPosition, createFormulaRangeSelect } from "./formula";
10
10
  import { inlineStyleAffectAttribute, updateInlineStringFormat, updateInlineStringFormatOutside } from "./inline-string";
11
11
  import { colLocationByIndex, rowLocationByIndex } from "./location";
12
12
  import { normalizeSelection, selectionCopyShow, selectIsOverlap } from "./selection";
13
13
  import { sortSelection } from "./sort";
14
- import { hasPartMC, isdatatypemulti, isRealNull, isRealNum } from "./validation";
14
+ import { detectDateFormat, hasPartMC, isdatatypemulti, isRealNull, isRealNum } from "./validation";
15
15
  import { showLinkCard } from "./hyperlink";
16
16
  import { cfSplitRange } from "./conditionalFormat";
17
17
  import { clearMeasureTextCache, getCellTextInfo } from "./text";
@@ -34,21 +34,42 @@ export function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_
34
34
  } else {
35
35
  value = cell;
36
36
  }
37
+ var type = "n";
38
+ 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) {
39
+ type = "d";
40
+ } else if (foucsStatus === "@" || foucsStatus === 49) {
41
+ type = "s";
42
+ }
37
43
  if (_.isNil(value)) {
44
+ if (!_.isNil(d[r])) {
45
+ if (_.isNil(d[r][c])) {
46
+ d[r][c] = {
47
+ ct: {
48
+ fa: foucsStatus,
49
+ t: type
50
+ }
51
+ };
52
+ } else if (_.isPlainObject(d[r][c])) {
53
+ if (_.isNil(d[r][c].ct)) d[r][c].ct = {};
54
+ d[r][c].ct.fa = foucsStatus;
55
+ d[r][c].ct.t = type;
56
+ }
57
+ }
38
58
  continue;
39
59
  }
40
60
  if (foucsStatus !== "@" && isRealNum(value)) {
41
61
  value = Number(value);
62
+ } else if (type === "d" && typeof value === "string") {
63
+ var dateInfo = detectDateFormat(value);
64
+ if (dateInfo) {
65
+ var dateObj = new Date(dateInfo.year, dateInfo.month - 1, dateInfo.day, dateInfo.hours, dateInfo.minutes, dateInfo.seconds);
66
+ value = datenum_local(dateObj);
67
+ }
42
68
  }
43
- var mask = update(foucsStatus, value);
44
- var type = "n";
45
- 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) {
46
- type = "d";
47
- } else if (foucsStatus === "@" || foucsStatus === 49) {
48
- type = "s";
49
- } else if (foucsStatus === "General" || foucsStatus === 0) {
69
+ if (foucsStatus === "General" || foucsStatus === 0) {
50
70
  type = isRealNum(value) ? "n" : "g";
51
71
  }
72
+ var mask = update(foucsStatus, value);
52
73
  if (cell && _.isPlainObject(cell)) {
53
74
  cell.m = "".concat(mask);
54
75
  if (_.isNil(cell.ct)) {
@@ -56,7 +77,7 @@ export function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_
56
77
  }
57
78
  cell.ct.fa = foucsStatus;
58
79
  cell.ct.t = type;
59
- cell.v = String(value);
80
+ cell.v = typeof value === "number" ? value : String(value);
60
81
  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);
61
82
  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);
62
83
  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);
@@ -69,7 +90,7 @@ export function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_
69
90
  fa: foucsStatus,
70
91
  t: type
71
92
  },
72
- v: value,
93
+ v: typeof value === "number" ? value : value,
73
94
  m: mask
74
95
  };
75
96
  }
@@ -15,6 +15,16 @@ export declare function valueIsError(value: string): boolean;
15
15
  export declare function isRealNull(val: any): boolean;
16
16
  export declare function isHexValue(str: string): boolean;
17
17
  export declare function isRealNum(val: any): boolean;
18
+ export type DateFormatInfo = {
19
+ year: number;
20
+ month: number;
21
+ day: number;
22
+ hours: number;
23
+ minutes: number;
24
+ seconds: number;
25
+ formatType: string;
26
+ };
27
+ export declare function detectDateFormat(str: string): DateFormatInfo | null;
18
28
  export declare function isdatetime(s: any): boolean;
19
29
  export declare function diff(now: any, then: any): number;
20
30
  export declare function isdatatypemulti(s: any): any;