@odoo/o-spreadsheet 16.0.26 → 16.0.28

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.
@@ -304,15 +304,76 @@
304
304
  // -----------------------------------------------------------------------------
305
305
  // Date Type
306
306
  // -----------------------------------------------------------------------------
307
+ /**
308
+ * A DateTime object that can be used to manipulate spreadsheet dates.
309
+ * Conceptually, a spreadsheet date is simply a number with a date format,
310
+ * and it is timezone-agnostic.
311
+ * This DateTime object consistently uses UTC time to represent a naive date and time.
312
+ */
313
+ class DateTime {
314
+ constructor(year, month, day, hours = 0, minutes = 0, seconds = 0) {
315
+ this.jsDate = new Date(Date.UTC(year, month, day, hours, minutes, seconds, 0));
316
+ }
317
+ static fromTimestamp(timestamp) {
318
+ const date = new Date(timestamp);
319
+ return new DateTime(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(), date.getUTCHours(), date.getUTCMinutes(), date.getUTCSeconds());
320
+ }
321
+ static now() {
322
+ const now = new Date();
323
+ return new DateTime(now.getFullYear(), now.getMonth(), now.getDate(), now.getHours(), now.getMinutes(), now.getSeconds());
324
+ }
325
+ toString() {
326
+ return this.jsDate.toString();
327
+ }
328
+ getTime() {
329
+ return this.jsDate.getTime();
330
+ }
331
+ getFullYear() {
332
+ return this.jsDate.getUTCFullYear();
333
+ }
334
+ getMonth() {
335
+ return this.jsDate.getUTCMonth();
336
+ }
337
+ getDate() {
338
+ return this.jsDate.getUTCDate();
339
+ }
340
+ getDay() {
341
+ return this.jsDate.getUTCDay();
342
+ }
343
+ getHours() {
344
+ return this.jsDate.getUTCHours();
345
+ }
346
+ getMinutes() {
347
+ return this.jsDate.getUTCMinutes();
348
+ }
349
+ getSeconds() {
350
+ return this.jsDate.getUTCSeconds();
351
+ }
352
+ setFullYear(year) {
353
+ this.jsDate.setFullYear(year);
354
+ }
355
+ setDate(date) {
356
+ this.jsDate.setUTCDate(date);
357
+ }
358
+ setHours(hours) {
359
+ this.jsDate.setUTCHours(hours);
360
+ }
361
+ setMinutes(minutes) {
362
+ this.jsDate.setUTCMinutes(minutes);
363
+ }
364
+ setSeconds(seconds) {
365
+ this.jsDate.setUTCSeconds(seconds);
366
+ }
367
+ }
307
368
  // -----------------------------------------------------------------------------
308
369
  // Parsing
309
370
  // -----------------------------------------------------------------------------
310
- const INITIAL_1900_DAY = new Date(1899, 11, 30);
371
+ const INITIAL_1900_DAY = new DateTime(1899, 11, 30);
311
372
  const MS_PER_DAY = 24 * 60 * 60 * 1000;
312
373
  const CURRENT_MILLENIAL = 2000; // note: don't forget to update this in 2999
313
- const CURRENT_YEAR = new Date().getFullYear();
314
- const INITIAL_JS_DAY = new Date(0);
315
- const DATE_JS_1900_OFFSET = INITIAL_JS_DAY - INITIAL_1900_DAY;
374
+ const CURRENT_YEAR = DateTime.now().getFullYear();
375
+ const INITIAL_JS_DAY = DateTime.fromTimestamp(0);
376
+ const DATE_JS_1900_OFFSET = INITIAL_JS_DAY.getTime() - INITIAL_1900_DAY.getTime();
316
377
  const mdyDateRegexp = /^\d{1,2}(\/|-|\s)\d{1,2}((\/|-|\s)\d{1,4})?$/;
317
378
  const ymdDateRegexp = /^\d{3,4}(\/|-|\s)\d{1,2}(\/|-|\s)\d{1,2}$/;
318
379
  const timeRegexp = /((\d+(:\d+)?(:\d+)?\s*(AM|PM))|(\d+:\d+(:\d+)?))$/;
@@ -361,7 +422,7 @@
361
422
  return {
362
423
  value: date.value + time.value,
363
424
  format: date.format + " " + (time.format === "hhhh:mm:ss" ? "hh:mm:ss" : time.format),
364
- jsDate: new Date(date.jsDate.getFullYear() + time.jsDate.getFullYear() - 1899, date.jsDate.getMonth() + time.jsDate.getMonth() - 11, date.jsDate.getDate() + time.jsDate.getDate() - 30, date.jsDate.getHours() + time.jsDate.getHours(), date.jsDate.getMinutes() + time.jsDate.getMinutes(), date.jsDate.getSeconds() + time.jsDate.getSeconds()),
425
+ jsDate: new DateTime(date.jsDate.getFullYear() + time.jsDate.getFullYear() - 1899, date.jsDate.getMonth() + time.jsDate.getMonth() - 11, date.jsDate.getDate() + time.jsDate.getDate() - 30, date.jsDate.getHours() + time.jsDate.getHours(), date.jsDate.getMinutes() + time.jsDate.getMinutes(), date.jsDate.getSeconds() + time.jsDate.getSeconds()),
365
426
  };
366
427
  }
367
428
  return date || time;
@@ -378,13 +439,13 @@
378
439
  const day = Number(parts[dayIndex]);
379
440
  const leadingZero = (parts[monthIndex].length === 2 && month < 10) || (parts[dayIndex].length === 2 && day < 10);
380
441
  const year = parts[yearIndex] ? inferYear(parts[yearIndex]) : CURRENT_YEAR;
381
- const jsDate = new Date(year, month - 1, day);
442
+ const jsDate = new DateTime(year, month - 1, day);
382
443
  const sep = str.match(/\/|-|\s/)[0];
383
444
  if (jsDate.getMonth() !== month - 1 || jsDate.getDate() !== day) {
384
445
  // invalid date
385
446
  return null;
386
447
  }
387
- const delta = jsDate - INITIAL_1900_DAY;
448
+ const delta = jsDate.getTime() - INITIAL_1900_DAY.getTime();
388
449
  let format = leadingZero ? `mm${sep}dd` : `m${sep}d`;
389
450
  if (parts[yearIndex]) {
390
451
  format = isMDY ? format + sep + "yyyy" : "yyyy" + sep + format;
@@ -444,7 +505,7 @@
444
505
  if (hours >= 24) {
445
506
  format = "hhhh:mm:ss";
446
507
  }
447
- const jsDate = new Date(1899, 11, 30, hours, minutes, seconds);
508
+ const jsDate = new DateTime(1899, 11, 30, hours, minutes, seconds);
448
509
  return {
449
510
  value: hours / 24 + minutes / 1440 + seconds / 86400,
450
511
  format: format,
@@ -458,7 +519,7 @@
458
519
  // -----------------------------------------------------------------------------
459
520
  function numberToJsDate(value) {
460
521
  const truncValue = Math.trunc(value);
461
- let date = new Date(truncValue * MS_PER_DAY - DATE_JS_1900_OFFSET);
522
+ let date = DateTime.fromTimestamp(truncValue * MS_PER_DAY - DATE_JS_1900_OFFSET);
462
523
  let time = value - truncValue;
463
524
  time = time < 0 ? 1 + time : time;
464
525
  const hours = Math.round(time * 24);
@@ -475,7 +536,7 @@
475
536
  }
476
537
  /** Return the number of days in the current month of the given date */
477
538
  function getDaysInMonth(date) {
478
- return new Date(date.getFullYear(), date.getMonth() + 1, 0).getDate();
539
+ return new DateTime(date.getFullYear(), date.getMonth() + 1, 0).getDate();
479
540
  }
480
541
  function isLastDayOfMonth(date) {
481
542
  return getDaysInMonth(date) === date.getDate();
@@ -493,7 +554,7 @@
493
554
  const yStart = date.getFullYear();
494
555
  const mStart = date.getMonth();
495
556
  const dStart = date.getDate();
496
- const jsDate = new Date(yStart, mStart + months);
557
+ const jsDate = new DateTime(yStart, mStart + months, 1);
497
558
  if (keepEndOfMonth && dStart === getDaysInMonth(date)) {
498
559
  jsDate.setDate(getDaysInMonth(jsDate));
499
560
  }
@@ -846,7 +907,7 @@
846
907
  function isDateTime(str) {
847
908
  return parseDateTime(str) !== null;
848
909
  }
849
- const MARKDOWN_LINK_REGEX = /^\[([^\[]+)\]\((.+)\)$/;
910
+ const MARKDOWN_LINK_REGEX = /^\[(.+)\]\((.+)\)$/;
850
911
  //link must start with http or https
851
912
  //https://stackoverflow.com/a/3809435/4760614
852
913
  const WEB_LINK_REGEX = /^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)$/;
@@ -1769,7 +1830,7 @@
1769
1830
  .map((p) => {
1770
1831
  switch (p) {
1771
1832
  case "hhhh":
1772
- const helapsedHours = Math.floor((jsDate.getTime() - INITIAL_1900_DAY) / (60 * 60 * 1000));
1833
+ const helapsedHours = Math.floor((jsDate.getTime() - INITIAL_1900_DAY.getTime()) / (60 * 60 * 1000));
1773
1834
  return helapsedHours.toString();
1774
1835
  case "hh":
1775
1836
  return hours.toString().padStart(2, "0");
@@ -3884,6 +3945,7 @@
3884
3945
  return node.description ? node.description : "";
3885
3946
  }
3886
3947
 
3948
+ const macRegex = /Mac/i;
3887
3949
  /**
3888
3950
  * Return true if the event was triggered from
3889
3951
  * a child element.
@@ -3903,7 +3965,15 @@
3903
3965
  return Array.from(document.querySelectorAll(".o-spreadsheet .o-menu"));
3904
3966
  }
3905
3967
  function isMacOS() {
3906
- return navigator.userAgent.toUpperCase().indexOf("MAC") >= 0;
3968
+ return Boolean(macRegex.test(navigator.userAgent));
3969
+ }
3970
+ /**
3971
+ * @param {KeyboardEvent | MouseEvent} ev
3972
+ * @returns Returns true if the event was triggered with the "ctrl" modifier pressed.
3973
+ * On Mac, this is the "meta" or "command" key.
3974
+ */
3975
+ function isCtrlKey(ev) {
3976
+ return isMacOS() ? ev.metaKey : ev.ctrlKey;
3907
3977
  }
3908
3978
 
3909
3979
  /**
@@ -13836,7 +13906,7 @@
13836
13906
  if (_year < 1900) {
13837
13907
  _year += 1900;
13838
13908
  }
13839
- const jsDate = new Date(_year, _month - 1, _day);
13909
+ const jsDate = new DateTime(_year, _month - 1, _day);
13840
13910
  const result = jsDateToRoundNumber(jsDate);
13841
13911
  assert(() => result >= 0, _lt(`The function [[FUNCTION_NAME]] result must be greater than or equal 01/01/1900.`));
13842
13912
  return result;
@@ -13948,7 +14018,7 @@
13948
14018
  const _months = Math.trunc(toNumber(months));
13949
14019
  const yStart = _startDate.getFullYear();
13950
14020
  const mStart = _startDate.getMonth();
13951
- const jsDate = new Date(yStart, mStart + _months + 1, 0);
14021
+ const jsDate = new DateTime(yStart, mStart + _months + 1, 0);
13952
14022
  return jsDateToRoundNumber(jsDate);
13953
14023
  },
13954
14024
  isExported: true,
@@ -13987,17 +14057,17 @@
13987
14057
  // The first week of the year is the week that contains the first
13988
14058
  // Thursday of the year.
13989
14059
  let firstThursday = 1;
13990
- while (new Date(y, 0, firstThursday).getDay() !== 4) {
14060
+ while (new DateTime(y, 0, firstThursday).getDay() !== 4) {
13991
14061
  firstThursday += 1;
13992
14062
  }
13993
- const firstDayOfFirstWeek = new Date(y, 0, firstThursday - 3);
14063
+ const firstDayOfFirstWeek = new DateTime(y, 0, firstThursday - 3);
13994
14064
  // The last week of the year is the week that contains the last Thursday of
13995
14065
  // the year.
13996
14066
  let lastThursday = 31;
13997
- while (new Date(y, 11, lastThursday).getDay() !== 4) {
14067
+ while (new DateTime(y, 11, lastThursday).getDay() !== 4) {
13998
14068
  lastThursday -= 1;
13999
14069
  }
14000
- const lastDayOfLastWeek = new Date(y, 11, lastThursday + 3);
14070
+ const lastDayOfLastWeek = new DateTime(y, 11, lastThursday + 3);
14001
14071
  // B - If our date > lastDayOfLastWeek then it's in the weeks of the year after
14002
14072
  // If our date < firstDayOfFirstWeek then it's in the weeks of the year before
14003
14073
  let offsetYear;
@@ -14023,17 +14093,17 @@
14023
14093
  case 1:
14024
14094
  // firstDay is the 1st day of the 1st week of the year after
14025
14095
  // firstDay = lastDayOfLastWeek + 1 Day
14026
- firstDay = new Date(y, 11, lastThursday + 3 + 1);
14096
+ firstDay = new DateTime(y, 11, lastThursday + 3 + 1);
14027
14097
  break;
14028
14098
  case -1:
14029
14099
  // firstDay is the 1st day of the 1st week of the previous year.
14030
14100
  // The first week of the previous year is the week that contains the
14031
14101
  // first Thursday of the previous year.
14032
14102
  let firstThursdayPreviousYear = 1;
14033
- while (new Date(y - 1, 0, firstThursdayPreviousYear).getDay() !== 4) {
14103
+ while (new DateTime(y - 1, 0, firstThursdayPreviousYear).getDay() !== 4) {
14034
14104
  firstThursdayPreviousYear += 1;
14035
14105
  }
14036
- firstDay = new Date(y - 1, 0, firstThursdayPreviousYear - 3);
14106
+ firstDay = new DateTime(y - 1, 0, firstThursdayPreviousYear - 3);
14037
14107
  break;
14038
14108
  }
14039
14109
  const diff = (_date.getTime() - firstDay.getTime()) / MS_PER_DAY;
@@ -14172,8 +14242,8 @@
14172
14242
  });
14173
14243
  }
14174
14244
  const invertDate = _startDate.getTime() > _endDate.getTime();
14175
- const stopDate = new Date((invertDate ? _startDate : _endDate).getTime());
14176
- let stepDate = new Date((invertDate ? _endDate : _startDate).getTime());
14245
+ const stopDate = DateTime.fromTimestamp((invertDate ? _startDate : _endDate).getTime());
14246
+ let stepDate = DateTime.fromTimestamp((invertDate ? _endDate : _startDate).getTime());
14177
14247
  const timeStopDate = stopDate.getTime();
14178
14248
  let timeStepDate = stepDate.getTime();
14179
14249
  let netWorkingDay = 0;
@@ -14197,8 +14267,7 @@
14197
14267
  returns: ["DATE"],
14198
14268
  computeFormat: () => "m/d/yyyy hh:mm:ss",
14199
14269
  compute: function () {
14200
- let today = new Date();
14201
- today.setMilliseconds(0);
14270
+ let today = DateTime.now();
14202
14271
  const delta = today.getTime() - INITIAL_1900_DAY.getTime();
14203
14272
  const time = today.getHours() / 24 + today.getMinutes() / 1440 + today.getSeconds() / 86400;
14204
14273
  return Math.floor(delta / MS_PER_DAY) + time;
@@ -14272,8 +14341,8 @@
14272
14341
  returns: ["DATE"],
14273
14342
  computeFormat: () => "m/d/yyyy",
14274
14343
  compute: function () {
14275
- const today = new Date();
14276
- const jsDate = new Date(today.getFullYear(), today.getMonth(), today.getDate());
14344
+ const today = DateTime.now();
14345
+ const jsDate = new DateTime(today.getFullYear(), today.getMonth(), today.getDate());
14277
14346
  return jsDateToRoundNumber(jsDate);
14278
14347
  },
14279
14348
  isExported: true,
@@ -14328,10 +14397,10 @@
14328
14397
  }
14329
14398
  const y = _date.getFullYear();
14330
14399
  let dayStart = 1;
14331
- let startDayOfFirstWeek = new Date(y, 0, dayStart);
14400
+ let startDayOfFirstWeek = new DateTime(y, 0, dayStart);
14332
14401
  while (startDayOfFirstWeek.getDay() !== startDayOfWeek) {
14333
14402
  dayStart += 1;
14334
- startDayOfFirstWeek = new Date(y, 0, dayStart);
14403
+ startDayOfFirstWeek = new DateTime(y, 0, dayStart);
14335
14404
  }
14336
14405
  const dif = (_date.getTime() - startDayOfFirstWeek.getTime()) / MS_PER_DAY;
14337
14406
  if (dif < 0) {
@@ -14385,7 +14454,7 @@
14385
14454
  timesHoliday.add(holiday.getTime());
14386
14455
  });
14387
14456
  }
14388
- let stepDate = new Date(_startDate.getTime());
14457
+ let stepDate = DateTime.fromTimestamp(_startDate.getTime());
14389
14458
  let timeStepDate = stepDate.getTime();
14390
14459
  const unitDay = Math.sign(_numDays);
14391
14460
  let stepDay = Math.abs(_numDays);
@@ -14451,7 +14520,7 @@
14451
14520
  const _startDate = toJsDate(date);
14452
14521
  const yStart = _startDate.getFullYear();
14453
14522
  const mStart = _startDate.getMonth();
14454
- const jsDate = new Date(yStart, mStart, 1);
14523
+ const jsDate = new DateTime(yStart, mStart, 1);
14455
14524
  return jsDateToRoundNumber(jsDate);
14456
14525
  },
14457
14526
  };
@@ -14495,7 +14564,7 @@
14495
14564
  compute: function (date) {
14496
14565
  const quarter = QUARTER.compute(date);
14497
14566
  const year = YEAR.compute(date);
14498
- const jsDate = new Date(year, (quarter - 1) * 3, 1);
14567
+ const jsDate = new DateTime(year, (quarter - 1) * 3, 1);
14499
14568
  return jsDateToRoundNumber(jsDate);
14500
14569
  },
14501
14570
  };
@@ -14512,7 +14581,7 @@
14512
14581
  compute: function (date) {
14513
14582
  const quarter = QUARTER.compute(date);
14514
14583
  const year = YEAR.compute(date);
14515
- const jsDate = new Date(year, quarter * 3, 0);
14584
+ const jsDate = new DateTime(year, quarter * 3, 0);
14516
14585
  return jsDateToRoundNumber(jsDate);
14517
14586
  },
14518
14587
  };
@@ -14528,7 +14597,7 @@
14528
14597
  computeFormat: () => "m/d/yyyy",
14529
14598
  compute: function (date) {
14530
14599
  const year = YEAR.compute(date);
14531
- const jsDate = new Date(year, 0, 1);
14600
+ const jsDate = new DateTime(year, 0, 1);
14532
14601
  return jsDateToRoundNumber(jsDate);
14533
14602
  },
14534
14603
  };
@@ -14544,7 +14613,7 @@
14544
14613
  computeFormat: () => "m/d/yyyy",
14545
14614
  compute: function (date) {
14546
14615
  const year = YEAR.compute(date);
14547
- const jsDate = new Date(year + 1, 0, 0);
14616
+ const jsDate = new DateTime(year + 1, 0, 0);
14548
14617
  return jsDateToRoundNumber(jsDate);
14549
14618
  },
14550
14619
  };
@@ -14678,7 +14747,7 @@
14678
14747
  function assertSettlementLessThanOneYearBeforeMaturity(settlement, maturity) {
14679
14748
  const startDate = toJsDate(settlement);
14680
14749
  const endDate = toJsDate(maturity);
14681
- const startDatePlusOneYear = new Date(startDate);
14750
+ const startDatePlusOneYear = toJsDate(settlement);
14682
14751
  startDatePlusOneYear.setFullYear(startDate.getFullYear() + 1);
14683
14752
  assert(() => endDate.getTime() <= startDatePlusOneYear.getTime(), _lt("The settlement date (%s) must at most one year after the maturity date (%s).", settlement.toString(), maturity.toString()));
14684
14753
  }
@@ -21473,7 +21542,10 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
21473
21542
  return;
21474
21543
  }
21475
21544
  const [col, row] = this.getCartesianCoordinates(ev);
21476
- this.props.onCellClicked(col, row, { shiftKey: ev.shiftKey, ctrlKey: ev.ctrlKey });
21545
+ this.props.onCellClicked(col, row, {
21546
+ expandZone: ev.shiftKey,
21547
+ addZone: isCtrlKey(ev),
21548
+ });
21477
21549
  }
21478
21550
  onDoubleClick(ev) {
21479
21551
  const [col, row] = this.getCartesianCoordinates(ev);
@@ -21701,7 +21773,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
21701
21773
  this._increaseSelection(index);
21702
21774
  }
21703
21775
  else {
21704
- this._selectElement(index, ev.ctrlKey);
21776
+ this._selectElement(index, isCtrlKey(ev));
21705
21777
  }
21706
21778
  this.lastSelectedElementIndex = index;
21707
21779
  const mouseMoveSelect = (col, row) => {
@@ -21714,7 +21786,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
21714
21786
  const mouseUpSelect = () => {
21715
21787
  this.state.isSelecting = false;
21716
21788
  this.lastSelectedElementIndex = null;
21717
- this.env.model.dispatch(ev.ctrlKey ? "PREPARE_SELECTION_INPUT_EXPANSION" : "STOP_SELECTION_INPUT");
21789
+ this.env.model.dispatch(isCtrlKey(ev) ? "PREPARE_SELECTION_INPUT_EXPANSION" : "STOP_SELECTION_INPUT");
21718
21790
  this._computeGrabDisplay(ev);
21719
21791
  };
21720
21792
  dragAndDropBeyondTheViewport(this.env, mouseMoveSelect, mouseUpSelect);
@@ -21861,8 +21933,8 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
21861
21933
  this.env.raiseError(MergeErrorMessage);
21862
21934
  }
21863
21935
  }
21864
- _selectElement(index, ctrlKey) {
21865
- this.env.model.selection.selectColumn(index, ctrlKey ? "newAnchor" : "overrideSelection");
21936
+ _selectElement(index, addDistinctHeader) {
21937
+ this.env.model.selection.selectColumn(index, addDistinctHeader ? "newAnchor" : "overrideSelection");
21866
21938
  }
21867
21939
  _increaseSelection(index) {
21868
21940
  this.env.model.selection.selectColumn(index, "updateAnchor");
@@ -22031,8 +22103,8 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
22031
22103
  this.env.raiseError(MergeErrorMessage);
22032
22104
  }
22033
22105
  }
22034
- _selectElement(index, ctrlKey) {
22035
- this.env.model.selection.selectRow(index, ctrlKey ? "newAnchor" : "overrideSelection");
22106
+ _selectElement(index, addDistinctHeader) {
22107
+ this.env.model.selection.selectRow(index, addDistinctHeader ? "newAnchor" : "overrideSelection");
22036
22108
  }
22037
22109
  _increaseSelection(index) {
22038
22110
  this.env.model.selection.selectRow(index, "updateAnchor");
@@ -22723,18 +22795,18 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
22723
22795
  // ---------------------------------------------------------------------------
22724
22796
  // Zone selection with mouse
22725
22797
  // ---------------------------------------------------------------------------
22726
- onCellClicked(col, row, { ctrlKey, shiftKey }) {
22727
- if (ctrlKey) {
22798
+ onCellClicked(col, row, { addZone, expandZone }) {
22799
+ if (addZone) {
22728
22800
  this.env.model.dispatch("PREPARE_SELECTION_INPUT_EXPANSION");
22729
22801
  }
22730
22802
  this.closeOpenedPopover();
22731
22803
  if (this.env.model.getters.getEditionMode() === "editing") {
22732
22804
  this.env.model.dispatch("STOP_EDITION");
22733
22805
  }
22734
- if (shiftKey) {
22806
+ if (expandZone) {
22735
22807
  this.env.model.selection.setAnchorCorner(col, row);
22736
22808
  }
22737
- else if (ctrlKey) {
22809
+ else if (addZone) {
22738
22810
  this.env.model.selection.addCellToSelection(col, row);
22739
22811
  }
22740
22812
  else {
@@ -22788,10 +22860,10 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
22788
22860
  };
22789
22861
  const direction = arrowMap[ev.key];
22790
22862
  if (ev.shiftKey) {
22791
- this.env.model.selection.resizeAnchorZone(direction, ev.ctrlKey ? "end" : 1);
22863
+ this.env.model.selection.resizeAnchorZone(direction, isCtrlKey(ev) ? "end" : 1);
22792
22864
  }
22793
22865
  else {
22794
- this.env.model.selection.moveAnchorCell(direction, ev.ctrlKey ? "end" : 1);
22866
+ this.env.model.selection.moveAnchorCell(direction, isCtrlKey(ev) ? "end" : 1);
22795
22867
  }
22796
22868
  if (this.env.model.getters.isPaintingFormat()) {
22797
22869
  this.env.model.dispatch("PASTE", {
@@ -22805,9 +22877,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
22805
22877
  return;
22806
22878
  }
22807
22879
  let keyDownString = "";
22808
- if (ev.ctrlKey)
22809
- keyDownString += "CTRL+";
22810
- if (ev.metaKey)
22880
+ if (isCtrlKey(ev))
22811
22881
  keyDownString += "CTRL+";
22812
22882
  if (ev.altKey)
22813
22883
  keyDownString += "ALT+";
@@ -32568,13 +32638,18 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
32568
32638
  // Getters
32569
32639
  // ---------------------------------------------------------------------------
32570
32640
  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));
32641
+ try {
32642
+ const compiledFormula = compile(formulaString);
32643
+ const params = this.getCompilationParameters(() => { });
32644
+ const ranges = [];
32645
+ for (let xc of compiledFormula.dependencies) {
32646
+ ranges.push(this.getters.getRangeFromSheetXC(sheetId, xc));
32647
+ }
32648
+ return compiledFormula.execute(ranges, ...params).value;
32649
+ }
32650
+ catch (error) {
32651
+ return error instanceof EvaluationError ? error.errorType : CellErrorType.GenericError;
32576
32652
  }
32577
- return compiledFormula.execute(ranges, ...params).value;
32578
32653
  }
32579
32654
  /**
32580
32655
  * Return the value of each cell in the range as they are displayed in the grid.
@@ -32976,39 +33051,34 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
32976
33051
  this.computedIcons[activeSheetId] = {};
32977
33052
  const computedStyle = this.computedStyles[activeSheetId];
32978
33053
  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
- }
33054
+ switch (cf.rule.type) {
33055
+ case "ColorScaleRule":
33056
+ for (let range of cf.ranges) {
33057
+ this.applyColorScale(range, cf.rule);
33058
+ }
33059
+ break;
33060
+ case "IconSetRule":
33061
+ for (let range of cf.ranges) {
33062
+ this.applyIcon(range, cf.rule);
33063
+ }
33064
+ break;
33065
+ default:
33066
+ for (let ref of cf.ranges) {
33067
+ const zone = this.getters.getRangeFromSheetXC(activeSheetId, ref).zone;
33068
+ for (let row = zone.top; row <= zone.bottom; row++) {
33069
+ for (let col = zone.left; col <= zone.right; col++) {
33070
+ const pr = this.rulePredicate[cf.rule.type];
33071
+ let cell = this.getters.getCell(activeSheetId, col, row);
33072
+ if (pr && pr(cell, cf.rule)) {
33073
+ if (!computedStyle[col])
33074
+ computedStyle[col] = [];
33075
+ // we must combine all the properties of all the CF rules applied to the given cell
33076
+ computedStyle[col][row] = Object.assign(((_a = computedStyle[col]) === null || _a === void 0 ? void 0 : _a[row]) || {}, cf.rule.style);
33004
33077
  }
33005
33078
  }
33006
33079
  }
33007
- break;
33008
- }
33009
- }
33010
- catch (_) {
33011
- // we don't care about the errors within the evaluation of a rule
33080
+ }
33081
+ break;
33012
33082
  }
33013
33083
  }
33014
33084
  }
@@ -33032,7 +33102,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
33032
33102
  return percentile(rangeValues, Number(threshold.value) / 100, true);
33033
33103
  case "formula":
33034
33104
  const value = threshold.value && this.getters.evaluateFormula(threshold.value);
33035
- return !(value instanceof Promise) ? value : null;
33105
+ return typeof value === "number" ? value : null;
33036
33106
  default:
33037
33107
  return null;
33038
33108
  }
@@ -39111,7 +39181,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
39111
39181
  }
39112
39182
  onKeydown(ev) {
39113
39183
  let keyDownString = "";
39114
- if (ev.ctrlKey || ev.metaKey) {
39184
+ if (isCtrlKey(ev)) {
39115
39185
  keyDownString += "CTRL+";
39116
39186
  }
39117
39187
  keyDownString += ev.key.toUpperCase();
@@ -43060,9 +43130,9 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
43060
43130
  Object.defineProperty(exports, '__esModule', { value: true });
43061
43131
 
43062
43132
 
43063
- __info__.version = '16.0.26';
43064
- __info__.date = '2023-12-05T09:37:20.450Z';
43065
- __info__.hash = '10de093';
43133
+ __info__.version = '16.0.28';
43134
+ __info__.date = '2024-01-12T13:42:04.756Z';
43135
+ __info__.hash = '7251a47';
43066
43136
 
43067
43137
 
43068
43138
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);