@leankylin-sheet/core 4.0.40 → 4.0.41

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/dist/index.esm.js CHANGED
@@ -35453,7 +35453,7 @@ for (var i = 0; i < operatorArr.length; i += 1) {
35453
35453
  var simpleSheetName = "[A-Za-z0-9_\u4E00-\u9FFF]+";
35454
35454
  var quotedSheetName = "'(?:(?!').|'')*'";
35455
35455
  var sheetNameRegexp = "(".concat(simpleSheetName, "|").concat(quotedSheetName, ")!");
35456
- var rowColumnRegexp = "[$]?[A-Za-z]+[$]?[0-9]+";
35456
+ var rowColumnRegexp = "[$]?[A-Za-z]+[$]?[0-9]*";
35457
35457
  var rowColumnWithSheetName = "(?:".concat(sheetNameRegexp, ")?(").concat(rowColumnRegexp, ")");
35458
35458
  var LABEL_EXTRACT_REGEXP = new RegExp("^".concat(rowColumnWithSheetName, "(?:[:]").concat(rowColumnWithSheetName, ")?$"));
35459
35459
  var FormulaCache = /*#__PURE__*/function () {
@@ -35509,16 +35509,20 @@ var FormulaCache = /*#__PURE__*/function () {
35509
35509
  var endRow = endCellCoord.row.index;
35510
35510
  var startCol = startCellCoord.column.index;
35511
35511
  var endCol = endCellCoord.column.index;
35512
- var emptyRow = startRow === -1 || endRow === -1;
35513
- var emptyCol = startCol === -1 || endCol === -1;
35514
- if (emptyRow) {
35515
- var _flowdata$length;
35512
+ var emptyRow = startRow === -1 && endRow === -1;
35513
+ var emptyCol = startCol === -1 && endCol === -1;
35514
+ if (startRow === -1) {
35516
35515
  startRow = 0;
35516
+ }
35517
+ if (endRow === -1) {
35518
+ var _flowdata$length;
35517
35519
  endRow = (_flowdata$length = flowdata === null || flowdata === void 0 ? void 0 : flowdata.length) !== null && _flowdata$length !== void 0 ? _flowdata$length : 0;
35518
35520
  }
35519
- if (emptyCol) {
35520
- var _flowdata$0$length;
35521
+ if (startCol === -1) {
35521
35522
  startCol = 0;
35523
+ }
35524
+ if (endCol === -1) {
35525
+ var _flowdata$0$length;
35522
35526
  endCol = (_flowdata$0$length = flowdata === null || flowdata === void 0 ? void 0 : flowdata[0].length) !== null && _flowdata$0$length !== void 0 ? _flowdata$0$length : 0;
35523
35527
  }
35524
35528
  if (emptyRow && emptyCol) throw Error(ERROR_REF);
@@ -36187,7 +36191,7 @@ function execFunctionGroup(ctx, origin_r, origin_c, value, id, data) {
36187
36191
  var cellCache = [[{
36188
36192
  v: undefined
36189
36193
  }]];
36190
- setCellValue(ctx, 0, 0, cellCache, value);
36194
+ setCellValue(ctx, 0, 0, cellCache, value, true);
36191
36195
  var _cellCache$ = _slicedToArray(cellCache[0], 1);
36192
36196
  ctx.formulaCache.execFunctionGlobalData["".concat(origin_r, "_").concat(origin_c, "_").concat(id)] = _cellCache$[0];
36193
36197
  }
@@ -36247,6 +36251,7 @@ function execFunctionGroup(ctx, origin_r, origin_c, value, id, data) {
36247
36251
  var formulaCell = calcChains[_i12];
36248
36252
  var key = "r".concat(formulaCell.r, "c").concat(formulaCell.c, "i").concat(formulaCell.id);
36249
36253
  var calc_funcStr = getcellFormula(ctx, formulaCell.r, formulaCell.c, formulaCell.id);
36254
+ console.log("calc_funcStr", key, calc_funcStr);
36250
36255
  if (_.isNil(calc_funcStr)) {
36251
36256
  return 1; // continue
36252
36257
  }
@@ -39831,50 +39836,8 @@ function getCellValue(r, c, data, attr) {
39831
39836
  }
39832
39837
  return retv;
39833
39838
  }
39834
- function setCellValue(ctx, r, c, d, v) {
39839
+ function setVUpdateStr(cell, vupdateStr, d, r, c, vupdate) {
39835
39840
  var _cell$ct, _cell$ct2, _cell$ct3, _cell$ct4, _cell$ct5, _cell$ct6;
39836
- if (_.isNil(d)) {
39837
- d = getFlowdata(ctx);
39838
- }
39839
- if (!d) return;
39840
- var cell = d[r][c];
39841
- var vupdate;
39842
- if (_.isPlainObject(v)) {
39843
- if (_.isNil(cell)) {
39844
- cell = v;
39845
- } else {
39846
- if (!_.isNil(v.f)) {
39847
- cell.f = v.f;
39848
- } else if ("f" in cell) {
39849
- delete cell.f;
39850
- }
39851
- if (!_.isNil(v.ct)) {
39852
- cell.ct = v.ct;
39853
- }
39854
- }
39855
- if (_.isPlainObject(v.v)) {
39856
- vupdate = v.v.v;
39857
- } else {
39858
- vupdate = v.v;
39859
- }
39860
- } else {
39861
- vupdate = v;
39862
- }
39863
- if (isRealNull(vupdate)) {
39864
- if (_.isPlainObject(cell)) {
39865
- delete cell.m;
39866
- delete cell.v;
39867
- } else {
39868
- cell = null;
39869
- }
39870
- d[r][c] = cell;
39871
- return;
39872
- }
39873
- if (isRealNull(cell) || (_.isString(cell) || _.isNumber(cell)) && cell === v) {
39874
- cell = {};
39875
- }
39876
- if (!cell) return;
39877
- var vupdateStr = vupdate.toString();
39878
39841
  if (vupdateStr.substr(0, 1) === "'") {
39879
39842
  cell.m = vupdateStr.substr(1);
39880
39843
  cell.ct = {
@@ -40010,7 +39973,67 @@ function setCellValue(ctx, r, c, d, v) {
40010
39973
  }
40011
39974
  }
40012
39975
  }
40013
- d[r][c] = cell;
39976
+ if (d[r]) {
39977
+ d[r][c] = cell;
39978
+ }
39979
+ }
39980
+ function setCellValue(ctx, r, c, d, v, isCache) {
39981
+ if (_.isNil(d)) {
39982
+ d = getFlowdata(ctx);
39983
+ }
39984
+ if (!d) return;
39985
+ var cell = d[r][c];
39986
+ var vupdate;
39987
+ if (_.isPlainObject(v)) {
39988
+ if (_.isNil(cell)) {
39989
+ cell = v;
39990
+ } else {
39991
+ if (!_.isNil(v.f)) {
39992
+ cell.f = v.f;
39993
+ } else if ("f" in cell) {
39994
+ delete cell.f;
39995
+ }
39996
+ if (!_.isNil(v.ct)) {
39997
+ cell.ct = v.ct;
39998
+ }
39999
+ }
40000
+ if (_.isPlainObject(v.v)) {
40001
+ vupdate = v.v.v;
40002
+ } else {
40003
+ vupdate = v.v;
40004
+ }
40005
+ } else {
40006
+ vupdate = v;
40007
+ }
40008
+ if (isRealNull(vupdate)) {
40009
+ if (_.isPlainObject(cell)) {
40010
+ delete cell.m;
40011
+ delete cell.v;
40012
+ } else {
40013
+ cell = null;
40014
+ }
40015
+ d[r][c] = cell;
40016
+ return;
40017
+ }
40018
+ if (isRealNull(cell) || (_.isString(cell) || _.isNumber(cell)) && cell === v) {
40019
+ cell = {};
40020
+ }
40021
+ if (!cell) return;
40022
+ if (Array.isArray(vupdate) && !isCache) {
40023
+ for (var rIndex = 0; rIndex < vupdate.length; rIndex++) {
40024
+ var _vupdate$rIndex;
40025
+ var row = (_vupdate$rIndex = vupdate[rIndex]) !== null && _vupdate$rIndex !== void 0 ? _vupdate$rIndex : "";
40026
+ for (var cIndex = 0; cIndex < row.length; cIndex++) {
40027
+ var vUpdateCell = row[cIndex] || "";
40028
+ var vupdateStr = vUpdateCell.toString();
40029
+ var _cell = _objectSpread2({}, cell || {});
40030
+ setVUpdateStr(_cell, vupdateStr, d, r + rIndex, c + cIndex, vUpdateCell);
40031
+ }
40032
+ }
40033
+ } else {
40034
+ var _vupdateStr = vupdate.toString();
40035
+ setVUpdateStr(cell, _vupdateStr, d, r, c, vupdate);
40036
+ }
40014
40037
  }
40015
40038
  function getRealCellValue(r, c, data, attr) {
40016
40039
  var value = getCellValue(r, c, data, "m");
package/dist/index.js CHANGED
@@ -35463,7 +35463,7 @@ for (var i = 0; i < operatorArr.length; i += 1) {
35463
35463
  var simpleSheetName = "[A-Za-z0-9_\u4E00-\u9FFF]+";
35464
35464
  var quotedSheetName = "'(?:(?!').|'')*'";
35465
35465
  var sheetNameRegexp = "(".concat(simpleSheetName, "|").concat(quotedSheetName, ")!");
35466
- var rowColumnRegexp = "[$]?[A-Za-z]+[$]?[0-9]+";
35466
+ var rowColumnRegexp = "[$]?[A-Za-z]+[$]?[0-9]*";
35467
35467
  var rowColumnWithSheetName = "(?:".concat(sheetNameRegexp, ")?(").concat(rowColumnRegexp, ")");
35468
35468
  var LABEL_EXTRACT_REGEXP = new RegExp("^".concat(rowColumnWithSheetName, "(?:[:]").concat(rowColumnWithSheetName, ")?$"));
35469
35469
  var FormulaCache = /*#__PURE__*/function () {
@@ -35519,16 +35519,20 @@ var FormulaCache = /*#__PURE__*/function () {
35519
35519
  var endRow = endCellCoord.row.index;
35520
35520
  var startCol = startCellCoord.column.index;
35521
35521
  var endCol = endCellCoord.column.index;
35522
- var emptyRow = startRow === -1 || endRow === -1;
35523
- var emptyCol = startCol === -1 || endCol === -1;
35524
- if (emptyRow) {
35525
- var _flowdata$length;
35522
+ var emptyRow = startRow === -1 && endRow === -1;
35523
+ var emptyCol = startCol === -1 && endCol === -1;
35524
+ if (startRow === -1) {
35526
35525
  startRow = 0;
35526
+ }
35527
+ if (endRow === -1) {
35528
+ var _flowdata$length;
35527
35529
  endRow = (_flowdata$length = flowdata === null || flowdata === void 0 ? void 0 : flowdata.length) !== null && _flowdata$length !== void 0 ? _flowdata$length : 0;
35528
35530
  }
35529
- if (emptyCol) {
35530
- var _flowdata$0$length;
35531
+ if (startCol === -1) {
35531
35532
  startCol = 0;
35533
+ }
35534
+ if (endCol === -1) {
35535
+ var _flowdata$0$length;
35532
35536
  endCol = (_flowdata$0$length = flowdata === null || flowdata === void 0 ? void 0 : flowdata[0].length) !== null && _flowdata$0$length !== void 0 ? _flowdata$0$length : 0;
35533
35537
  }
35534
35538
  if (emptyRow && emptyCol) throw Error(formulaParser.ERROR_REF);
@@ -36197,7 +36201,7 @@ function execFunctionGroup(ctx, origin_r, origin_c, value, id, data) {
36197
36201
  var cellCache = [[{
36198
36202
  v: undefined
36199
36203
  }]];
36200
- setCellValue(ctx, 0, 0, cellCache, value);
36204
+ setCellValue(ctx, 0, 0, cellCache, value, true);
36201
36205
  var _cellCache$ = _slicedToArray(cellCache[0], 1);
36202
36206
  ctx.formulaCache.execFunctionGlobalData["".concat(origin_r, "_").concat(origin_c, "_").concat(id)] = _cellCache$[0];
36203
36207
  }
@@ -36257,6 +36261,7 @@ function execFunctionGroup(ctx, origin_r, origin_c, value, id, data) {
36257
36261
  var formulaCell = calcChains[_i12];
36258
36262
  var key = "r".concat(formulaCell.r, "c").concat(formulaCell.c, "i").concat(formulaCell.id);
36259
36263
  var calc_funcStr = getcellFormula(ctx, formulaCell.r, formulaCell.c, formulaCell.id);
36264
+ console.log("calc_funcStr", key, calc_funcStr);
36260
36265
  if (___default['default'].isNil(calc_funcStr)) {
36261
36266
  return 1; // continue
36262
36267
  }
@@ -39841,50 +39846,8 @@ function getCellValue(r, c, data, attr) {
39841
39846
  }
39842
39847
  return retv;
39843
39848
  }
39844
- function setCellValue(ctx, r, c, d, v) {
39849
+ function setVUpdateStr(cell, vupdateStr, d, r, c, vupdate) {
39845
39850
  var _cell$ct, _cell$ct2, _cell$ct3, _cell$ct4, _cell$ct5, _cell$ct6;
39846
- if (___default['default'].isNil(d)) {
39847
- d = getFlowdata(ctx);
39848
- }
39849
- if (!d) return;
39850
- var cell = d[r][c];
39851
- var vupdate;
39852
- if (___default['default'].isPlainObject(v)) {
39853
- if (___default['default'].isNil(cell)) {
39854
- cell = v;
39855
- } else {
39856
- if (!___default['default'].isNil(v.f)) {
39857
- cell.f = v.f;
39858
- } else if ("f" in cell) {
39859
- delete cell.f;
39860
- }
39861
- if (!___default['default'].isNil(v.ct)) {
39862
- cell.ct = v.ct;
39863
- }
39864
- }
39865
- if (___default['default'].isPlainObject(v.v)) {
39866
- vupdate = v.v.v;
39867
- } else {
39868
- vupdate = v.v;
39869
- }
39870
- } else {
39871
- vupdate = v;
39872
- }
39873
- if (isRealNull(vupdate)) {
39874
- if (___default['default'].isPlainObject(cell)) {
39875
- delete cell.m;
39876
- delete cell.v;
39877
- } else {
39878
- cell = null;
39879
- }
39880
- d[r][c] = cell;
39881
- return;
39882
- }
39883
- if (isRealNull(cell) || (___default['default'].isString(cell) || ___default['default'].isNumber(cell)) && cell === v) {
39884
- cell = {};
39885
- }
39886
- if (!cell) return;
39887
- var vupdateStr = vupdate.toString();
39888
39851
  if (vupdateStr.substr(0, 1) === "'") {
39889
39852
  cell.m = vupdateStr.substr(1);
39890
39853
  cell.ct = {
@@ -40020,7 +39983,67 @@ function setCellValue(ctx, r, c, d, v) {
40020
39983
  }
40021
39984
  }
40022
39985
  }
40023
- d[r][c] = cell;
39986
+ if (d[r]) {
39987
+ d[r][c] = cell;
39988
+ }
39989
+ }
39990
+ function setCellValue(ctx, r, c, d, v, isCache) {
39991
+ if (___default['default'].isNil(d)) {
39992
+ d = getFlowdata(ctx);
39993
+ }
39994
+ if (!d) return;
39995
+ var cell = d[r][c];
39996
+ var vupdate;
39997
+ if (___default['default'].isPlainObject(v)) {
39998
+ if (___default['default'].isNil(cell)) {
39999
+ cell = v;
40000
+ } else {
40001
+ if (!___default['default'].isNil(v.f)) {
40002
+ cell.f = v.f;
40003
+ } else if ("f" in cell) {
40004
+ delete cell.f;
40005
+ }
40006
+ if (!___default['default'].isNil(v.ct)) {
40007
+ cell.ct = v.ct;
40008
+ }
40009
+ }
40010
+ if (___default['default'].isPlainObject(v.v)) {
40011
+ vupdate = v.v.v;
40012
+ } else {
40013
+ vupdate = v.v;
40014
+ }
40015
+ } else {
40016
+ vupdate = v;
40017
+ }
40018
+ if (isRealNull(vupdate)) {
40019
+ if (___default['default'].isPlainObject(cell)) {
40020
+ delete cell.m;
40021
+ delete cell.v;
40022
+ } else {
40023
+ cell = null;
40024
+ }
40025
+ d[r][c] = cell;
40026
+ return;
40027
+ }
40028
+ if (isRealNull(cell) || (___default['default'].isString(cell) || ___default['default'].isNumber(cell)) && cell === v) {
40029
+ cell = {};
40030
+ }
40031
+ if (!cell) return;
40032
+ if (Array.isArray(vupdate) && !isCache) {
40033
+ for (var rIndex = 0; rIndex < vupdate.length; rIndex++) {
40034
+ var _vupdate$rIndex;
40035
+ var row = (_vupdate$rIndex = vupdate[rIndex]) !== null && _vupdate$rIndex !== void 0 ? _vupdate$rIndex : "";
40036
+ for (var cIndex = 0; cIndex < row.length; cIndex++) {
40037
+ var vUpdateCell = row[cIndex] || "";
40038
+ var vupdateStr = vUpdateCell.toString();
40039
+ var _cell = _objectSpread2({}, cell || {});
40040
+ setVUpdateStr(_cell, vupdateStr, d, r + rIndex, c + cIndex, vUpdateCell);
40041
+ }
40042
+ }
40043
+ } else {
40044
+ var _vupdateStr = vupdate.toString();
40045
+ setVUpdateStr(cell, _vupdateStr, d, r, c, vupdate);
40046
+ }
40024
40047
  }
40025
40048
  function getRealCellValue(r, c, data, attr) {
40026
40049
  var value = getCellValue(r, c, data, "m");
@@ -3,7 +3,7 @@ import { Cell, CellMatrix, Range, Selection, SingleRange } from "../types";
3
3
  export declare function normalizedCellAttr(cell: Cell, attr: keyof Cell, defaultFontSize?: number): any;
4
4
  export declare function normalizedAttr(data: CellMatrix, r: number, c: number, attr: keyof Cell): any;
5
5
  export declare function getCellValue(r: number, c: number, data: CellMatrix, attr?: keyof Cell): any;
6
- export declare function setCellValue(ctx: Context, r: number, c: number, d: CellMatrix | null | undefined, v: any): void;
6
+ export declare function setCellValue(ctx: Context, r: number, c: number, d: CellMatrix | null | undefined, v: any, isCache?: boolean): void;
7
7
  export declare function getRealCellValue(r: number, c: number, data: CellMatrix, attr?: keyof Cell): any;
8
8
  export declare function mergeBorder(ctx: Context, d: CellMatrix, row_index: number, col_index: number): {
9
9
  row: number[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leankylin-sheet/core",
3
- "version": "4.0.40",
3
+ "version": "4.0.41",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.esm.js",
6
6
  "typings": "dist/index.d.ts",
@@ -13,7 +13,7 @@
13
13
  "build": "father-build"
14
14
  },
15
15
  "dependencies": {
16
- "@leankylin-sheet/formula-parser": "4.0.40",
16
+ "@leankylin-sheet/formula-parser": "4.0.41",
17
17
  "dayjs": "^1.11.0",
18
18
  "immer": "^9.0.12",
19
19
  "lodash": "^4.17.21",