@leankylin-sheet/react 5.2.14 → 5.2.16

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.
@@ -119,7 +119,7 @@ export declare function generateAPIs(context: Context, setContext: (recipe: (ctx
119
119
  }[]) => void;
120
120
  handleUndo: () => void;
121
121
  handleRedo: () => void;
122
- calculateFormula: (sheetId?: string) => void;
122
+ calculateFormula: (sheetId?: string, isrefresh?: boolean) => void;
123
123
  calculateSheetByCells: (cells: any) => void;
124
124
  dataToCelldata: (data: CellMatrix | undefined) => CellWithRowAndCol[];
125
125
  celldataToData: (celldata: CellWithRowAndCol[], rowCount?: number, colCount?: number) => CellMatrix | null;
@@ -127,7 +127,7 @@ declare const Workbook: React.ForwardRefExoticComponent<Settings & AdditionalPro
127
127
  }[]) => void;
128
128
  handleUndo: () => void;
129
129
  handleRedo: () => void;
130
- calculateFormula: (sheetId?: string | undefined) => void;
130
+ calculateFormula: (sheetId?: string | undefined, isrefresh?: boolean) => void;
131
131
  calculateSheetByCells: (cells: any) => void;
132
132
  dataToCelldata: (data: CellMatrix | undefined) => CellWithRowAndCol[];
133
133
  celldataToData: (celldata: CellWithRowAndCol[], rowCount?: number | undefined, colCount?: number | undefined) => CellMatrix | null;
package/dist/index.esm.js CHANGED
@@ -3561,12 +3561,12 @@ var DropDownList = function DropDownList() {
3561
3561
  };
3562
3562
 
3563
3563
  var CellOptions = function CellOptions() {
3564
- var _context$cellOptions;
3565
3564
  var _useContext = useContext(WorkbookContext),
3566
3565
  context = _useContext.context,
3567
3566
  refs = _useContext.refs,
3568
3567
  settings = _useContext.settings;
3569
- var cellOptions = (_context$cellOptions = context.cellOptions) !== null && _context$cellOptions !== void 0 ? _context$cellOptions : [];
3568
+ var currentSheet = context.luckysheetfile[getSheetIndex(context, context.currentSheetId)];
3569
+ var cellOptions = currentSheet.cellOptions;
3570
3570
  return /*#__PURE__*/React.createElement("div", {
3571
3571
  className: "leankylin-cell-option"
3572
3572
  }, cellOptions === null || cellOptions === void 0 ? void 0 : cellOptions.map(function (item) {
@@ -10011,6 +10011,8 @@ function generateAPIs(context, setContext, handleUndo, handleRedo, settings, cel
10011
10011
  setCellOptions: function setCellOptions(cellOptions) {
10012
10012
  return setContext(function (ctx) {
10013
10013
  ctx.cellOptions = cellOptions;
10014
+ var index = getSheetIndex(ctx, context.currentSheetId);
10015
+ ctx.luckysheetfile[index].cellOptions = cellOptions;
10014
10016
  });
10015
10017
  },
10016
10018
  applyOp: function applyOp(ops) {
@@ -10275,13 +10277,14 @@ function generateAPIs(context, setContext, handleUndo, handleRedo, settings, cel
10275
10277
  handleUndo: handleUndo,
10276
10278
  handleRedo: handleRedo,
10277
10279
  calculateFormula: function calculateFormula(sheetId) {
10280
+ var isrefresh = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
10278
10281
  setContext(function (draftCtx) {
10279
10282
  api.updateFunctionGroup(draftCtx);
10280
10283
  if (sheetId) {
10281
- api.calculateSheetFromula(draftCtx, sheetId);
10284
+ api.calculateSheetFromula(draftCtx, sheetId, isrefresh);
10282
10285
  } else {
10283
10286
  _.forEach(draftCtx.luckysheetfile, function (sheet_obj) {
10284
- api.calculateSheetFromula(draftCtx, sheet_obj.id);
10287
+ api.calculateSheetFromula(draftCtx, sheet_obj.id, isrefresh);
10285
10288
  });
10286
10289
  }
10287
10290
  });
package/dist/index.js CHANGED
@@ -3571,12 +3571,12 @@ var DropDownList = function DropDownList() {
3571
3571
  };
3572
3572
 
3573
3573
  var CellOptions = function CellOptions() {
3574
- var _context$cellOptions;
3575
3574
  var _useContext = React.useContext(WorkbookContext),
3576
3575
  context = _useContext.context,
3577
3576
  refs = _useContext.refs,
3578
3577
  settings = _useContext.settings;
3579
- var cellOptions = (_context$cellOptions = context.cellOptions) !== null && _context$cellOptions !== void 0 ? _context$cellOptions : [];
3578
+ var currentSheet = context.luckysheetfile[core.getSheetIndex(context, context.currentSheetId)];
3579
+ var cellOptions = currentSheet.cellOptions;
3580
3580
  return /*#__PURE__*/React__default['default'].createElement("div", {
3581
3581
  className: "leankylin-cell-option"
3582
3582
  }, cellOptions === null || cellOptions === void 0 ? void 0 : cellOptions.map(function (item) {
@@ -10021,6 +10021,8 @@ function generateAPIs(context, setContext, handleUndo, handleRedo, settings, cel
10021
10021
  setCellOptions: function setCellOptions(cellOptions) {
10022
10022
  return setContext(function (ctx) {
10023
10023
  ctx.cellOptions = cellOptions;
10024
+ var index = core.getSheetIndex(ctx, context.currentSheetId);
10025
+ ctx.luckysheetfile[index].cellOptions = cellOptions;
10024
10026
  });
10025
10027
  },
10026
10028
  applyOp: function applyOp(ops) {
@@ -10285,13 +10287,14 @@ function generateAPIs(context, setContext, handleUndo, handleRedo, settings, cel
10285
10287
  handleUndo: handleUndo,
10286
10288
  handleRedo: handleRedo,
10287
10289
  calculateFormula: function calculateFormula(sheetId) {
10290
+ var isrefresh = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
10288
10291
  setContext(function (draftCtx) {
10289
10292
  core.api.updateFunctionGroup(draftCtx);
10290
10293
  if (sheetId) {
10291
- core.api.calculateSheetFromula(draftCtx, sheetId);
10294
+ core.api.calculateSheetFromula(draftCtx, sheetId, isrefresh);
10292
10295
  } else {
10293
10296
  ___default['default'].forEach(draftCtx.luckysheetfile, function (sheet_obj) {
10294
- core.api.calculateSheetFromula(draftCtx, sheet_obj.id);
10297
+ core.api.calculateSheetFromula(draftCtx, sheet_obj.id, isrefresh);
10295
10298
  });
10296
10299
  }
10297
10300
  });
package/dist/index.umd.js CHANGED
@@ -42175,7 +42175,6 @@
42175
42175
  * @returns {*}
42176
42176
  */
42177
42177
  function toNumber(number) {
42178
- var _result;
42179
42178
  var result;
42180
42179
  if (number === true) {
42181
42180
  return 1;
@@ -42185,7 +42184,7 @@
42185
42184
  } else if (typeof number === 'string') {
42186
42185
  result = number.indexOf('.') > -1 ? parseFloat(number) : parseInt(number, 10);
42187
42186
  }
42188
- return (_result = result) !== null && _result !== void 0 ? _result : 0;
42187
+ return result || 0;
42189
42188
  }
42190
42189
 
42191
42190
  /**
@@ -42198,7 +42197,7 @@
42198
42197
  return -1 * toNumber(number);
42199
42198
  }
42200
42199
  function toNumberNotNaN(number) {
42201
- var _result2;
42200
+ var _result;
42202
42201
  var result;
42203
42202
  if (number === true) {
42204
42203
  return 1;
@@ -42211,7 +42210,7 @@
42211
42210
  if (isNaN(result)) {
42212
42211
  return 0;
42213
42212
  }
42214
- return (_result2 = result) !== null && _result2 !== void 0 ? _result2 : 0;
42213
+ return (_result = result) !== null && _result !== void 0 ? _result : 0;
42215
42214
  }
42216
42215
 
42217
42216
  var ERROR$1 = 'ERROR';
@@ -42328,6 +42327,9 @@
42328
42327
  } else if (type === ">=") {
42329
42328
  return tsValue(exp1) >= tsValue(exp2);
42330
42329
  } else if (type === "=") {
42330
+ if (exp1 === 0 || exp2 === 0) {
42331
+ return (exp1 || 0) === (exp2 || 0);
42332
+ }
42331
42333
  return tsValue(exp1) === tsValue(exp2);
42332
42334
  }
42333
42335
  }
@@ -42365,6 +42367,7 @@
42365
42367
  foundFormula = true;
42366
42368
  params = tsParams(symbolParts[0], params);
42367
42369
  result = formulajs[symbolParts[0]].apply(formulajs, _toConsumableArray$1(params));
42370
+ result = tsResult(symbolParts[0], result);
42368
42371
  }
42369
42372
  } else {
42370
42373
  var length = symbolParts.length;
@@ -42423,6 +42426,17 @@
42423
42426
  }
42424
42427
  return params;
42425
42428
  }
42429
+ function tsResult(fnName, result) {
42430
+ if (fnName === 'UNIQUE') {
42431
+ if (Array.isArray(result) && Array.isArray(result[0])) {
42432
+ var uniResult = _toConsumableArray$1(new Set(result[0].flat()));
42433
+ return uniResult === null || uniResult === void 0 ? void 0 : uniResult.map(function (item) {
42434
+ return [[item]];
42435
+ });
42436
+ }
42437
+ }
42438
+ return result;
42439
+ }
42426
42440
 
42427
42441
  var SYMBOL$5 = '>';
42428
42442
  function func$5(exp1, exp2) {
@@ -80577,7 +80591,12 @@
80577
80591
  formulaError = _ctx$formulaCache$par.error;
80578
80592
  if (!lodash.isNil(r) && !lodash.isNil(c)) {
80579
80593
  if (isrefresh) {
80580
- execFunctionGroup(ctx, r, c, lodash.isNil(formulaError) ? result : formulaError, id);
80594
+ var _data$r;
80595
+ var data = getFlowdata(ctx, id);
80596
+ var cell = data === null || data === void 0 ? void 0 : (_data$r = data[r]) === null || _data$r === void 0 ? void 0 : _data$r[c];
80597
+ if ((cell === null || cell === void 0 ? void 0 : cell.v) !== result) {
80598
+ execFunctionGroup(ctx, r, c, lodash.isNil(formulaError) ? result : formulaError, id);
80599
+ }
80581
80600
  }
80582
80601
  if (!notInsertFunc) {
80583
80602
  insertUpdateFunctionGroup(ctx, r, c, id);
@@ -88978,7 +88997,7 @@
88978
88997
  rs: rs,
88979
88998
  cs: cs
88980
88999
  };
88981
- } else if (index === c) {
89000
+ } else if (index === c && cs !== 1) {
88982
89001
  if (direction === "lefttop") {
88983
89002
  merge_new["".concat(r, "_").concat(c + count)] = {
88984
89003
  r: r,
@@ -90872,11 +90891,6 @@
90872
90891
  console.time("calcTime:".concat(id));
90873
90892
  var index$1 = getSheetIndex(ctx, id);
90874
90893
  var luckysheetfile = ctx.luckysheetfile;
90875
- var file = luckysheetfile[index$1];
90876
- var calcChain = file.calcChain;
90877
- if (lodash.isNil(calcChain)) {
90878
- calcChain = [];
90879
- }
90880
90894
  if (!ctx.luckysheetfile[index$1].data) return;
90881
90895
  for (var r = 0; r < ctx.luckysheetfile[index$1].data.length; r += 1) {
90882
90896
  for (var c = 0; c < ctx.luckysheetfile[index$1].data[r].length; c += 1) {
@@ -90884,13 +90898,7 @@
90884
90898
  if (!(cell === null || cell === void 0 ? void 0 : cell.f)) {
90885
90899
  continue;
90886
90900
  }
90887
- var cc = {
90888
- r: r,
90889
- c: c,
90890
- id: id
90891
- };
90892
- calcChain.push(cc);
90893
- var result = execfunction(ctx, cell === null || cell === void 0 ? void 0 : cell.f, r, c, id, undefined, true);
90901
+ var result = execfunction(ctx, cell === null || cell === void 0 ? void 0 : cell.f, r, c, id, false, true);
90894
90902
  var newV = result[1];
90895
90903
  if (newV === cell.v) {
90896
90904
  continue;
@@ -90900,12 +90908,32 @@
90900
90908
  });
90901
90909
  }
90902
90910
  }
90903
- file.calcChain = lodash.uniqBy(calcChain, function (item) {
90904
- return item.r + item.c + item.id;
90905
- });
90906
90911
  ctx.luckysheetfile = luckysheetfile;
90907
90912
  console.timeEnd("calcTime:".concat(id));
90908
90913
  }
90914
+ function updateFunctionGroup(ctx) {
90915
+ var luckysheetfile = ctx.luckysheetfile;
90916
+ for (var index = 0; index < luckysheetfile.length; index++) {
90917
+ var file = luckysheetfile[index];
90918
+ var calcChain = [];
90919
+ if (!ctx.luckysheetfile[index].data) return;
90920
+ for (var r = 0; r < ctx.luckysheetfile[index].data.length; r += 1) {
90921
+ for (var c = 0; c < ctx.luckysheetfile[index].data[r].length; c += 1) {
90922
+ var cell = ctx.luckysheetfile[index].data[r][c];
90923
+ if (!(cell === null || cell === void 0 ? void 0 : cell.f)) {
90924
+ continue;
90925
+ }
90926
+ var cc = {
90927
+ r: r,
90928
+ c: c,
90929
+ id: file.id
90930
+ };
90931
+ calcChain.push(cc);
90932
+ }
90933
+ }
90934
+ file.calcChain = calcChain;
90935
+ }
90936
+ }
90909
90937
  function parseCellReferences(expression) {
90910
90938
  if (typeof expression !== "string" || expression.trim() === "") {
90911
90939
  return [];
@@ -100599,6 +100627,7 @@
100599
100627
  showSheet: showSheet,
100600
100628
  copySheet: copySheet,
100601
100629
  calculateSheetFromula: calculateSheetFromula,
100630
+ updateFunctionGroup: updateFunctionGroup,
100602
100631
  calculateSheetByCells: calculateSheetByCells,
100603
100632
  addSheet: addSheet$1,
100604
100633
  deleteSheet: deleteSheet$1,
@@ -100621,6 +100650,7 @@
100621
100650
  renderEditorSelector: undefined,
100622
100651
  copyRich: false,
100623
100652
  renderCalcInfo: undefined,
100653
+ renderCellOptions: undefined,
100624
100654
  renderFreezeCol: undefined,
100625
100655
  renderFreezeRow: undefined,
100626
100656
  renderFilter: undefined,
@@ -108410,12 +108440,12 @@
108410
108440
  };
108411
108441
 
108412
108442
  var CellOptions = function CellOptions() {
108413
- var _context$cellOptions;
108414
108443
  var _useContext = React.useContext(WorkbookContext),
108415
108444
  context = _useContext.context,
108416
108445
  refs = _useContext.refs,
108417
108446
  settings = _useContext.settings;
108418
- var cellOptions = (_context$cellOptions = context.cellOptions) !== null && _context$cellOptions !== void 0 ? _context$cellOptions : [];
108447
+ var currentSheet = context.luckysheetfile[getSheetIndex(context, context.currentSheetId)];
108448
+ var cellOptions = currentSheet.cellOptions;
108419
108449
  return /*#__PURE__*/React__default['default'].createElement("div", {
108420
108450
  className: "leankylin-cell-option"
108421
108451
  }, cellOptions === null || cellOptions === void 0 ? void 0 : cellOptions.map(function (item) {
@@ -114860,6 +114890,8 @@
114860
114890
  setCellOptions: function setCellOptions(cellOptions) {
114861
114891
  return setContext(function (ctx) {
114862
114892
  ctx.cellOptions = cellOptions;
114893
+ var index = getSheetIndex(ctx, context.currentSheetId);
114894
+ ctx.luckysheetfile[index].cellOptions = cellOptions;
114863
114895
  });
114864
114896
  },
114865
114897
  applyOp: function applyOp(ops) {
@@ -115124,13 +115156,14 @@
115124
115156
  handleUndo: handleUndo,
115125
115157
  handleRedo: handleRedo,
115126
115158
  calculateFormula: function calculateFormula(sheetId) {
115159
+ var isrefresh = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
115127
115160
  setContext(function (draftCtx) {
115128
115161
  index.updateFunctionGroup(draftCtx);
115129
115162
  if (sheetId) {
115130
- index.calculateSheetFromula(draftCtx, sheetId);
115163
+ index.calculateSheetFromula(draftCtx, sheetId, isrefresh);
115131
115164
  } else {
115132
115165
  lodash.forEach(draftCtx.luckysheetfile, function (sheet_obj) {
115133
- index.calculateSheetFromula(draftCtx, sheet_obj.id);
115166
+ index.calculateSheetFromula(draftCtx, sheet_obj.id, isrefresh);
115134
115167
  });
115135
115168
  }
115136
115169
  });