@odoo/o-spreadsheet 17.4.34 → 17.4.36

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.
@@ -2,9 +2,9 @@
2
2
  /**
3
3
  * This file is generated by o-spreadsheet build tools. Do not edit it.
4
4
  * @see https://github.com/odoo/o-spreadsheet
5
- * @version 17.4.34
6
- * @date 2025-05-12T05:23:37.387Z
7
- * @hash e3ac48a
5
+ * @version 17.4.36
6
+ * @date 2025-05-20T05:54:11.995Z
7
+ * @hash fabd931
8
8
  */
9
9
 
10
10
  (function (exports, owl) {
@@ -1915,7 +1915,7 @@
1915
1915
  */
1916
1916
  const getFormulaNumberRegex = memoize(function getFormulaNumberRegex(decimalSeparator) {
1917
1917
  decimalSeparator = escapeRegExp(decimalSeparator);
1918
- return new RegExp(`(?:^-?\\d+(?:${decimalSeparator}?\\d*(?:e\\d+)?)?|^-?${decimalSeparator}\\d+)(?!\\w|!)`);
1918
+ return new RegExp(`(?:^-?\\d+(?:${decimalSeparator}?\\d*(?:e(\\+|-)?\\d+)?)?|^-?${decimalSeparator}\\d+)(?!\\w|!)`);
1919
1919
  });
1920
1920
  const getNumberRegex = memoize(function getNumberRegex(locale) {
1921
1921
  const decimalSeparator = escapeRegExp(locale.decimalSeparator);
@@ -5210,6 +5210,13 @@
5210
5210
  }
5211
5211
  return name;
5212
5212
  }
5213
+ function isSheetNameEqual(name1, name2) {
5214
+ if (name1 === undefined || name2 === undefined) {
5215
+ return false;
5216
+ }
5217
+ return (getUnquotedSheetName(name1.trim().toUpperCase()) ===
5218
+ getUnquotedSheetName(name2.trim().toUpperCase()));
5219
+ }
5213
5220
 
5214
5221
  function computeTextLinesHeight(textLineHeight, numberOfLines = 1) {
5215
5222
  return numberOfLines * (textLineHeight + MIN_CELL_TEXT_MARGIN) - MIN_CELL_TEXT_MARGIN;
@@ -6511,10 +6518,9 @@
6511
6518
  avg: _t("Average"),
6512
6519
  sum: _t("Sum"),
6513
6520
  };
6514
- const NUMBER_CHAR_AGGREGATORS = ["max", "min", "avg", "sum", "count_distinct", "count"];
6515
6521
  const AGGREGATORS_BY_FIELD_TYPE = {
6516
- integer: NUMBER_CHAR_AGGREGATORS,
6517
- char: NUMBER_CHAR_AGGREGATORS,
6522
+ integer: ["max", "min", "avg", "sum", "count_distinct", "count"],
6523
+ char: ["count_distinct", "count"],
6518
6524
  boolean: ["count_distinct", "count", "bool_and", "bool_or"],
6519
6525
  };
6520
6526
  const AGGREGATORS = {};
@@ -6728,8 +6734,11 @@
6728
6734
  const evaluatedCell = this.getters.getEvaluatedCell(position);
6729
6735
  const pivotId = this.getters.getPivotIdFromPosition(position);
6730
6736
  const spreader = this.getters.getArrayFormulaSpreadingOn(position);
6731
- if (pivotId) {
6732
- if (spreader && (!deepEquals(spreader, position) || !isCopyingOneCell)) {
6737
+ if (pivotId && spreader) {
6738
+ const pivotZone = this.getters.getSpreadZone(spreader);
6739
+ if ((!deepEquals(spreader, position) || !isCopyingOneCell) &&
6740
+ pivotZone &&
6741
+ !data.zones.some((z) => isZoneInside(pivotZone, z))) {
6733
6742
  const pivotCell = this.getters.getPivotCellFromPosition(position);
6734
6743
  const formulaPivotId = this.getters.getPivotFormulaId(pivotId);
6735
6744
  const pivotFormula = createPivotFormula(formulaPivotId, pivotCell);
@@ -9451,7 +9460,10 @@ stores.inject(MyMetaStore, storeInstance);
9451
9460
  const functionProxy = new Proxy(value, {
9452
9461
  // trap the function call
9453
9462
  apply(target, thisArg, argArray) {
9454
- Reflect.apply(target, thisStore, argArray);
9463
+ const res = Reflect.apply(target, thisStore, argArray);
9464
+ if (res === "noStateChange") {
9465
+ return;
9466
+ }
9455
9467
  callback();
9456
9468
  },
9457
9469
  });
@@ -9473,7 +9485,7 @@ stores.inject(MyMetaStore, storeInstance);
9473
9485
  const ModelStore = createAbstractStore("Model");
9474
9486
 
9475
9487
  class RendererStore {
9476
- mutators = ["register", "unRegister"];
9488
+ mutators = ["register", "unRegister", "drawLayer"];
9477
9489
  renderers = {};
9478
9490
  register(renderer) {
9479
9491
  if (!renderer.renderingLayers.length) {
@@ -9493,14 +9505,14 @@ stores.inject(MyMetaStore, storeInstance);
9493
9505
  }
9494
9506
  drawLayer(context, layer) {
9495
9507
  const renderers = this.renderers[layer];
9496
- if (!renderers) {
9497
- return;
9498
- }
9499
- for (const renderer of renderers) {
9500
- context.ctx.save();
9501
- renderer.drawLayer(context, layer);
9502
- context.ctx.restore();
9508
+ if (renderers) {
9509
+ for (const renderer of renderers) {
9510
+ context.ctx.save();
9511
+ renderer.drawLayer(context, layer);
9512
+ context.ctx.restore();
9513
+ }
9503
9514
  }
9515
+ return "noStateChange";
9504
9516
  }
9505
9517
  }
9506
9518
 
@@ -10113,7 +10125,7 @@ stores.inject(MyMetaStore, storeInstance);
10113
10125
  .find((token) => {
10114
10126
  const { xc, sheetName: sheet } = splitReference(token.value);
10115
10127
  const sheetName = sheet || this.getters.getSheetName(this.sheetId);
10116
- if (this.getters.getSheetName(activeSheetId) !== sheetName) {
10128
+ if (!isSheetNameEqual(this.getters.getSheetName(activeSheetId), sheetName)) {
10117
10129
  return false;
10118
10130
  }
10119
10131
  const refRange = this.getters.getRangeFromSheetXC(activeSheetId, xc);
@@ -10418,27 +10430,30 @@ stores.inject(MyMetaStore, storeInstance);
10418
10430
  }
10419
10431
  focusTopBarComposer(selection) {
10420
10432
  if (this.getters.isReadonly()) {
10421
- return;
10433
+ return "noStateChange";
10422
10434
  }
10423
10435
  this.topBarFocus = "contentFocus";
10424
10436
  this.gridFocusMode = "inactive";
10425
- this.setComposerContent({ selection } || {});
10437
+ this.setComposerContent({ selection });
10438
+ return;
10426
10439
  }
10427
10440
  focusGridComposerContent() {
10428
10441
  if (this.getters.isReadonly()) {
10429
- return;
10442
+ return "noStateChange";
10430
10443
  }
10431
10444
  this.topBarFocus = "inactive";
10432
10445
  this.gridFocusMode = "contentFocus";
10433
10446
  this.setComposerContent({});
10447
+ return;
10434
10448
  }
10435
10449
  focusGridComposerCell(content, selection) {
10436
10450
  if (this.getters.isReadonly()) {
10437
- return;
10451
+ return "noStateChange";
10438
10452
  }
10439
10453
  this.topBarFocus = "inactive";
10440
10454
  this.gridFocusMode = "cellFocus";
10441
- this.setComposerContent({ content, selection } || {});
10455
+ this.setComposerContent({ content, selection });
10456
+ return;
10442
10457
  }
10443
10458
  /**
10444
10459
  * Start the edition or update the content if it's already started.
@@ -20323,6 +20338,9 @@ stores.inject(MyMetaStore, storeInstance);
20323
20338
  return data === undefined || data.value === null;
20324
20339
  }
20325
20340
  const getNeutral = { number: 0, string: "", boolean: false };
20341
+ function areAlmostEqual(value1, value2, epsilon = 2e-16) {
20342
+ return Math.abs(value1 - value2) < epsilon;
20343
+ }
20326
20344
  const EQ = {
20327
20345
  description: _t("Equal."),
20328
20346
  args: [
@@ -20344,6 +20362,9 @@ stores.inject(MyMetaStore, storeInstance);
20344
20362
  if (isEvaluationError(_value2)) {
20345
20363
  throw value2;
20346
20364
  }
20365
+ if (typeof _value1 === "number" && typeof _value2 === "number") {
20366
+ return areAlmostEqual(_value1, _value2);
20367
+ }
20347
20368
  return _value1 === _value2;
20348
20369
  },
20349
20370
  };
@@ -20383,6 +20404,9 @@ stores.inject(MyMetaStore, storeInstance);
20383
20404
  ],
20384
20405
  compute: function (value1, value2) {
20385
20406
  return applyRelationalOperator(value1, value2, (v1, v2) => {
20407
+ if (typeof v1 === "number" && typeof v2 === "number") {
20408
+ return !areAlmostEqual(v1, v2) && v1 > v2;
20409
+ }
20386
20410
  return v1 > v2;
20387
20411
  });
20388
20412
  },
@@ -20398,6 +20422,9 @@ stores.inject(MyMetaStore, storeInstance);
20398
20422
  ],
20399
20423
  compute: function (value1, value2) {
20400
20424
  return applyRelationalOperator(value1, value2, (v1, v2) => {
20425
+ if (typeof v1 === "number" && typeof v2 === "number") {
20426
+ return areAlmostEqual(v1, v2) || v1 > v2;
20427
+ }
20401
20428
  return v1 >= v2;
20402
20429
  });
20403
20430
  },
@@ -21498,10 +21525,18 @@ stores.inject(MyMetaStore, storeInstance);
21498
21525
  });
21499
21526
 
21500
21527
  class DOMFocusableElementStore {
21501
- mutators = ["setFocusableElement"];
21528
+ mutators = ["setFocusableElement", "focus"];
21502
21529
  focusableElement = undefined;
21503
21530
  setFocusableElement(element) {
21504
21531
  this.focusableElement = element;
21532
+ return "noStateChange";
21533
+ }
21534
+ focus() {
21535
+ if (this.focusableElement === document.activeElement) {
21536
+ return "noStateChange";
21537
+ }
21538
+ this.focusableElement?.focus();
21539
+ return;
21505
21540
  }
21506
21541
  }
21507
21542
 
@@ -21758,12 +21793,20 @@ stores.inject(MyMetaStore, storeInstance);
21758
21793
  }
21759
21794
  }
21760
21795
  hover(position) {
21796
+ if (position.col === this.col && position.row === this.row) {
21797
+ return "noStateChange";
21798
+ }
21761
21799
  this.col = position.col;
21762
21800
  this.row = position.row;
21801
+ return;
21763
21802
  }
21764
21803
  clear() {
21804
+ if (this.col === undefined && this.row === undefined) {
21805
+ return "noStateChange";
21806
+ }
21765
21807
  this.col = undefined;
21766
21808
  this.row = undefined;
21809
+ return;
21767
21810
  }
21768
21811
  }
21769
21812
 
@@ -21785,7 +21828,11 @@ stores.inject(MyMetaStore, storeInstance);
21785
21828
  this.persistentPopover = { col, row, sheetId, type };
21786
21829
  }
21787
21830
  close() {
21831
+ if (!this.persistentPopover) {
21832
+ return "noStateChange";
21833
+ }
21788
21834
  this.persistentPopover = undefined;
21835
+ return;
21789
21836
  }
21790
21837
  get persistentCellPopover() {
21791
21838
  return ((this.persistentPopover && { isOpen: true, ...this.persistentPopover }) || { isOpen: false });
@@ -37027,7 +37074,9 @@ stores.inject(MyMetaStore, storeInstance);
37027
37074
  return dimension.order === "asc" ? -1 : 1;
37028
37075
  }
37029
37076
  if (dimension.type === "integer" || dimension.type === "date") {
37030
- return dimension.order === "asc" ? Number(a) - Number(b) : Number(b) - Number(a);
37077
+ return dimension.order === "asc"
37078
+ ? toNumber(a, DEFAULT_LOCALE) - toNumber(b, DEFAULT_LOCALE)
37079
+ : toNumber(b, DEFAULT_LOCALE) - toNumber(a, DEFAULT_LOCALE);
37031
37080
  }
37032
37081
  return dimension.order === "asc" ? a.localeCompare(b) : b.localeCompare(a);
37033
37082
  }
@@ -37461,7 +37510,12 @@ stores.inject(MyMetaStore, storeInstance);
37461
37510
  entry[field.name] = { value: null, type: CellValueType.empty };
37462
37511
  }
37463
37512
  else {
37464
- entry[field.name] = cell;
37513
+ if (field.type === "char") {
37514
+ entry[field.name] = { ...cell, value: cell.formattedValue || null };
37515
+ }
37516
+ else {
37517
+ entry[field.name] = cell;
37518
+ }
37465
37519
  }
37466
37520
  }
37467
37521
  entry["__count"] = { value: 1, type: CellValueType.number };
@@ -39656,7 +39710,7 @@ stores.inject(MyMetaStore, storeInstance);
39656
39710
  this.isEditing = isEditing;
39657
39711
  if (!isEditing) {
39658
39712
  this.rect = this.defaultRect;
39659
- this.DOMFocusableElementStore.focusableElement?.focus();
39713
+ this.DOMFocusableElementStore.focus();
39660
39714
  return;
39661
39715
  }
39662
39716
  const position = this.env.model.getters.getActivePosition();
@@ -42092,10 +42146,6 @@ stores.inject(MyMetaStore, storeInstance);
42092
42146
  ctx.scale(dpr, dpr);
42093
42147
  for (const layer of OrderedLayers()) {
42094
42148
  model.drawLayer(renderingContext, layer);
42095
- // @ts-ignore 'drawLayer' is not declated as a mutator because:
42096
- // it does not mutate anything. Most importantly it's used
42097
- // during rendering. Invoking a mutator during rendering would
42098
- // trigger another rendering, ultimately resulting in an infinite loop.
42099
42149
  rendererStore.drawLayer(renderingContext, layer);
42100
42150
  }
42101
42151
  }
@@ -42718,7 +42768,7 @@ stores.inject(MyMetaStore, storeInstance);
42718
42768
  this.cellPopovers = useStore(CellPopoverStore);
42719
42769
  owl.useEffect(() => {
42720
42770
  if (!this.sidePanel.isOpen) {
42721
- this.DOMFocusableElementStore.focusableElement?.focus();
42771
+ this.DOMFocusableElementStore.focus();
42722
42772
  }
42723
42773
  }, () => [this.sidePanel.isOpen]);
42724
42774
  }
@@ -42922,7 +42972,7 @@ stores.inject(MyMetaStore, storeInstance);
42922
42972
  focusDefaultElement() {
42923
42973
  if (!this.env.model.getters.getSelectedFigureId() &&
42924
42974
  this.composerStore.editionMode === "inactive") {
42925
- this.DOMFocusableElementStore.focusableElement?.focus();
42975
+ this.DOMFocusableElementStore.focus();
42926
42976
  }
42927
42977
  }
42928
42978
  get gridEl() {
@@ -44659,7 +44709,7 @@ stores.inject(MyMetaStore, storeInstance);
44659
44709
  ({ xc, sheetName } = splitReference(reference));
44660
44710
  let rangeSheetIndex;
44661
44711
  if (sheetName) {
44662
- const index = data.sheets.findIndex((sheet) => sheet.name === sheetName);
44712
+ const index = data.sheets.findIndex((sheet) => isSheetNameEqual(sheet.name, sheetName));
44663
44713
  if (index < 0) {
44664
44714
  throw new Error("Unable to find a sheet with the name " + sheetName);
44665
44715
  }
@@ -44880,7 +44930,7 @@ stores.inject(MyMetaStore, storeInstance);
44880
44930
  formula = formula.replace(externalReferenceRegex, (match, externalRefId, sheetName, cellRef) => {
44881
44931
  externalRefId = Number(externalRefId) - 1;
44882
44932
  cellRef = cellRef.replace(/\$/g, "");
44883
- const sheetIndex = data.externalBooks[externalRefId].sheetNames.findIndex((name) => name === sheetName);
44933
+ const sheetIndex = data.externalBooks[externalRefId].sheetNames.findIndex((name) => isSheetNameEqual(name, sheetName));
44884
44934
  if (sheetIndex === -1) {
44885
44935
  return match;
44886
44936
  }
@@ -45209,7 +45259,7 @@ stores.inject(MyMetaStore, storeInstance);
45209
45259
  */
45210
45260
  function convertTableFormulaReferences(convertedSheets, xlsxSheets) {
45211
45261
  for (let tableSheet of convertedSheets) {
45212
- const tables = xlsxSheets.find((s) => s.sheetName === tableSheet.name).tables;
45262
+ const tables = xlsxSheets.find((s) => isSheetNameEqual(s.sheetName, tableSheet.name)).tables;
45213
45263
  for (let table of tables) {
45214
45264
  const tabRef = table.name + "[";
45215
45265
  for (let sheet of convertedSheets) {
@@ -50886,7 +50936,7 @@ stores.inject(MyMetaStore, storeInstance);
50886
50936
  if (range.sheetId === cmd.sheetId) {
50887
50937
  return { changeType: "CHANGE", range };
50888
50938
  }
50889
- if (cmd.name && range.invalidSheetName === cmd.name) {
50939
+ if (isSheetNameEqual(range.invalidSheetName, cmd.name)) {
50890
50940
  const invalidSheetName = undefined;
50891
50941
  const sheetId = cmd.sheetId;
50892
50942
  const newRange = range.clone({ sheetId, invalidSheetName });
@@ -51457,7 +51507,7 @@ stores.inject(MyMetaStore, storeInstance);
51457
51507
  if (name) {
51458
51508
  const unquotedName = getUnquotedSheetName(name);
51459
51509
  for (const key in this.sheetIdsMapName) {
51460
- if (key.toUpperCase() === unquotedName.toUpperCase()) {
51510
+ if (isSheetNameEqual(key, unquotedName)) {
51461
51511
  return this.sheetIdsMapName[key];
51462
51512
  }
51463
51513
  }
@@ -51705,7 +51755,7 @@ stores.inject(MyMetaStore, storeInstance);
51705
51755
  }
51706
51756
  const { orderedSheetIds, sheets } = this;
51707
51757
  const name = cmd.name && cmd.name.trim().toLowerCase();
51708
- if (orderedSheetIds.find((id) => sheets[id]?.name.toLowerCase() === name && id !== cmd.sheetId)) {
51758
+ if (orderedSheetIds.find((id) => isSheetNameEqual(sheets[id]?.name, name) && id !== cmd.sheetId)) {
51709
51759
  return "DuplicatedSheetName" /* CommandResult.DuplicatedSheetName */;
51710
51760
  }
51711
51761
  if (FORBIDDEN_SHEETNAME_CHARS_IN_EXCEL_REGEX.test(name)) {
@@ -63037,11 +63087,11 @@ stores.inject(MyMetaStore, storeInstance);
63037
63087
  if (ev.key === "Enter") {
63038
63088
  ev.preventDefault();
63039
63089
  this.stopEdition();
63040
- this.DOMFocusableElementStore.focusableElement?.focus();
63090
+ this.DOMFocusableElementStore.focus();
63041
63091
  }
63042
63092
  if (ev.key === "Escape") {
63043
63093
  this.cancelEdition();
63044
- this.DOMFocusableElementStore.focusableElement?.focus();
63094
+ this.DOMFocusableElementStore.focus();
63045
63095
  }
63046
63096
  }
63047
63097
  onMouseEventSheetName(ev) {
@@ -69514,9 +69564,9 @@ stores.inject(MyMetaStore, storeInstance);
69514
69564
  exports.tokenize = tokenize;
69515
69565
 
69516
69566
 
69517
- __info__.version = "17.4.34";
69518
- __info__.date = "2025-05-12T05:23:37.387Z";
69519
- __info__.hash = "e3ac48a";
69567
+ __info__.version = "17.4.36";
69568
+ __info__.date = "2025-05-20T05:54:11.995Z";
69569
+ __info__.hash = "fabd931";
69520
69570
 
69521
69571
 
69522
69572
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);