@leankylin-sheet/react 5.2.13 → 5.2.15

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
@@ -3561,15 +3561,16 @@ 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
- refs = _useContext.refs;
3568
- var cellOptions = (_context$cellOptions = context.cellOptions) !== null && _context$cellOptions !== void 0 ? _context$cellOptions : [];
3566
+ refs = _useContext.refs,
3567
+ settings = _useContext.settings;
3568
+ var currentSheet = context.luckysheetfile[getSheetIndex(context, context.currentSheetId)];
3569
+ var cellOptions = currentSheet.cellOptions;
3569
3570
  return /*#__PURE__*/React.createElement("div", {
3570
3571
  className: "leankylin-cell-option"
3571
3572
  }, cellOptions === null || cellOptions === void 0 ? void 0 : cellOptions.map(function (item) {
3572
- var _refs$globalCache$fre, _refs$globalCache$fre2, _refs$globalCache$fre3, _refs$globalCache$fre4, _refs$globalCache$fre5, _refs$globalCache$fre6, _refs$globalCache$fre7, _refs$globalCache$fre8, _refs$globalCache$fre9, _refs$globalCache$fre10, _item$render;
3573
+ var _refs$globalCache$fre, _refs$globalCache$fre2, _refs$globalCache$fre3, _refs$globalCache$fre4, _refs$globalCache$fre5, _refs$globalCache$fre6, _refs$globalCache$fre7, _refs$globalCache$fre8, _refs$globalCache$fre9, _refs$globalCache$fre10, _item$render, _settings$renderCellO;
3573
3574
  var _colLocationByIndex = colLocationByIndex(item.c, context.visibledatacolumn),
3574
3575
  _colLocationByIndex2 = _slicedToArray(_colLocationByIndex, 2),
3575
3576
  left = _colLocationByIndex2[0],
@@ -3597,7 +3598,7 @@ var CellOptions = function CellOptions() {
3597
3598
  width: right - left,
3598
3599
  height: bottom - top
3599
3600
  }, otherStyles)
3600
- }, item === null || item === void 0 ? void 0 : (_item$render = item.render) === null || _item$render === void 0 ? void 0 : _item$render.call(item, item));
3601
+ }, (item === null || item === void 0 ? void 0 : item.render) ? item === null || item === void 0 ? void 0 : (_item$render = item.render) === null || _item$render === void 0 ? void 0 : _item$render.call(item, item) : (_settings$renderCellO = settings.renderCellOptions) === null || _settings$renderCellO === void 0 ? void 0 : _settings$renderCellO.call(settings, item));
3601
3602
  }));
3602
3603
  };
3603
3604
 
@@ -10010,6 +10011,8 @@ function generateAPIs(context, setContext, handleUndo, handleRedo, settings, cel
10010
10011
  setCellOptions: function setCellOptions(cellOptions) {
10011
10012
  return setContext(function (ctx) {
10012
10013
  ctx.cellOptions = cellOptions;
10014
+ var index = getSheetIndex(ctx, context.currentSheetId);
10015
+ ctx.luckysheetfile[index].cellOptions = cellOptions;
10013
10016
  });
10014
10017
  },
10015
10018
  applyOp: function applyOp(ops) {
package/dist/index.js CHANGED
@@ -3571,15 +3571,16 @@ 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
- refs = _useContext.refs;
3578
- var cellOptions = (_context$cellOptions = context.cellOptions) !== null && _context$cellOptions !== void 0 ? _context$cellOptions : [];
3576
+ refs = _useContext.refs,
3577
+ settings = _useContext.settings;
3578
+ var currentSheet = context.luckysheetfile[core.getSheetIndex(context, context.currentSheetId)];
3579
+ var cellOptions = currentSheet.cellOptions;
3579
3580
  return /*#__PURE__*/React__default['default'].createElement("div", {
3580
3581
  className: "leankylin-cell-option"
3581
3582
  }, cellOptions === null || cellOptions === void 0 ? void 0 : cellOptions.map(function (item) {
3582
- var _refs$globalCache$fre, _refs$globalCache$fre2, _refs$globalCache$fre3, _refs$globalCache$fre4, _refs$globalCache$fre5, _refs$globalCache$fre6, _refs$globalCache$fre7, _refs$globalCache$fre8, _refs$globalCache$fre9, _refs$globalCache$fre10, _item$render;
3583
+ var _refs$globalCache$fre, _refs$globalCache$fre2, _refs$globalCache$fre3, _refs$globalCache$fre4, _refs$globalCache$fre5, _refs$globalCache$fre6, _refs$globalCache$fre7, _refs$globalCache$fre8, _refs$globalCache$fre9, _refs$globalCache$fre10, _item$render, _settings$renderCellO;
3583
3584
  var _colLocationByIndex = core.colLocationByIndex(item.c, context.visibledatacolumn),
3584
3585
  _colLocationByIndex2 = _slicedToArray(_colLocationByIndex, 2),
3585
3586
  left = _colLocationByIndex2[0],
@@ -3607,7 +3608,7 @@ var CellOptions = function CellOptions() {
3607
3608
  width: right - left,
3608
3609
  height: bottom - top
3609
3610
  }, otherStyles)
3610
- }, item === null || item === void 0 ? void 0 : (_item$render = item.render) === null || _item$render === void 0 ? void 0 : _item$render.call(item, item));
3611
+ }, (item === null || item === void 0 ? void 0 : item.render) ? item === null || item === void 0 ? void 0 : (_item$render = item.render) === null || _item$render === void 0 ? void 0 : _item$render.call(item, item) : (_settings$renderCellO = settings.renderCellOptions) === null || _settings$renderCellO === void 0 ? void 0 : _settings$renderCellO.call(settings, item));
3611
3612
  }));
3612
3613
  };
3613
3614
 
@@ -10020,6 +10021,8 @@ function generateAPIs(context, setContext, handleUndo, handleRedo, settings, cel
10020
10021
  setCellOptions: function setCellOptions(cellOptions) {
10021
10022
  return setContext(function (ctx) {
10022
10023
  ctx.cellOptions = cellOptions;
10024
+ var index = core.getSheetIndex(ctx, context.currentSheetId);
10025
+ ctx.luckysheetfile[index].cellOptions = cellOptions;
10023
10026
  });
10024
10027
  },
10025
10028
  applyOp: function applyOp(ops) {
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,15 +108440,16 @@
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
- refs = _useContext.refs;
108417
- var cellOptions = (_context$cellOptions = context.cellOptions) !== null && _context$cellOptions !== void 0 ? _context$cellOptions : [];
108445
+ refs = _useContext.refs,
108446
+ settings = _useContext.settings;
108447
+ var currentSheet = context.luckysheetfile[getSheetIndex(context, context.currentSheetId)];
108448
+ var cellOptions = currentSheet.cellOptions;
108418
108449
  return /*#__PURE__*/React__default['default'].createElement("div", {
108419
108450
  className: "leankylin-cell-option"
108420
108451
  }, cellOptions === null || cellOptions === void 0 ? void 0 : cellOptions.map(function (item) {
108421
- var _refs$globalCache$fre, _refs$globalCache$fre2, _refs$globalCache$fre3, _refs$globalCache$fre4, _refs$globalCache$fre5, _refs$globalCache$fre6, _refs$globalCache$fre7, _refs$globalCache$fre8, _refs$globalCache$fre9, _refs$globalCache$fre10, _item$render;
108452
+ var _refs$globalCache$fre, _refs$globalCache$fre2, _refs$globalCache$fre3, _refs$globalCache$fre4, _refs$globalCache$fre5, _refs$globalCache$fre6, _refs$globalCache$fre7, _refs$globalCache$fre8, _refs$globalCache$fre9, _refs$globalCache$fre10, _item$render, _settings$renderCellO;
108422
108453
  var _colLocationByIndex = colLocationByIndex(item.c, context.visibledatacolumn),
108423
108454
  _colLocationByIndex2 = _slicedToArray(_colLocationByIndex, 2),
108424
108455
  left = _colLocationByIndex2[0],
@@ -108446,7 +108477,7 @@
108446
108477
  width: right - left,
108447
108478
  height: bottom - top
108448
108479
  }, otherStyles)
108449
- }, item === null || item === void 0 ? void 0 : (_item$render = item.render) === null || _item$render === void 0 ? void 0 : _item$render.call(item, item));
108480
+ }, (item === null || item === void 0 ? void 0 : item.render) ? item === null || item === void 0 ? void 0 : (_item$render = item.render) === null || _item$render === void 0 ? void 0 : _item$render.call(item, item) : (_settings$renderCellO = settings.renderCellOptions) === null || _settings$renderCellO === void 0 ? void 0 : _settings$renderCellO.call(settings, item));
108450
108481
  }));
108451
108482
  };
108452
108483
 
@@ -114859,6 +114890,8 @@
114859
114890
  setCellOptions: function setCellOptions(cellOptions) {
114860
114891
  return setContext(function (ctx) {
114861
114892
  ctx.cellOptions = cellOptions;
114893
+ var index = getSheetIndex(ctx, context.currentSheetId);
114894
+ ctx.luckysheetfile[index].cellOptions = cellOptions;
114862
114895
  });
114863
114896
  },
114864
114897
  applyOp: function applyOp(ops) {