@odoo/o-spreadsheet 16.0.26 → 16.0.27

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.
@@ -3884,6 +3884,7 @@
3884
3884
  return node.description ? node.description : "";
3885
3885
  }
3886
3886
 
3887
+ const macRegex = /Mac/i;
3887
3888
  /**
3888
3889
  * Return true if the event was triggered from
3889
3890
  * a child element.
@@ -3903,7 +3904,15 @@
3903
3904
  return Array.from(document.querySelectorAll(".o-spreadsheet .o-menu"));
3904
3905
  }
3905
3906
  function isMacOS() {
3906
- return navigator.userAgent.toUpperCase().indexOf("MAC") >= 0;
3907
+ return Boolean(macRegex.test(navigator.userAgent));
3908
+ }
3909
+ /**
3910
+ * @param {KeyboardEvent | MouseEvent} ev
3911
+ * @returns Returns true if the event was triggered with the "ctrl" modifier pressed.
3912
+ * On Mac, this is the "meta" or "command" key.
3913
+ */
3914
+ function isCtrlKey(ev) {
3915
+ return isMacOS() ? ev.metaKey : ev.ctrlKey;
3907
3916
  }
3908
3917
 
3909
3918
  /**
@@ -21473,7 +21482,10 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
21473
21482
  return;
21474
21483
  }
21475
21484
  const [col, row] = this.getCartesianCoordinates(ev);
21476
- this.props.onCellClicked(col, row, { shiftKey: ev.shiftKey, ctrlKey: ev.ctrlKey });
21485
+ this.props.onCellClicked(col, row, {
21486
+ expandZone: ev.shiftKey,
21487
+ addZone: isCtrlKey(ev),
21488
+ });
21477
21489
  }
21478
21490
  onDoubleClick(ev) {
21479
21491
  const [col, row] = this.getCartesianCoordinates(ev);
@@ -21701,7 +21713,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
21701
21713
  this._increaseSelection(index);
21702
21714
  }
21703
21715
  else {
21704
- this._selectElement(index, ev.ctrlKey);
21716
+ this._selectElement(index, isCtrlKey(ev));
21705
21717
  }
21706
21718
  this.lastSelectedElementIndex = index;
21707
21719
  const mouseMoveSelect = (col, row) => {
@@ -21714,7 +21726,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
21714
21726
  const mouseUpSelect = () => {
21715
21727
  this.state.isSelecting = false;
21716
21728
  this.lastSelectedElementIndex = null;
21717
- this.env.model.dispatch(ev.ctrlKey ? "PREPARE_SELECTION_INPUT_EXPANSION" : "STOP_SELECTION_INPUT");
21729
+ this.env.model.dispatch(isCtrlKey(ev) ? "PREPARE_SELECTION_INPUT_EXPANSION" : "STOP_SELECTION_INPUT");
21718
21730
  this._computeGrabDisplay(ev);
21719
21731
  };
21720
21732
  dragAndDropBeyondTheViewport(this.env, mouseMoveSelect, mouseUpSelect);
@@ -21861,8 +21873,8 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
21861
21873
  this.env.raiseError(MergeErrorMessage);
21862
21874
  }
21863
21875
  }
21864
- _selectElement(index, ctrlKey) {
21865
- this.env.model.selection.selectColumn(index, ctrlKey ? "newAnchor" : "overrideSelection");
21876
+ _selectElement(index, addDistinctHeader) {
21877
+ this.env.model.selection.selectColumn(index, addDistinctHeader ? "newAnchor" : "overrideSelection");
21866
21878
  }
21867
21879
  _increaseSelection(index) {
21868
21880
  this.env.model.selection.selectColumn(index, "updateAnchor");
@@ -22031,8 +22043,8 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
22031
22043
  this.env.raiseError(MergeErrorMessage);
22032
22044
  }
22033
22045
  }
22034
- _selectElement(index, ctrlKey) {
22035
- this.env.model.selection.selectRow(index, ctrlKey ? "newAnchor" : "overrideSelection");
22046
+ _selectElement(index, addDistinctHeader) {
22047
+ this.env.model.selection.selectRow(index, addDistinctHeader ? "newAnchor" : "overrideSelection");
22036
22048
  }
22037
22049
  _increaseSelection(index) {
22038
22050
  this.env.model.selection.selectRow(index, "updateAnchor");
@@ -22723,18 +22735,18 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
22723
22735
  // ---------------------------------------------------------------------------
22724
22736
  // Zone selection with mouse
22725
22737
  // ---------------------------------------------------------------------------
22726
- onCellClicked(col, row, { ctrlKey, shiftKey }) {
22727
- if (ctrlKey) {
22738
+ onCellClicked(col, row, { addZone, expandZone }) {
22739
+ if (addZone) {
22728
22740
  this.env.model.dispatch("PREPARE_SELECTION_INPUT_EXPANSION");
22729
22741
  }
22730
22742
  this.closeOpenedPopover();
22731
22743
  if (this.env.model.getters.getEditionMode() === "editing") {
22732
22744
  this.env.model.dispatch("STOP_EDITION");
22733
22745
  }
22734
- if (shiftKey) {
22746
+ if (expandZone) {
22735
22747
  this.env.model.selection.setAnchorCorner(col, row);
22736
22748
  }
22737
- else if (ctrlKey) {
22749
+ else if (addZone) {
22738
22750
  this.env.model.selection.addCellToSelection(col, row);
22739
22751
  }
22740
22752
  else {
@@ -22788,10 +22800,10 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
22788
22800
  };
22789
22801
  const direction = arrowMap[ev.key];
22790
22802
  if (ev.shiftKey) {
22791
- this.env.model.selection.resizeAnchorZone(direction, ev.ctrlKey ? "end" : 1);
22803
+ this.env.model.selection.resizeAnchorZone(direction, isCtrlKey(ev) ? "end" : 1);
22792
22804
  }
22793
22805
  else {
22794
- this.env.model.selection.moveAnchorCell(direction, ev.ctrlKey ? "end" : 1);
22806
+ this.env.model.selection.moveAnchorCell(direction, isCtrlKey(ev) ? "end" : 1);
22795
22807
  }
22796
22808
  if (this.env.model.getters.isPaintingFormat()) {
22797
22809
  this.env.model.dispatch("PASTE", {
@@ -22805,9 +22817,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
22805
22817
  return;
22806
22818
  }
22807
22819
  let keyDownString = "";
22808
- if (ev.ctrlKey)
22809
- keyDownString += "CTRL+";
22810
- if (ev.metaKey)
22820
+ if (isCtrlKey(ev))
22811
22821
  keyDownString += "CTRL+";
22812
22822
  if (ev.altKey)
22813
22823
  keyDownString += "ALT+";
@@ -32568,13 +32578,18 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
32568
32578
  // Getters
32569
32579
  // ---------------------------------------------------------------------------
32570
32580
  evaluateFormula(formulaString, sheetId = this.getters.getActiveSheetId()) {
32571
- const compiledFormula = compile(formulaString);
32572
- const params = this.getCompilationParameters(() => { });
32573
- const ranges = [];
32574
- for (let xc of compiledFormula.dependencies) {
32575
- ranges.push(this.getters.getRangeFromSheetXC(sheetId, xc));
32581
+ try {
32582
+ const compiledFormula = compile(formulaString);
32583
+ const params = this.getCompilationParameters(() => { });
32584
+ const ranges = [];
32585
+ for (let xc of compiledFormula.dependencies) {
32586
+ ranges.push(this.getters.getRangeFromSheetXC(sheetId, xc));
32587
+ }
32588
+ return compiledFormula.execute(ranges, ...params).value;
32589
+ }
32590
+ catch (error) {
32591
+ return error instanceof EvaluationError ? error.errorType : CellErrorType.GenericError;
32576
32592
  }
32577
- return compiledFormula.execute(ranges, ...params).value;
32578
32593
  }
32579
32594
  /**
32580
32595
  * Return the value of each cell in the range as they are displayed in the grid.
@@ -32976,39 +32991,34 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
32976
32991
  this.computedIcons[activeSheetId] = {};
32977
32992
  const computedStyle = this.computedStyles[activeSheetId];
32978
32993
  for (let cf of this.getters.getConditionalFormats(activeSheetId).reverse()) {
32979
- try {
32980
- switch (cf.rule.type) {
32981
- case "ColorScaleRule":
32982
- for (let range of cf.ranges) {
32983
- this.applyColorScale(range, cf.rule);
32984
- }
32985
- break;
32986
- case "IconSetRule":
32987
- for (let range of cf.ranges) {
32988
- this.applyIcon(range, cf.rule);
32989
- }
32990
- break;
32991
- default:
32992
- for (let ref of cf.ranges) {
32993
- const zone = this.getters.getRangeFromSheetXC(activeSheetId, ref).zone;
32994
- for (let row = zone.top; row <= zone.bottom; row++) {
32995
- for (let col = zone.left; col <= zone.right; col++) {
32996
- const pr = this.rulePredicate[cf.rule.type];
32997
- let cell = this.getters.getCell(activeSheetId, col, row);
32998
- if (pr && pr(cell, cf.rule)) {
32999
- if (!computedStyle[col])
33000
- computedStyle[col] = [];
33001
- // we must combine all the properties of all the CF rules applied to the given cell
33002
- computedStyle[col][row] = Object.assign(((_a = computedStyle[col]) === null || _a === void 0 ? void 0 : _a[row]) || {}, cf.rule.style);
33003
- }
32994
+ switch (cf.rule.type) {
32995
+ case "ColorScaleRule":
32996
+ for (let range of cf.ranges) {
32997
+ this.applyColorScale(range, cf.rule);
32998
+ }
32999
+ break;
33000
+ case "IconSetRule":
33001
+ for (let range of cf.ranges) {
33002
+ this.applyIcon(range, cf.rule);
33003
+ }
33004
+ break;
33005
+ default:
33006
+ for (let ref of cf.ranges) {
33007
+ const zone = this.getters.getRangeFromSheetXC(activeSheetId, ref).zone;
33008
+ for (let row = zone.top; row <= zone.bottom; row++) {
33009
+ for (let col = zone.left; col <= zone.right; col++) {
33010
+ const pr = this.rulePredicate[cf.rule.type];
33011
+ let cell = this.getters.getCell(activeSheetId, col, row);
33012
+ if (pr && pr(cell, cf.rule)) {
33013
+ if (!computedStyle[col])
33014
+ computedStyle[col] = [];
33015
+ // we must combine all the properties of all the CF rules applied to the given cell
33016
+ computedStyle[col][row] = Object.assign(((_a = computedStyle[col]) === null || _a === void 0 ? void 0 : _a[row]) || {}, cf.rule.style);
33004
33017
  }
33005
33018
  }
33006
33019
  }
33007
- break;
33008
- }
33009
- }
33010
- catch (_) {
33011
- // we don't care about the errors within the evaluation of a rule
33020
+ }
33021
+ break;
33012
33022
  }
33013
33023
  }
33014
33024
  }
@@ -33032,7 +33042,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
33032
33042
  return percentile(rangeValues, Number(threshold.value) / 100, true);
33033
33043
  case "formula":
33034
33044
  const value = threshold.value && this.getters.evaluateFormula(threshold.value);
33035
- return !(value instanceof Promise) ? value : null;
33045
+ return typeof value === "number" ? value : null;
33036
33046
  default:
33037
33047
  return null;
33038
33048
  }
@@ -39111,7 +39121,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
39111
39121
  }
39112
39122
  onKeydown(ev) {
39113
39123
  let keyDownString = "";
39114
- if (ev.ctrlKey || ev.metaKey) {
39124
+ if (isCtrlKey(ev)) {
39115
39125
  keyDownString += "CTRL+";
39116
39126
  }
39117
39127
  keyDownString += ev.key.toUpperCase();
@@ -43060,9 +43070,9 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
43060
43070
  Object.defineProperty(exports, '__esModule', { value: true });
43061
43071
 
43062
43072
 
43063
- __info__.version = '16.0.26';
43064
- __info__.date = '2023-12-05T09:37:20.450Z';
43065
- __info__.hash = '10de093';
43073
+ __info__.version = '16.0.27';
43074
+ __info__.date = '2024-01-04T12:19:11.487Z';
43075
+ __info__.hash = '54006f6';
43066
43076
 
43067
43077
 
43068
43078
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);