@odoo/o-spreadsheet 17.0.31 → 17.0.33

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.0.31
6
- * @date 2024-07-18T14:22:00.324Z
7
- * @hash c64db0d
5
+ * @version 17.0.33
6
+ * @date 2024-08-02T08:18:55.061Z
7
+ * @hash 4ad4049
8
8
  */
9
9
 
10
10
  (function (exports, owl) {
@@ -593,7 +593,7 @@
593
593
  let timeout;
594
594
  return function () {
595
595
  const context = this;
596
- const args = arguments;
596
+ const args = Array.from(arguments);
597
597
  function later() {
598
598
  timeout = null;
599
599
  if (!immediate) {
@@ -796,7 +796,7 @@
796
796
  */
797
797
  function largeMax(array) {
798
798
  let len = array.length;
799
- if (len < 100000)
799
+ if (len < 100_000)
800
800
  return Math.max(...array);
801
801
  let max = -Infinity;
802
802
  while (len--) {
@@ -810,7 +810,7 @@
810
810
  */
811
811
  function largeMin(array) {
812
812
  let len = array.length;
813
- if (len < 100000)
813
+ if (len < 100_000)
814
814
  return Math.min(...array);
815
815
  let min = +Infinity;
816
816
  while (len--) {
@@ -2565,13 +2565,16 @@
2565
2565
  }
2566
2566
  return new RegExp("^" + exp + "$", "i");
2567
2567
  }
2568
- function evaluatePredicate(value = "", criterion) {
2568
+ function evaluatePredicate(value = "", criterion, locale) {
2569
2569
  const { operator, operand } = criterion;
2570
2570
  if (operand === undefined || value === null || operand === null) {
2571
2571
  return false;
2572
2572
  }
2573
2573
  if (typeof operand === "number" && operator === "=") {
2574
- return toString(value) === toString(operand);
2574
+ if (typeof value === "string" && (isNumber(value, locale) || isDateTime(value, locale))) {
2575
+ return toNumber(value, locale) === operand;
2576
+ }
2577
+ return value === operand;
2575
2578
  }
2576
2579
  if (operator === "<>" || operator === "=") {
2577
2580
  let result;
@@ -2650,7 +2653,7 @@
2650
2653
  for (let k = 0; k < countArg - 1; k += 2) {
2651
2654
  const criteriaValue = args[k][i][j];
2652
2655
  const criterion = predicates[k / 2];
2653
- validatedPredicates = evaluatePredicate(criteriaValue ?? undefined, criterion);
2656
+ validatedPredicates = evaluatePredicate(criteriaValue ?? undefined, criterion, locale);
2654
2657
  if (!validatedPredicates) {
2655
2658
  break;
2656
2659
  }
@@ -5899,7 +5902,7 @@
5899
5902
  function numberCell(value, localeFormat) {
5900
5903
  return {
5901
5904
  type: CellValueType.number,
5902
- value: value || 0,
5905
+ value: value || 0, // necessary to avoid "-0" and NaN values,
5903
5906
  format: localeFormat.format,
5904
5907
  isAutoSummable: true,
5905
5908
  defaultAlign: "right",
@@ -8432,8 +8435,8 @@
8432
8435
  function getDefaultChartJsRuntime(chart, labels, fontColor, { format, locale, truncateLabels = true }) {
8433
8436
  const options = {
8434
8437
  // https://www.chartjs.org/docs/latest/general/responsive.html
8435
- responsive: true,
8436
- maintainAspectRatio: false,
8438
+ responsive: true, // will resize when its container is resized
8439
+ maintainAspectRatio: false, // doesn't maintain the aspect ration (width/height =2 by default) so the user has the choice of the exact layout
8437
8440
  layout: {
8438
8441
  padding: { left: 20, right: 20, top: chart.title ? 10 : 25, bottom: 10 },
8439
8442
  },
@@ -8742,7 +8745,7 @@
8742
8745
  },
8743
8746
  y: {
8744
8747
  position: chart.verticalAxisPosition,
8745
- beginAtZero: true,
8748
+ beginAtZero: true, // the origin of the y axis is always zero
8746
8749
  ticks: {
8747
8750
  color: fontColor,
8748
8751
  callback: (value) => {
@@ -9396,7 +9399,7 @@
9396
9399
  },
9397
9400
  y: {
9398
9401
  position: chart.verticalAxisPosition,
9399
- beginAtZero: true,
9402
+ beginAtZero: true, // the origin of the y axis is always zero
9400
9403
  ticks: {
9401
9404
  color: fontColor,
9402
9405
  callback: (value) => {
@@ -9484,7 +9487,7 @@
9484
9487
  const dataset = {
9485
9488
  label,
9486
9489
  data,
9487
- tension: 0,
9490
+ tension: 0, // 0 -> render straight lines, which is much faster
9488
9491
  borderColor: color,
9489
9492
  backgroundColor,
9490
9493
  pointBackgroundColor: color,
@@ -9595,7 +9598,7 @@
9595
9598
  ...this.getDefinition(),
9596
9599
  backgroundColor: toXlsxHexColor(this.background || BACKGROUND_CHART_COLOR),
9597
9600
  fontColor: toXlsxHexColor(chartFontColor(this.background)),
9598
- verticalAxisPosition: "left",
9601
+ verticalAxisPosition: "left", //TODO ExcelChartDefinition should be adapted, but can be done later
9599
9602
  dataSets,
9600
9603
  labelRange,
9601
9604
  };
@@ -26699,7 +26702,9 @@
26699
26702
  argToFocus: 0,
26700
26703
  });
26701
26704
  compositionActive = false;
26705
+ spreadsheetRect = useSpreadsheetRect();
26702
26706
  get assistantStyle() {
26707
+ const composerRect = this.composerRef.el.getBoundingClientRect();
26703
26708
  const assistantStyle = {};
26704
26709
  assistantStyle["min-width"] = `${this.props.rect?.width || ASSISTANT_WIDTH}px`;
26705
26710
  if (this.autoCompleteState.type === "function") {
@@ -26722,6 +26727,10 @@
26722
26727
  assistantStyle.right = `0px`;
26723
26728
  }
26724
26729
  }
26730
+ if (this.props.focus === "contentFocus" &&
26731
+ composerRect.left + ASSISTANT_WIDTH > this.spreadsheetRect.width) {
26732
+ assistantStyle.right = "0px";
26733
+ }
26725
26734
  return cssPropertiesToCss(assistantStyle);
26726
26735
  }
26727
26736
  // we can't allow input events to be triggered while we remove and add back the content of the composer in processContent
@@ -28370,10 +28379,13 @@
28370
28379
  row: undefined,
28371
28380
  };
28372
28381
  const { Date } = window;
28373
- let x = 0;
28374
- let y = 0;
28382
+ let x = undefined;
28383
+ let y = undefined;
28375
28384
  let lastMoved = 0;
28376
28385
  function getPosition() {
28386
+ if (x === undefined || y === undefined) {
28387
+ return { col: -1, row: -1 };
28388
+ }
28377
28389
  const col = env.model.getters.getColIndex(x);
28378
28390
  const row = env.model.getters.getRowIndex(y);
28379
28391
  return { col, row };
@@ -29577,7 +29589,7 @@
29577
29589
  onScroll(offset) {
29578
29590
  const { scrollX } = this.env.model.getters.getActiveSheetDOMScrollInfo();
29579
29591
  this.env.model.dispatch("SET_VIEWPORT_OFFSET", {
29580
- offsetX: scrollX,
29592
+ offsetX: scrollX, // offsetX is the same
29581
29593
  offsetY: offset,
29582
29594
  });
29583
29595
  }
@@ -29788,8 +29800,8 @@
29788
29800
  "CTRL+SHIFT+L": () => this.setHorizontalAlign("left"),
29789
29801
  "CTRL+SHIFT+R": () => this.setHorizontalAlign("right"),
29790
29802
  "CTRL+SHIFT+V": () => PASTE_VALUE_ACTION(this.env),
29791
- "CTRL+SHIFT+<": () => this.clearFormatting(),
29792
- "CTRL+<": () => this.clearFormatting(),
29803
+ "CTRL+SHIFT+<": () => this.clearFormatting(), // for qwerty
29804
+ "CTRL+<": () => this.clearFormatting(), // for azerty
29793
29805
  "CTRL+SHIFT+ ": () => {
29794
29806
  this.env.model.selection.selectAll();
29795
29807
  },
@@ -30603,10 +30615,10 @@
30603
30615
  const CF_TYPE_CONVERSION_MAP = {
30604
30616
  aboveAverage: undefined,
30605
30617
  expression: undefined,
30606
- cellIs: undefined,
30607
- colorScale: undefined,
30618
+ cellIs: undefined, // exist but isn't an operator in o_spreadsheet
30619
+ colorScale: undefined, // exist but isn't an operator in o_spreadsheet
30608
30620
  dataBar: undefined,
30609
- iconSet: undefined,
30621
+ iconSet: undefined, // exist but isn't an operator in o_spreadsheet
30610
30622
  top10: undefined,
30611
30623
  uniqueValues: undefined,
30612
30624
  duplicateValues: undefined,
@@ -30841,7 +30853,7 @@
30841
30853
  61: "993366",
30842
30854
  62: "333399",
30843
30855
  63: "333333",
30844
- 64: "000000",
30856
+ 64: "000000", // system foreground
30845
30857
  65: "FFFFFF", // system background
30846
30858
  };
30847
30859
  const IMAGE_MIMETYPE_TO_EXTENSION_MAPPING = {
@@ -34482,12 +34494,13 @@
34482
34494
  this.clearBorders(cmd.sheetId, cmd.target);
34483
34495
  break;
34484
34496
  case "REMOVE_COLUMNS_ROWS":
34485
- for (let el of [...cmd.elements].sort((a, b) => b - a)) {
34497
+ const elements = [...cmd.elements].sort((a, b) => b - a);
34498
+ for (const group of groupConsecutive(elements)) {
34486
34499
  if (cmd.dimension === "COL") {
34487
- this.shiftBordersHorizontally(cmd.sheetId, el + 1, -1);
34500
+ this.shiftBordersHorizontally(cmd.sheetId, group[group.length - 1] + 1, -group.length);
34488
34501
  }
34489
34502
  else {
34490
- this.shiftBordersVertically(cmd.sheetId, el + 1, -1);
34503
+ this.shiftBordersVertically(cmd.sheetId, group[group.length - 1] + 1, -group.length);
34491
34504
  }
34492
34505
  }
34493
34506
  break;
@@ -39548,12 +39561,7 @@
39548
39561
  });
39549
39562
  }
39550
39563
  if (colIndex > deletedColumn) {
39551
- this.dispatch("UPDATE_CELL_POSITION", {
39552
- sheetId: sheet.id,
39553
- cellId: cellId,
39554
- col: colIndex - 1,
39555
- row: rowIndex,
39556
- });
39564
+ this.setNewPosition(cellId, sheet.id, colIndex - 1, rowIndex);
39557
39565
  }
39558
39566
  }
39559
39567
  }
@@ -39563,7 +39571,7 @@
39563
39571
  * Move the cells after a column or rows insertion
39564
39572
  */
39565
39573
  moveCellsOnAddition(sheet, addedElement, quantity, dimension) {
39566
- const commands = [];
39574
+ const updates = [];
39567
39575
  for (let rowIndex = 0; rowIndex < sheet.rows.length; rowIndex++) {
39568
39576
  const row = sheet.rows[rowIndex];
39569
39577
  if (dimension !== "rows" || rowIndex >= addedElement) {
@@ -39572,20 +39580,20 @@
39572
39580
  const cellId = row.cells[i];
39573
39581
  if (cellId) {
39574
39582
  if (dimension === "rows" || colIndex >= addedElement) {
39575
- commands.push({
39576
- type: "UPDATE_CELL_POSITION",
39583
+ updates.push({
39577
39584
  sheetId: sheet.id,
39578
39585
  cellId: cellId,
39579
39586
  col: colIndex + (dimension === "columns" ? quantity : 0),
39580
39587
  row: rowIndex + (dimension === "rows" ? quantity : 0),
39588
+ type: "UPDATE_CELL_POSITION",
39581
39589
  });
39582
39590
  }
39583
39591
  }
39584
39592
  }
39585
39593
  }
39586
39594
  }
39587
- for (let cmd of commands.reverse()) {
39588
- this.dispatch(cmd.type, cmd);
39595
+ for (let update of updates.reverse()) {
39596
+ this.updateCellPosition(update);
39589
39597
  }
39590
39598
  }
39591
39599
  /**
@@ -39618,12 +39626,7 @@
39618
39626
  const colIndex = Number(i);
39619
39627
  const cellId = row.cells[i];
39620
39628
  if (cellId) {
39621
- this.dispatch("UPDATE_CELL_POSITION", {
39622
- sheetId: sheet.id,
39623
- cellId: cellId,
39624
- col: colIndex,
39625
- row: rowIndex - numberRows,
39626
- });
39629
+ this.setNewPosition(cellId, sheet.id, colIndex, rowIndex - numberRows);
39627
39630
  }
39628
39631
  }
39629
39632
  }
@@ -42236,17 +42239,17 @@
42236
42239
  */
42237
42240
  function sortWithClusters(colorsToSort) {
42238
42241
  const clusters = [
42239
- { leadColor: rgba(255, 0, 0), colors: [] },
42240
- { leadColor: rgba(255, 128, 0), colors: [] },
42241
- { leadColor: rgba(128, 128, 0), colors: [] },
42242
- { leadColor: rgba(128, 255, 0), colors: [] },
42243
- { leadColor: rgba(0, 255, 0), colors: [] },
42244
- { leadColor: rgba(0, 255, 128), colors: [] },
42245
- { leadColor: rgba(0, 255, 255), colors: [] },
42246
- { leadColor: rgba(0, 127, 255), colors: [] },
42247
- { leadColor: rgba(0, 0, 255), colors: [] },
42248
- { leadColor: rgba(127, 0, 255), colors: [] },
42249
- { leadColor: rgba(128, 0, 128), colors: [] },
42242
+ { leadColor: rgba(255, 0, 0), colors: [] }, // red
42243
+ { leadColor: rgba(255, 128, 0), colors: [] }, // orange
42244
+ { leadColor: rgba(128, 128, 0), colors: [] }, // yellow
42245
+ { leadColor: rgba(128, 255, 0), colors: [] }, // chartreuse
42246
+ { leadColor: rgba(0, 255, 0), colors: [] }, // green
42247
+ { leadColor: rgba(0, 255, 128), colors: [] }, // spring green
42248
+ { leadColor: rgba(0, 255, 255), colors: [] }, // cyan
42249
+ { leadColor: rgba(0, 127, 255), colors: [] }, // azure
42250
+ { leadColor: rgba(0, 0, 255), colors: [] }, // blue
42251
+ { leadColor: rgba(127, 0, 255), colors: [] }, // violet
42252
+ { leadColor: rgba(128, 0, 128), colors: [] }, // magenta
42250
42253
  { leadColor: rgba(255, 0, 128), colors: [] }, // rose
42251
42254
  ];
42252
42255
  for (const color of colorsToSort.map(colorToRGBA)) {
@@ -42552,40 +42555,45 @@
42552
42555
  getComputedStyles(sheetId) {
42553
42556
  const computedStyle = {};
42554
42557
  for (let cf of this.getters.getConditionalFormats(sheetId).reverse()) {
42555
- switch (cf.rule.type) {
42556
- case "ColorScaleRule":
42557
- for (let range of cf.ranges) {
42558
- this.applyColorScale(sheetId, range, cf.rule, computedStyle);
42559
- }
42560
- break;
42561
- case "CellIsRule":
42562
- const formulas = cf.rule.values.map((value) => value.startsWith("=") ? compile(value) : undefined);
42563
- for (let ref of cf.ranges) {
42564
- const zone = this.getters.getRangeFromSheetXC(sheetId, ref).zone;
42565
- for (let row = zone.top; row <= zone.bottom; row++) {
42566
- for (let col = zone.left; col <= zone.right; col++) {
42567
- const predicate = this.rulePredicate[cf.rule.type];
42568
- const target = { sheetId, col, row };
42569
- const values = cf.rule.values.map((value, i) => {
42570
- const compiledFormula = formulas[i];
42571
- if (compiledFormula) {
42572
- return this.getters.getTranslatedCellFormula(sheetId, col - zone.left, row - zone.top, {
42573
- ...compiledFormula,
42574
- dependencies: compiledFormula.dependencies.map((d) => this.getters.getRangeFromSheetXC(sheetId, d)),
42575
- });
42558
+ try {
42559
+ switch (cf.rule.type) {
42560
+ case "ColorScaleRule":
42561
+ for (let range of cf.ranges) {
42562
+ this.applyColorScale(sheetId, range, cf.rule, computedStyle);
42563
+ }
42564
+ break;
42565
+ case "CellIsRule":
42566
+ const formulas = cf.rule.values.map((value) => value.startsWith("=") ? compile(value) : undefined);
42567
+ for (let ref of cf.ranges) {
42568
+ const zone = this.getters.getRangeFromSheetXC(sheetId, ref).zone;
42569
+ for (let row = zone.top; row <= zone.bottom; row++) {
42570
+ for (let col = zone.left; col <= zone.right; col++) {
42571
+ const predicate = this.rulePredicate[cf.rule.type];
42572
+ const target = { sheetId, col, row };
42573
+ const values = cf.rule.values.map((value, i) => {
42574
+ const compiledFormula = formulas[i];
42575
+ if (compiledFormula) {
42576
+ return this.getters.getTranslatedCellFormula(sheetId, col - zone.left, row - zone.top, {
42577
+ ...compiledFormula,
42578
+ dependencies: compiledFormula.dependencies.map((d) => this.getters.getRangeFromSheetXC(sheetId, d)),
42579
+ });
42580
+ }
42581
+ return value;
42582
+ });
42583
+ if (predicate && predicate(target, { ...cf.rule, values })) {
42584
+ if (!computedStyle[col])
42585
+ computedStyle[col] = [];
42586
+ // we must combine all the properties of all the CF rules applied to the given cell
42587
+ computedStyle[col][row] = Object.assign(computedStyle[col]?.[row] || {}, cf.rule.style);
42576
42588
  }
42577
- return value;
42578
- });
42579
- if (predicate && predicate(target, { ...cf.rule, values })) {
42580
- if (!computedStyle[col])
42581
- computedStyle[col] = [];
42582
- // we must combine all the properties of all the CF rules applied to the given cell
42583
- computedStyle[col][row] = Object.assign(computedStyle[col]?.[row] || {}, cf.rule.style);
42584
42589
  }
42585
42590
  }
42586
42591
  }
42587
- }
42588
- break;
42592
+ break;
42593
+ }
42594
+ }
42595
+ catch (_) {
42596
+ // we ignore the errors within the evaluation of a rule
42589
42597
  }
42590
42598
  }
42591
42599
  return computedStyle;
@@ -52151,7 +52159,7 @@
52151
52159
  .map((sheetEl) => sheetEl.getBoundingClientRect())
52152
52160
  .map((rect) => ({
52153
52161
  x: rect.x,
52154
- width: rect.width - 1,
52162
+ width: rect.width - 1, // -1 to compensate negative margin
52155
52163
  y: rect.y,
52156
52164
  height: rect.height,
52157
52165
  }));
@@ -52376,7 +52384,7 @@
52376
52384
  }
52377
52385
  return cssPropertiesToCss({
52378
52386
  top: `${groupBox.headerRect.height / 2}px`,
52379
- left: `calc(50% - 1px)`,
52387
+ left: `calc(50% - 1px)`, // -1px: we want the border to be on the center
52380
52388
  width: `30%`,
52381
52389
  height: `calc(100% - ${groupBox.headerRect.height / 2}px)`,
52382
52390
  "border-left": `1px solid ${HEADER_GROUPING_BORDER_COLOR}`,
@@ -52428,7 +52436,7 @@
52428
52436
  return "";
52429
52437
  }
52430
52438
  return cssPropertiesToCss({
52431
- top: `calc(50% - 1px)`,
52439
+ top: `calc(50% - 1px)`, // -1px: we want the border to be on the center
52432
52440
  left: `${groupBox.headerRect.width / 2}px`,
52433
52441
  width: `calc(100% - ${groupBox.headerRect.width / 2}px)`,
52434
52442
  height: `30%`,
@@ -53829,7 +53837,7 @@
53829
53837
  const gridColSize = GROUP_LAYER_WIDTH * this.rowLayers.length;
53830
53838
  const gridRowSize = GROUP_LAYER_WIDTH * this.colLayers.length;
53831
53839
  return cssPropertiesToCss({
53832
- "grid-template-columns": `${gridColSize ? gridColSize + 2 : 0}px auto`,
53840
+ "grid-template-columns": `${gridColSize ? gridColSize + 2 : 0}px auto`, // +2: margins
53833
53841
  "grid-template-rows": `${gridRowSize ? gridRowSize + 2 : 0}px auto`,
53834
53842
  });
53835
53843
  }
@@ -55332,7 +55340,7 @@
55332
55340
  }
55333
55341
 
55334
55342
  class StateObserver {
55335
- changes = [];
55343
+ changes;
55336
55344
  commands = [];
55337
55345
  /**
55338
55346
  * Record the changes which could happen in the given callback, save them in a
@@ -55364,7 +55372,7 @@
55364
55372
  if (value[key] === val) {
55365
55373
  return;
55366
55374
  }
55367
- this.changes.push({
55375
+ this.changes?.push({
55368
55376
  path: args,
55369
55377
  before: value[key],
55370
55378
  after: val,
@@ -56495,7 +56503,7 @@
56495
56503
  const colHeaderXc = toXC(tableZone.left + i, tableZone.top);
56496
56504
  const colName = sheetData.cells[colHeaderXc]?.content || `col${i}`;
56497
56505
  const colAttributes = [
56498
- ["id", i + 1],
56506
+ ["id", i + 1], // id cannot be 0
56499
56507
  ["name", colName],
56500
56508
  ];
56501
56509
  columns.push(escapeXml /*xml*/ `<tableColumn ${formatAttributes(colAttributes)}/>`);
@@ -57577,9 +57585,9 @@
57577
57585
  exports.tokenize = tokenize;
57578
57586
 
57579
57587
 
57580
- __info__.version = "17.0.31";
57581
- __info__.date = "2024-07-18T14:22:00.324Z";
57582
- __info__.hash = "c64db0d";
57588
+ __info__.version = "17.0.33";
57589
+ __info__.date = "2024-08-02T08:18:55.061Z";
57590
+ __info__.hash = "4ad4049";
57583
57591
 
57584
57592
 
57585
57593
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);