@odoo/o-spreadsheet 17.2.17 → 17.2.19

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.
@@ -3,9 +3,9 @@
3
3
  /**
4
4
  * This file is generated by o-spreadsheet build tools. Do not edit it.
5
5
  * @see https://github.com/odoo/o-spreadsheet
6
- * @version 17.2.17
7
- * @date 2024-07-18T14:23:50.417Z
8
- * @hash 9e0ea24
6
+ * @version 17.2.19
7
+ * @date 2024-08-02T08:22:56.367Z
8
+ * @hash c5ae261
9
9
  */
10
10
 
11
11
  (function (exports, owl) {
@@ -486,7 +486,7 @@
486
486
  let timeout = undefined;
487
487
  const debounced = function () {
488
488
  const context = this;
489
- const args = arguments;
489
+ const args = Array.from(arguments);
490
490
  function later() {
491
491
  timeout = undefined;
492
492
  if (!immediate) {
@@ -714,7 +714,7 @@
714
714
  */
715
715
  function largeMax(array) {
716
716
  let len = array.length;
717
- if (len < 100000)
717
+ if (len < 100_000)
718
718
  return Math.max(...array);
719
719
  let max = -Infinity;
720
720
  while (len--) {
@@ -728,7 +728,7 @@
728
728
  */
729
729
  function largeMin(array) {
730
730
  let len = array.length;
731
- if (len < 100000)
731
+ if (len < 100_000)
732
732
  return Math.min(...array);
733
733
  let min = +Infinity;
734
734
  while (len--) {
@@ -2669,13 +2669,16 @@
2669
2669
  }
2670
2670
  return new RegExp("^" + exp + "$", "i");
2671
2671
  });
2672
- function evaluatePredicate(value = "", criterion) {
2672
+ function evaluatePredicate(value = "", criterion, locale) {
2673
2673
  const { operator, operand } = criterion;
2674
2674
  if (operand === undefined || value === null || operand === null) {
2675
2675
  return false;
2676
2676
  }
2677
2677
  if (typeof operand === "number" && operator === "=") {
2678
- return value.toString() === operand.toString();
2678
+ if (typeof value === "string" && (isNumber(value, locale) || isDateTime(value, locale))) {
2679
+ return toNumber(value, locale) === operand;
2680
+ }
2681
+ return value === operand;
2679
2682
  }
2680
2683
  if (operator === "<>" || operator === "=") {
2681
2684
  let result;
@@ -2757,7 +2760,7 @@
2757
2760
  for (let k = 0; k < countArg - 1; k += 2) {
2758
2761
  const criteriaValue = toMatrix(args[k])[i][j].value;
2759
2762
  const criterion = predicates[k / 2];
2760
- validatedPredicates = evaluatePredicate(criteriaValue ?? undefined, criterion);
2763
+ validatedPredicates = evaluatePredicate(criteriaValue ?? undefined, criterion, locale);
2761
2764
  if (!validatedPredicates) {
2762
2765
  break;
2763
2766
  }
@@ -7181,7 +7184,7 @@
7181
7184
  }
7182
7185
  function numberCell(value, format, formattedValue) {
7183
7186
  return {
7184
- value: value || 0,
7187
+ value: value || 0, // necessary to avoid "-0" and NaN values,
7185
7188
  format,
7186
7189
  formattedValue,
7187
7190
  type: CellValueType.number,
@@ -19629,8 +19632,8 @@ stores.inject(MyMetaStore, storeInstance);
19629
19632
  function getDefaultChartJsRuntime(chart, labels, fontColor, { format, locale, truncateLabels = true }) {
19630
19633
  const options = {
19631
19634
  // https://www.chartjs.org/docs/latest/general/responsive.html
19632
- responsive: true,
19633
- maintainAspectRatio: false,
19635
+ responsive: true, // will resize when its container is resized
19636
+ maintainAspectRatio: false, // doesn't maintain the aspect ration (width/height =2 by default) so the user has the choice of the exact layout
19634
19637
  layout: {
19635
19638
  padding: { left: 20, right: 20, top: chart.title ? 10 : 25, bottom: 10 },
19636
19639
  },
@@ -19676,7 +19679,7 @@ stores.inject(MyMetaStore, storeInstance);
19676
19679
  labels: truncateLabels ? labels.map(truncateLabel) : labels,
19677
19680
  datasets: [],
19678
19681
  },
19679
- platform: undefined,
19682
+ platform: undefined, // This key is optional and will be set by chart.js
19680
19683
  plugins: [],
19681
19684
  };
19682
19685
  }
@@ -19953,7 +19956,7 @@ stores.inject(MyMetaStore, storeInstance);
19953
19956
  },
19954
19957
  y: {
19955
19958
  position: chart.verticalAxisPosition,
19956
- beginAtZero: true,
19959
+ beginAtZero: true, // the origin of the y axis is always zero
19957
19960
  ticks: {
19958
19961
  color: fontColor,
19959
19962
  callback: (value) => {
@@ -20477,7 +20480,7 @@ stores.inject(MyMetaStore, storeInstance);
20477
20480
  },
20478
20481
  y: {
20479
20482
  position: chart.verticalAxisPosition,
20480
- beginAtZero: true,
20483
+ beginAtZero: true, // the origin of the y axis is always zero
20481
20484
  ticks: {
20482
20485
  color: fontColor,
20483
20486
  callback: (value) => {
@@ -20567,7 +20570,7 @@ stores.inject(MyMetaStore, storeInstance);
20567
20570
  const dataset = {
20568
20571
  label,
20569
20572
  data,
20570
- tension: 0,
20573
+ tension: 0, // 0 -> render straight lines, which is much faster
20571
20574
  borderColor: color,
20572
20575
  backgroundColor,
20573
20576
  pointBackgroundColor: color,
@@ -20789,7 +20792,7 @@ stores.inject(MyMetaStore, storeInstance);
20789
20792
  ...this.getDefinition(),
20790
20793
  backgroundColor: toXlsxHexColor(this.background || BACKGROUND_CHART_COLOR),
20791
20794
  fontColor: toXlsxHexColor(chartFontColor(this.background)),
20792
- verticalAxisPosition: "left",
20795
+ verticalAxisPosition: "left", //TODO ExcelChartDefinition should be adapted, but can be done later
20793
20796
  dataSets,
20794
20797
  labelRange,
20795
20798
  };
@@ -23356,7 +23359,7 @@ stores.inject(MyMetaStore, storeInstance);
23356
23359
  style: { fillColor: colorSet.highlight, textColor: "#FFFFFF" },
23357
23360
  border: { bottom: { color: colorSet.highlight, style: "thin" } },
23358
23361
  },
23359
- totalRow: { border: { top: { color: colorSet.highlight, style: "medium" } } },
23362
+ totalRow: { border: { top: { color: colorSet.highlight, style: "medium" } } }, // @compatibility: should be double line
23360
23363
  firstRowStripe: { border: { bottom: { color: colorSet.highlight, style: "thin" } } },
23361
23364
  secondRowStripe: { border: { bottom: { color: colorSet.highlight, style: "thin" } } },
23362
23365
  });
@@ -23374,7 +23377,7 @@ stores.inject(MyMetaStore, storeInstance);
23374
23377
  },
23375
23378
  },
23376
23379
  headerRow: { border: { bottom: { color: colorSet.highlight, style: "medium" } } },
23377
- totalRow: { border: { top: { color: colorSet.highlight, style: "medium" } } },
23380
+ totalRow: { border: { top: { color: colorSet.highlight, style: "medium" } } }, // @compatibility: should be double line
23378
23381
  firstRowStripe: { style: { fillColor: colorSet.light } },
23379
23382
  firstColumnStripe: { style: { fillColor: colorSet.light } },
23380
23383
  });
@@ -23393,7 +23396,7 @@ stores.inject(MyMetaStore, storeInstance);
23393
23396
  headerRow: {
23394
23397
  style: { fillColor: colorSet.highlight, textColor: "#FFFFFF" },
23395
23398
  },
23396
- totalRow: { border: { top: { color: colorSet.highlight, style: "medium" } } },
23399
+ totalRow: { border: { top: { color: colorSet.highlight, style: "medium" } } }, // @compatibility: should be double line
23397
23400
  firstRowStripe: { style: { fillColor: colorSet.light } },
23398
23401
  firstColumnStripe: { style: { fillColor: colorSet.light } },
23399
23402
  });
@@ -23429,7 +23432,7 @@ stores.inject(MyMetaStore, storeInstance);
23429
23432
  bottom: { color: "#000000", style: "medium" },
23430
23433
  },
23431
23434
  },
23432
- totalRow: { border: { top: { color: "#000000", style: "medium" } } },
23435
+ totalRow: { border: { top: { color: "#000000", style: "medium" } } }, // @compatibility: should be double line
23433
23436
  headerRow: {
23434
23437
  style: { fillColor: colorSet.highlight, textColor: "#FFFFFF" },
23435
23438
  border: { bottom: { color: "#000000", style: "medium" } },
@@ -23453,7 +23456,7 @@ stores.inject(MyMetaStore, storeInstance);
23453
23456
  },
23454
23457
  style: { fillColor: colorSet.light },
23455
23458
  },
23456
- totalRow: { border: { top: { color: colorSet.highlight, style: "medium" } } },
23459
+ totalRow: { border: { top: { color: colorSet.highlight, style: "medium" } } }, // @compatibility: should be double line
23457
23460
  firstRowStripe: { style: { fillColor: colorSet.medium } },
23458
23461
  firstColumnStripe: { style: { fillColor: colorSet.medium } },
23459
23462
  });
@@ -23484,7 +23487,7 @@ stores.inject(MyMetaStore, storeInstance);
23484
23487
  category: "dark",
23485
23488
  colorName: colorSet.name,
23486
23489
  wholeTable: { style: { fillColor: colorSet.light } },
23487
- totalRow: { border: { top: { color: "#000000", style: "medium" } } },
23490
+ totalRow: { border: { top: { color: "#000000", style: "medium" } } }, // @compatibility: should be double line
23488
23491
  headerRow: { style: { fillColor: colorSet.highlight, textColor: "#FFFFFF" } },
23489
23492
  firstRowStripe: { style: { fillColor: colorSet.medium } },
23490
23493
  firstColumnStripe: { style: { fillColor: colorSet.medium } },
@@ -32256,7 +32259,9 @@ stores.inject(MyMetaStore, storeInstance);
32256
32259
  argToFocus: 0,
32257
32260
  });
32258
32261
  compositionActive = false;
32262
+ spreadsheetRect = useSpreadsheetRect();
32259
32263
  get assistantStyle() {
32264
+ const composerRect = this.composerRef.el.getBoundingClientRect();
32260
32265
  const assistantStyle = {};
32261
32266
  assistantStyle["min-width"] = `${this.props.rect?.width || ASSISTANT_WIDTH}px`;
32262
32267
  const proposals = this.autoCompleteState.provider?.proposals;
@@ -32283,6 +32288,9 @@ stores.inject(MyMetaStore, storeInstance);
32283
32288
  }
32284
32289
  else if (this.props.delimitation) {
32285
32290
  assistantStyle["max-height"] = `${this.props.delimitation.height}px`;
32291
+ if (composerRect.left + ASSISTANT_WIDTH > this.spreadsheetRect.width) {
32292
+ assistantStyle.right = `0px`;
32293
+ }
32286
32294
  }
32287
32295
  return cssPropertiesToCss(assistantStyle);
32288
32296
  }
@@ -33845,10 +33853,13 @@ stores.inject(MyMetaStore, storeInstance);
33845
33853
  row: undefined,
33846
33854
  };
33847
33855
  const { Date } = window;
33848
- let x = 0;
33849
- let y = 0;
33856
+ let x = undefined;
33857
+ let y = undefined;
33850
33858
  let lastMoved = 0;
33851
33859
  function getPosition() {
33860
+ if (x === undefined || y === undefined) {
33861
+ return { col: -1, row: -1 };
33862
+ }
33852
33863
  const col = env.model.getters.getColIndex(x);
33853
33864
  const row = env.model.getters.getRowIndex(y);
33854
33865
  return { col, row };
@@ -35679,7 +35690,7 @@ stores.inject(MyMetaStore, storeInstance);
35679
35690
  onScroll(offset) {
35680
35691
  const { scrollX } = this.env.model.getters.getActiveSheetDOMScrollInfo();
35681
35692
  this.env.model.dispatch("SET_VIEWPORT_OFFSET", {
35682
- offsetX: scrollX,
35693
+ offsetX: scrollX, // offsetX is the same
35683
35694
  offsetY: offset,
35684
35695
  });
35685
35696
  }
@@ -35968,8 +35979,8 @@ stores.inject(MyMetaStore, storeInstance);
35968
35979
  "Ctrl+Shift+L": () => this.setHorizontalAlign("left"),
35969
35980
  "Ctrl+Shift+R": () => this.setHorizontalAlign("right"),
35970
35981
  "Ctrl+Shift+V": () => PASTE_AS_VALUE_ACTION(this.env),
35971
- "Ctrl+Shift+<": () => this.clearFormatting(),
35972
- "Ctrl+<": () => this.clearFormatting(),
35982
+ "Ctrl+Shift+<": () => this.clearFormatting(), // for qwerty
35983
+ "Ctrl+<": () => this.clearFormatting(), // for azerty
35973
35984
  "Ctrl+Shift+ ": () => {
35974
35985
  this.env.model.selection.selectAll();
35975
35986
  },
@@ -36770,10 +36781,10 @@ stores.inject(MyMetaStore, storeInstance);
36770
36781
  const CF_TYPE_CONVERSION_MAP = {
36771
36782
  aboveAverage: undefined,
36772
36783
  expression: undefined,
36773
- cellIs: undefined,
36774
- colorScale: undefined,
36784
+ cellIs: undefined, // exist but isn't an operator in o_spreadsheet
36785
+ colorScale: undefined, // exist but isn't an operator in o_spreadsheet
36775
36786
  dataBar: undefined,
36776
- iconSet: undefined,
36787
+ iconSet: undefined, // exist but isn't an operator in o_spreadsheet
36777
36788
  top10: undefined,
36778
36789
  uniqueValues: undefined,
36779
36790
  duplicateValues: undefined,
@@ -37008,7 +37019,7 @@ stores.inject(MyMetaStore, storeInstance);
37008
37019
  61: "993366",
37009
37020
  62: "333399",
37010
37021
  63: "333333",
37011
- 64: "000000",
37022
+ 64: "000000", // system foreground
37012
37023
  65: "FFFFFF", // system background
37013
37024
  };
37014
37025
  const IMAGE_MIMETYPE_TO_EXTENSION_MAPPING = {
@@ -40651,12 +40662,13 @@ stores.inject(MyMetaStore, storeInstance);
40651
40662
  this.clearBorders(cmd.sheetId, cmd.target);
40652
40663
  break;
40653
40664
  case "REMOVE_COLUMNS_ROWS":
40654
- for (let el of [...cmd.elements].sort((a, b) => b - a)) {
40665
+ const elements = [...cmd.elements].sort((a, b) => b - a);
40666
+ for (const group of groupConsecutive(elements)) {
40655
40667
  if (cmd.dimension === "COL") {
40656
- this.shiftBordersHorizontally(cmd.sheetId, el + 1, -1);
40668
+ this.shiftBordersHorizontally(cmd.sheetId, group[group.length - 1] + 1, -group.length);
40657
40669
  }
40658
40670
  else {
40659
- this.shiftBordersVertically(cmd.sheetId, el + 1, -1);
40671
+ this.shiftBordersVertically(cmd.sheetId, group[group.length - 1] + 1, -group.length);
40660
40672
  }
40661
40673
  }
40662
40674
  break;
@@ -45021,12 +45033,7 @@ stores.inject(MyMetaStore, storeInstance);
45021
45033
  });
45022
45034
  }
45023
45035
  if (colIndex > deletedColumn) {
45024
- this.dispatch("UPDATE_CELL_POSITION", {
45025
- sheetId: sheet.id,
45026
- cellId: cellId,
45027
- col: colIndex - 1,
45028
- row: rowIndex,
45029
- });
45036
+ this.setNewPosition(cellId, sheet.id, colIndex - 1, rowIndex);
45030
45037
  }
45031
45038
  }
45032
45039
  }
@@ -45036,7 +45043,7 @@ stores.inject(MyMetaStore, storeInstance);
45036
45043
  * Move the cells after a column or rows insertion
45037
45044
  */
45038
45045
  moveCellsOnAddition(sheet, addedElement, quantity, dimension) {
45039
- const commands = [];
45046
+ const updates = [];
45040
45047
  for (let rowIndex = 0; rowIndex < sheet.rows.length; rowIndex++) {
45041
45048
  const row = sheet.rows[rowIndex];
45042
45049
  if (dimension !== "rows" || rowIndex >= addedElement) {
@@ -45045,20 +45052,20 @@ stores.inject(MyMetaStore, storeInstance);
45045
45052
  const cellId = row.cells[i];
45046
45053
  if (cellId) {
45047
45054
  if (dimension === "rows" || colIndex >= addedElement) {
45048
- commands.push({
45049
- type: "UPDATE_CELL_POSITION",
45055
+ updates.push({
45050
45056
  sheetId: sheet.id,
45051
45057
  cellId: cellId,
45052
45058
  col: colIndex + (dimension === "columns" ? quantity : 0),
45053
45059
  row: rowIndex + (dimension === "rows" ? quantity : 0),
45060
+ type: "UPDATE_CELL_POSITION",
45054
45061
  });
45055
45062
  }
45056
45063
  }
45057
45064
  }
45058
45065
  }
45059
45066
  }
45060
- for (let cmd of commands.reverse()) {
45061
- this.dispatch(cmd.type, cmd);
45067
+ for (let update of updates.reverse()) {
45068
+ this.updateCellPosition(update);
45062
45069
  }
45063
45070
  }
45064
45071
  /**
@@ -45091,12 +45098,7 @@ stores.inject(MyMetaStore, storeInstance);
45091
45098
  const colIndex = Number(i);
45092
45099
  const cellId = row.cells[i];
45093
45100
  if (cellId) {
45094
- this.dispatch("UPDATE_CELL_POSITION", {
45095
- sheetId: sheet.id,
45096
- cellId: cellId,
45097
- col: colIndex,
45098
- row: rowIndex - numberRows,
45099
- });
45101
+ this.setNewPosition(cellId, sheet.id, colIndex, rowIndex - numberRows);
45100
45102
  }
45101
45103
  }
45102
45104
  }
@@ -48289,17 +48291,17 @@ stores.inject(MyMetaStore, storeInstance);
48289
48291
  */
48290
48292
  function sortWithClusters(colorsToSort) {
48291
48293
  const clusters = [
48292
- { leadColor: rgba(255, 0, 0), colors: [] },
48293
- { leadColor: rgba(255, 128, 0), colors: [] },
48294
- { leadColor: rgba(128, 128, 0), colors: [] },
48295
- { leadColor: rgba(128, 255, 0), colors: [] },
48296
- { leadColor: rgba(0, 255, 0), colors: [] },
48297
- { leadColor: rgba(0, 255, 128), colors: [] },
48298
- { leadColor: rgba(0, 255, 255), colors: [] },
48299
- { leadColor: rgba(0, 127, 255), colors: [] },
48300
- { leadColor: rgba(0, 0, 255), colors: [] },
48301
- { leadColor: rgba(127, 0, 255), colors: [] },
48302
- { leadColor: rgba(128, 0, 128), colors: [] },
48294
+ { leadColor: rgba(255, 0, 0), colors: [] }, // red
48295
+ { leadColor: rgba(255, 128, 0), colors: [] }, // orange
48296
+ { leadColor: rgba(128, 128, 0), colors: [] }, // yellow
48297
+ { leadColor: rgba(128, 255, 0), colors: [] }, // chartreuse
48298
+ { leadColor: rgba(0, 255, 0), colors: [] }, // green
48299
+ { leadColor: rgba(0, 255, 128), colors: [] }, // spring green
48300
+ { leadColor: rgba(0, 255, 255), colors: [] }, // cyan
48301
+ { leadColor: rgba(0, 127, 255), colors: [] }, // azure
48302
+ { leadColor: rgba(0, 0, 255), colors: [] }, // blue
48303
+ { leadColor: rgba(127, 0, 255), colors: [] }, // violet
48304
+ { leadColor: rgba(128, 0, 128), colors: [] }, // magenta
48303
48305
  { leadColor: rgba(255, 0, 128), colors: [] }, // rose
48304
48306
  ];
48305
48307
  for (const color of colorsToSort.map(colorToRGBA)) {
@@ -55420,7 +55422,7 @@ stores.inject(MyMetaStore, storeInstance);
55420
55422
  .map((sheetEl) => sheetEl.getBoundingClientRect())
55421
55423
  .map((rect) => ({
55422
55424
  x: rect.x,
55423
- width: rect.width - 1,
55425
+ width: rect.width - 1, // -1 to compensate negative margin
55424
55426
  y: rect.y,
55425
55427
  height: rect.height,
55426
55428
  }));
@@ -55642,7 +55644,7 @@ stores.inject(MyMetaStore, storeInstance);
55642
55644
  }
55643
55645
  return cssPropertiesToCss({
55644
55646
  top: `${groupBox.headerRect.height / 2}px`,
55645
- left: `calc(50% - 1px)`,
55647
+ left: `calc(50% - 1px)`, // -1px: we want the border to be on the center
55646
55648
  width: `30%`,
55647
55649
  height: `calc(100% - ${groupBox.headerRect.height / 2}px)`,
55648
55650
  "border-left": `1px solid ${HEADER_GROUPING_BORDER_COLOR}`,
@@ -55694,7 +55696,7 @@ stores.inject(MyMetaStore, storeInstance);
55694
55696
  return "";
55695
55697
  }
55696
55698
  return cssPropertiesToCss({
55697
- top: `calc(50% - 1px)`,
55699
+ top: `calc(50% - 1px)`, // -1px: we want the border to be on the center
55698
55700
  left: `${groupBox.headerRect.width / 2}px`,
55699
55701
  width: `calc(100% - ${groupBox.headerRect.width / 2}px)`,
55700
55702
  height: `30%`,
@@ -57112,7 +57114,7 @@ stores.inject(MyMetaStore, storeInstance);
57112
57114
  const gridColSize = GROUP_LAYER_WIDTH * this.rowLayers.length;
57113
57115
  const gridRowSize = GROUP_LAYER_WIDTH * this.colLayers.length;
57114
57116
  return cssPropertiesToCss({
57115
- "grid-template-columns": `${gridColSize ? gridColSize + 2 : 0}px auto`,
57117
+ "grid-template-columns": `${gridColSize ? gridColSize + 2 : 0}px auto`, // +2: margins
57116
57118
  "grid-template-rows": `${gridRowSize ? gridRowSize + 2 : 0}px auto`,
57117
57119
  });
57118
57120
  }
@@ -58562,7 +58564,7 @@ stores.inject(MyMetaStore, storeInstance);
58562
58564
  }
58563
58565
 
58564
58566
  class StateObserver {
58565
- changes = [];
58567
+ changes;
58566
58568
  commands = [];
58567
58569
  /**
58568
58570
  * Record the changes which could happen in the given callback, save them in a
@@ -58594,7 +58596,7 @@ stores.inject(MyMetaStore, storeInstance);
58594
58596
  if (value[key] === val) {
58595
58597
  return;
58596
58598
  }
58597
- this.changes.push({
58599
+ this.changes?.push({
58598
58600
  path: args,
58599
58601
  before: value[key],
58600
58602
  after: val,
@@ -59725,7 +59727,7 @@ stores.inject(MyMetaStore, storeInstance);
59725
59727
  const colHeaderXc = toXC(tableZone.left + i, tableZone.top);
59726
59728
  const colName = sheetData.cells[colHeaderXc]?.content || `col${i}`;
59727
59729
  const colAttributes = [
59728
- ["id", i + 1],
59730
+ ["id", i + 1], // id cannot be 0
59729
59731
  ["name", colName],
59730
59732
  ];
59731
59733
  columns.push(escapeXml /*xml*/ `<tableColumn ${formatAttributes(colAttributes)}/>`);
@@ -60882,9 +60884,9 @@ stores.inject(MyMetaStore, storeInstance);
60882
60884
  exports.tokenize = tokenize;
60883
60885
 
60884
60886
 
60885
- __info__.version = "17.2.17";
60886
- __info__.date = "2024-07-18T14:23:50.417Z";
60887
- __info__.hash = "9e0ea24";
60887
+ __info__.version = "17.2.19";
60888
+ __info__.date = "2024-08-02T08:22:56.367Z";
60889
+ __info__.hash = "c5ae261";
60888
60890
 
60889
60891
 
60890
60892
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);