@odoo/o-spreadsheet 17.2.18 → 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.18
7
- * @date 2024-07-24T10:28:05.353Z
8
- * @hash 6c65743
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
  }
@@ -35682,7 +35690,7 @@ stores.inject(MyMetaStore, storeInstance);
35682
35690
  onScroll(offset) {
35683
35691
  const { scrollX } = this.env.model.getters.getActiveSheetDOMScrollInfo();
35684
35692
  this.env.model.dispatch("SET_VIEWPORT_OFFSET", {
35685
- offsetX: scrollX,
35693
+ offsetX: scrollX, // offsetX is the same
35686
35694
  offsetY: offset,
35687
35695
  });
35688
35696
  }
@@ -35971,8 +35979,8 @@ stores.inject(MyMetaStore, storeInstance);
35971
35979
  "Ctrl+Shift+L": () => this.setHorizontalAlign("left"),
35972
35980
  "Ctrl+Shift+R": () => this.setHorizontalAlign("right"),
35973
35981
  "Ctrl+Shift+V": () => PASTE_AS_VALUE_ACTION(this.env),
35974
- "Ctrl+Shift+<": () => this.clearFormatting(),
35975
- "Ctrl+<": () => this.clearFormatting(),
35982
+ "Ctrl+Shift+<": () => this.clearFormatting(), // for qwerty
35983
+ "Ctrl+<": () => this.clearFormatting(), // for azerty
35976
35984
  "Ctrl+Shift+ ": () => {
35977
35985
  this.env.model.selection.selectAll();
35978
35986
  },
@@ -36773,10 +36781,10 @@ stores.inject(MyMetaStore, storeInstance);
36773
36781
  const CF_TYPE_CONVERSION_MAP = {
36774
36782
  aboveAverage: undefined,
36775
36783
  expression: undefined,
36776
- cellIs: undefined,
36777
- 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
36778
36786
  dataBar: undefined,
36779
- iconSet: undefined,
36787
+ iconSet: undefined, // exist but isn't an operator in o_spreadsheet
36780
36788
  top10: undefined,
36781
36789
  uniqueValues: undefined,
36782
36790
  duplicateValues: undefined,
@@ -37011,7 +37019,7 @@ stores.inject(MyMetaStore, storeInstance);
37011
37019
  61: "993366",
37012
37020
  62: "333399",
37013
37021
  63: "333333",
37014
- 64: "000000",
37022
+ 64: "000000", // system foreground
37015
37023
  65: "FFFFFF", // system background
37016
37024
  };
37017
37025
  const IMAGE_MIMETYPE_TO_EXTENSION_MAPPING = {
@@ -40654,12 +40662,13 @@ stores.inject(MyMetaStore, storeInstance);
40654
40662
  this.clearBorders(cmd.sheetId, cmd.target);
40655
40663
  break;
40656
40664
  case "REMOVE_COLUMNS_ROWS":
40657
- 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)) {
40658
40667
  if (cmd.dimension === "COL") {
40659
- this.shiftBordersHorizontally(cmd.sheetId, el + 1, -1);
40668
+ this.shiftBordersHorizontally(cmd.sheetId, group[group.length - 1] + 1, -group.length);
40660
40669
  }
40661
40670
  else {
40662
- this.shiftBordersVertically(cmd.sheetId, el + 1, -1);
40671
+ this.shiftBordersVertically(cmd.sheetId, group[group.length - 1] + 1, -group.length);
40663
40672
  }
40664
40673
  }
40665
40674
  break;
@@ -45024,12 +45033,7 @@ stores.inject(MyMetaStore, storeInstance);
45024
45033
  });
45025
45034
  }
45026
45035
  if (colIndex > deletedColumn) {
45027
- this.dispatch("UPDATE_CELL_POSITION", {
45028
- sheetId: sheet.id,
45029
- cellId: cellId,
45030
- col: colIndex - 1,
45031
- row: rowIndex,
45032
- });
45036
+ this.setNewPosition(cellId, sheet.id, colIndex - 1, rowIndex);
45033
45037
  }
45034
45038
  }
45035
45039
  }
@@ -45039,7 +45043,7 @@ stores.inject(MyMetaStore, storeInstance);
45039
45043
  * Move the cells after a column or rows insertion
45040
45044
  */
45041
45045
  moveCellsOnAddition(sheet, addedElement, quantity, dimension) {
45042
- const commands = [];
45046
+ const updates = [];
45043
45047
  for (let rowIndex = 0; rowIndex < sheet.rows.length; rowIndex++) {
45044
45048
  const row = sheet.rows[rowIndex];
45045
45049
  if (dimension !== "rows" || rowIndex >= addedElement) {
@@ -45048,20 +45052,20 @@ stores.inject(MyMetaStore, storeInstance);
45048
45052
  const cellId = row.cells[i];
45049
45053
  if (cellId) {
45050
45054
  if (dimension === "rows" || colIndex >= addedElement) {
45051
- commands.push({
45052
- type: "UPDATE_CELL_POSITION",
45055
+ updates.push({
45053
45056
  sheetId: sheet.id,
45054
45057
  cellId: cellId,
45055
45058
  col: colIndex + (dimension === "columns" ? quantity : 0),
45056
45059
  row: rowIndex + (dimension === "rows" ? quantity : 0),
45060
+ type: "UPDATE_CELL_POSITION",
45057
45061
  });
45058
45062
  }
45059
45063
  }
45060
45064
  }
45061
45065
  }
45062
45066
  }
45063
- for (let cmd of commands.reverse()) {
45064
- this.dispatch(cmd.type, cmd);
45067
+ for (let update of updates.reverse()) {
45068
+ this.updateCellPosition(update);
45065
45069
  }
45066
45070
  }
45067
45071
  /**
@@ -45094,12 +45098,7 @@ stores.inject(MyMetaStore, storeInstance);
45094
45098
  const colIndex = Number(i);
45095
45099
  const cellId = row.cells[i];
45096
45100
  if (cellId) {
45097
- this.dispatch("UPDATE_CELL_POSITION", {
45098
- sheetId: sheet.id,
45099
- cellId: cellId,
45100
- col: colIndex,
45101
- row: rowIndex - numberRows,
45102
- });
45101
+ this.setNewPosition(cellId, sheet.id, colIndex, rowIndex - numberRows);
45103
45102
  }
45104
45103
  }
45105
45104
  }
@@ -48292,17 +48291,17 @@ stores.inject(MyMetaStore, storeInstance);
48292
48291
  */
48293
48292
  function sortWithClusters(colorsToSort) {
48294
48293
  const clusters = [
48295
- { leadColor: rgba(255, 0, 0), colors: [] },
48296
- { leadColor: rgba(255, 128, 0), colors: [] },
48297
- { leadColor: rgba(128, 128, 0), colors: [] },
48298
- { leadColor: rgba(128, 255, 0), colors: [] },
48299
- { leadColor: rgba(0, 255, 0), colors: [] },
48300
- { leadColor: rgba(0, 255, 128), colors: [] },
48301
- { leadColor: rgba(0, 255, 255), colors: [] },
48302
- { leadColor: rgba(0, 127, 255), colors: [] },
48303
- { leadColor: rgba(0, 0, 255), colors: [] },
48304
- { leadColor: rgba(127, 0, 255), colors: [] },
48305
- { 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
48306
48305
  { leadColor: rgba(255, 0, 128), colors: [] }, // rose
48307
48306
  ];
48308
48307
  for (const color of colorsToSort.map(colorToRGBA)) {
@@ -55423,7 +55422,7 @@ stores.inject(MyMetaStore, storeInstance);
55423
55422
  .map((sheetEl) => sheetEl.getBoundingClientRect())
55424
55423
  .map((rect) => ({
55425
55424
  x: rect.x,
55426
- width: rect.width - 1,
55425
+ width: rect.width - 1, // -1 to compensate negative margin
55427
55426
  y: rect.y,
55428
55427
  height: rect.height,
55429
55428
  }));
@@ -55645,7 +55644,7 @@ stores.inject(MyMetaStore, storeInstance);
55645
55644
  }
55646
55645
  return cssPropertiesToCss({
55647
55646
  top: `${groupBox.headerRect.height / 2}px`,
55648
- left: `calc(50% - 1px)`,
55647
+ left: `calc(50% - 1px)`, // -1px: we want the border to be on the center
55649
55648
  width: `30%`,
55650
55649
  height: `calc(100% - ${groupBox.headerRect.height / 2}px)`,
55651
55650
  "border-left": `1px solid ${HEADER_GROUPING_BORDER_COLOR}`,
@@ -55697,7 +55696,7 @@ stores.inject(MyMetaStore, storeInstance);
55697
55696
  return "";
55698
55697
  }
55699
55698
  return cssPropertiesToCss({
55700
- top: `calc(50% - 1px)`,
55699
+ top: `calc(50% - 1px)`, // -1px: we want the border to be on the center
55701
55700
  left: `${groupBox.headerRect.width / 2}px`,
55702
55701
  width: `calc(100% - ${groupBox.headerRect.width / 2}px)`,
55703
55702
  height: `30%`,
@@ -57115,7 +57114,7 @@ stores.inject(MyMetaStore, storeInstance);
57115
57114
  const gridColSize = GROUP_LAYER_WIDTH * this.rowLayers.length;
57116
57115
  const gridRowSize = GROUP_LAYER_WIDTH * this.colLayers.length;
57117
57116
  return cssPropertiesToCss({
57118
- "grid-template-columns": `${gridColSize ? gridColSize + 2 : 0}px auto`,
57117
+ "grid-template-columns": `${gridColSize ? gridColSize + 2 : 0}px auto`, // +2: margins
57119
57118
  "grid-template-rows": `${gridRowSize ? gridRowSize + 2 : 0}px auto`,
57120
57119
  });
57121
57120
  }
@@ -58565,7 +58564,7 @@ stores.inject(MyMetaStore, storeInstance);
58565
58564
  }
58566
58565
 
58567
58566
  class StateObserver {
58568
- changes = [];
58567
+ changes;
58569
58568
  commands = [];
58570
58569
  /**
58571
58570
  * Record the changes which could happen in the given callback, save them in a
@@ -58597,7 +58596,7 @@ stores.inject(MyMetaStore, storeInstance);
58597
58596
  if (value[key] === val) {
58598
58597
  return;
58599
58598
  }
58600
- this.changes.push({
58599
+ this.changes?.push({
58601
58600
  path: args,
58602
58601
  before: value[key],
58603
58602
  after: val,
@@ -59728,7 +59727,7 @@ stores.inject(MyMetaStore, storeInstance);
59728
59727
  const colHeaderXc = toXC(tableZone.left + i, tableZone.top);
59729
59728
  const colName = sheetData.cells[colHeaderXc]?.content || `col${i}`;
59730
59729
  const colAttributes = [
59731
- ["id", i + 1],
59730
+ ["id", i + 1], // id cannot be 0
59732
59731
  ["name", colName],
59733
59732
  ];
59734
59733
  columns.push(escapeXml /*xml*/ `<tableColumn ${formatAttributes(colAttributes)}/>`);
@@ -60885,9 +60884,9 @@ stores.inject(MyMetaStore, storeInstance);
60885
60884
  exports.tokenize = tokenize;
60886
60885
 
60887
60886
 
60888
- __info__.version = "17.2.18";
60889
- __info__.date = "2024-07-24T10:28:05.353Z";
60890
- __info__.hash = "6c65743";
60887
+ __info__.version = "17.2.19";
60888
+ __info__.date = "2024-08-02T08:22:56.367Z";
60889
+ __info__.hash = "c5ae261";
60891
60890
 
60892
60891
 
60893
60892
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);