@odoo/o-spreadsheet 17.1.25 → 17.1.26

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.1.25
6
- * @date 2024-07-24T10:26:01.576Z
7
- * @hash 0edff47
5
+ * @version 17.1.26
6
+ * @date 2024-08-02T08:23:08.499Z
7
+ * @hash 4ba7e55
8
8
  */
9
9
 
10
10
  'use strict';
@@ -481,7 +481,7 @@ function debounce(func, wait, immediate) {
481
481
  let timeout;
482
482
  return function () {
483
483
  const context = this;
484
- const args = arguments;
484
+ const args = Array.from(arguments);
485
485
  function later() {
486
486
  timeout = null;
487
487
  if (!immediate) {
@@ -684,7 +684,7 @@ function isNumberBetween(value, min, max) {
684
684
  */
685
685
  function largeMax(array) {
686
686
  let len = array.length;
687
- if (len < 100000)
687
+ if (len < 100_000)
688
688
  return Math.max(...array);
689
689
  let max = -Infinity;
690
690
  while (len--) {
@@ -698,7 +698,7 @@ function largeMax(array) {
698
698
  */
699
699
  function largeMin(array) {
700
700
  let len = array.length;
701
- if (len < 100000)
701
+ if (len < 100_000)
702
702
  return Math.min(...array);
703
703
  let min = +Infinity;
704
704
  while (len--) {
@@ -2615,13 +2615,16 @@ function operandToRegExp(operand) {
2615
2615
  }
2616
2616
  return new RegExp("^" + exp + "$", "i");
2617
2617
  }
2618
- function evaluatePredicate(value = "", criterion) {
2618
+ function evaluatePredicate(value = "", criterion, locale) {
2619
2619
  const { operator, operand } = criterion;
2620
2620
  if (operand === undefined || value === null || operand === null) {
2621
2621
  return false;
2622
2622
  }
2623
2623
  if (typeof operand === "number" && operator === "=") {
2624
- return value.toString() === operand.toString();
2624
+ if (typeof value === "string" && (isNumber(value, locale) || isDateTime(value, locale))) {
2625
+ return toNumber(value, locale) === operand;
2626
+ }
2627
+ return value === operand;
2625
2628
  }
2626
2629
  if (operator === "<>" || operator === "=") {
2627
2630
  let result;
@@ -2699,7 +2702,7 @@ function visitMatchingRanges(args, cb, locale, isQuery = false) {
2699
2702
  for (let k = 0; k < countArg - 1; k += 2) {
2700
2703
  const criteriaValue = toMatrix(args[k])[i][j].value;
2701
2704
  const criterion = predicates[k / 2];
2702
- validatedPredicates = evaluatePredicate(criteriaValue ?? undefined, criterion);
2705
+ validatedPredicates = evaluatePredicate(criteriaValue ?? undefined, criterion, locale);
2703
2706
  if (!validatedPredicates) {
2704
2707
  break;
2705
2708
  }
@@ -5981,7 +5984,7 @@ function textCell(value, localeFormat) {
5981
5984
  function numberCell(value, localeFormat) {
5982
5985
  return {
5983
5986
  type: CellValueType.number,
5984
- value: value || 0,
5987
+ value: value || 0, // necessary to avoid "-0" and NaN values,
5985
5988
  format: localeFormat.format,
5986
5989
  isAutoSummable: true,
5987
5990
  defaultAlign: "right",
@@ -8472,8 +8475,8 @@ function truncateLabel(label) {
8472
8475
  function getDefaultChartJsRuntime(chart, labels, fontColor, { format, locale, truncateLabels = true }) {
8473
8476
  const options = {
8474
8477
  // https://www.chartjs.org/docs/latest/general/responsive.html
8475
- responsive: true,
8476
- maintainAspectRatio: false,
8478
+ responsive: true, // will resize when its container is resized
8479
+ maintainAspectRatio: false, // doesn't maintain the aspect ration (width/height =2 by default) so the user has the choice of the exact layout
8477
8480
  layout: {
8478
8481
  padding: { left: 20, right: 20, top: chart.title ? 10 : 25, bottom: 10 },
8479
8482
  },
@@ -8519,7 +8522,7 @@ function getDefaultChartJsRuntime(chart, labels, fontColor, { format, locale, tr
8519
8522
  labels: truncateLabels ? labels.map(truncateLabel) : labels,
8520
8523
  datasets: [],
8521
8524
  },
8522
- platform: undefined,
8525
+ platform: undefined, // This key is optional and will be set by chart.js
8523
8526
  plugins: [],
8524
8527
  };
8525
8528
  }
@@ -8783,7 +8786,7 @@ function getBarConfiguration(chart, labels, localeFormat) {
8783
8786
  },
8784
8787
  y: {
8785
8788
  position: chart.verticalAxisPosition,
8786
- beginAtZero: true,
8789
+ beginAtZero: true, // the origin of the y axis is always zero
8787
8790
  ticks: {
8788
8791
  color: fontColor,
8789
8792
  callback: (value) => {
@@ -9437,7 +9440,7 @@ function getLineConfiguration(chart, labels, options) {
9437
9440
  },
9438
9441
  y: {
9439
9442
  position: chart.verticalAxisPosition,
9440
- beginAtZero: true,
9443
+ beginAtZero: true, // the origin of the y axis is always zero
9441
9444
  ticks: {
9442
9445
  color: fontColor,
9443
9446
  callback: (value) => {
@@ -9525,7 +9528,7 @@ function createLineChartRuntime(chart, getters) {
9525
9528
  const dataset = {
9526
9529
  label,
9527
9530
  data,
9528
- tension: 0,
9531
+ tension: 0, // 0 -> render straight lines, which is much faster
9529
9532
  borderColor: color,
9530
9533
  backgroundColor,
9531
9534
  pointBackgroundColor: color,
@@ -9636,7 +9639,7 @@ class PieChart extends AbstractChart {
9636
9639
  ...this.getDefinition(),
9637
9640
  backgroundColor: toXlsxHexColor(this.background || BACKGROUND_CHART_COLOR),
9638
9641
  fontColor: toXlsxHexColor(chartFontColor(this.background)),
9639
- verticalAxisPosition: "left",
9642
+ verticalAxisPosition: "left", //TODO ExcelChartDefinition should be adapted, but can be done later
9640
9643
  dataSets,
9641
9644
  labelRange,
9642
9645
  };
@@ -27203,7 +27206,9 @@ class Composer extends owl.Component {
27203
27206
  argToFocus: 0,
27204
27207
  });
27205
27208
  compositionActive = false;
27209
+ spreadsheetRect = useSpreadsheetRect();
27206
27210
  get assistantStyle() {
27211
+ const composerRect = this.composerRef.el.getBoundingClientRect();
27207
27212
  const assistantStyle = {};
27208
27213
  assistantStyle["min-width"] = `${this.props.rect?.width || ASSISTANT_WIDTH}px`;
27209
27214
  if (this.autoCompleteState.type === "function") {
@@ -27226,6 +27231,10 @@ class Composer extends owl.Component {
27226
27231
  assistantStyle.right = `0px`;
27227
27232
  }
27228
27233
  }
27234
+ if (this.props.focus === "contentFocus" &&
27235
+ composerRect.left + ASSISTANT_WIDTH > this.spreadsheetRect.width) {
27236
+ assistantStyle.right = "0px";
27237
+ }
27229
27238
  return cssPropertiesToCss(assistantStyle);
27230
27239
  }
27231
27240
  // we can't allow input events to be triggered while we remove and add back the content of the composer in processContent
@@ -30059,7 +30068,7 @@ class VerticalScrollBar extends owl.Component {
30059
30068
  onScroll(offset) {
30060
30069
  const { scrollX } = this.env.model.getters.getActiveSheetDOMScrollInfo();
30061
30070
  this.env.model.dispatch("SET_VIEWPORT_OFFSET", {
30062
- offsetX: scrollX,
30071
+ offsetX: scrollX, // offsetX is the same
30063
30072
  offsetY: offset,
30064
30073
  });
30065
30074
  }
@@ -30272,8 +30281,8 @@ class Grid extends owl.Component {
30272
30281
  "Ctrl+Shift+L": () => this.setHorizontalAlign("left"),
30273
30282
  "Ctrl+Shift+R": () => this.setHorizontalAlign("right"),
30274
30283
  "Ctrl+Shift+V": () => PASTE_AS_VALUE_ACTION(this.env),
30275
- "Ctrl+Shift+<": () => this.clearFormatting(),
30276
- "Ctrl+<": () => this.clearFormatting(),
30284
+ "Ctrl+Shift+<": () => this.clearFormatting(), // for qwerty
30285
+ "Ctrl+<": () => this.clearFormatting(), // for azerty
30277
30286
  "Ctrl+Shift+ ": () => {
30278
30287
  this.env.model.selection.selectAll();
30279
30288
  },
@@ -31071,10 +31080,10 @@ function convertCFCellIsOperator(xlsxCfOperator) {
31071
31080
  const CF_TYPE_CONVERSION_MAP = {
31072
31081
  aboveAverage: undefined,
31073
31082
  expression: undefined,
31074
- cellIs: undefined,
31075
- colorScale: undefined,
31083
+ cellIs: undefined, // exist but isn't an operator in o_spreadsheet
31084
+ colorScale: undefined, // exist but isn't an operator in o_spreadsheet
31076
31085
  dataBar: undefined,
31077
- iconSet: undefined,
31086
+ iconSet: undefined, // exist but isn't an operator in o_spreadsheet
31078
31087
  top10: undefined,
31079
31088
  uniqueValues: undefined,
31080
31089
  duplicateValues: undefined,
@@ -31309,7 +31318,7 @@ const XLSX_INDEXED_COLORS = {
31309
31318
  61: "993366",
31310
31319
  62: "333399",
31311
31320
  63: "333333",
31312
- 64: "000000",
31321
+ 64: "000000", // system foreground
31313
31322
  65: "FFFFFF", // system background
31314
31323
  };
31315
31324
  const IMAGE_MIMETYPE_TO_EXTENSION_MAPPING = {
@@ -34979,12 +34988,13 @@ class BordersPlugin extends CorePlugin {
34979
34988
  this.clearBorders(cmd.sheetId, cmd.target);
34980
34989
  break;
34981
34990
  case "REMOVE_COLUMNS_ROWS":
34982
- for (let el of [...cmd.elements].sort((a, b) => b - a)) {
34991
+ const elements = [...cmd.elements].sort((a, b) => b - a);
34992
+ for (const group of groupConsecutive(elements)) {
34983
34993
  if (cmd.dimension === "COL") {
34984
- this.shiftBordersHorizontally(cmd.sheetId, el + 1, -1);
34994
+ this.shiftBordersHorizontally(cmd.sheetId, group[group.length - 1] + 1, -group.length);
34985
34995
  }
34986
34996
  else {
34987
- this.shiftBordersVertically(cmd.sheetId, el + 1, -1);
34997
+ this.shiftBordersVertically(cmd.sheetId, group[group.length - 1] + 1, -group.length);
34988
34998
  }
34989
34999
  }
34990
35000
  break;
@@ -40016,12 +40026,7 @@ class SheetPlugin extends CorePlugin {
40016
40026
  });
40017
40027
  }
40018
40028
  if (colIndex > deletedColumn) {
40019
- this.dispatch("UPDATE_CELL_POSITION", {
40020
- sheetId: sheet.id,
40021
- cellId: cellId,
40022
- col: colIndex - 1,
40023
- row: rowIndex,
40024
- });
40029
+ this.setNewPosition(cellId, sheet.id, colIndex - 1, rowIndex);
40025
40030
  }
40026
40031
  }
40027
40032
  }
@@ -40031,7 +40036,7 @@ class SheetPlugin extends CorePlugin {
40031
40036
  * Move the cells after a column or rows insertion
40032
40037
  */
40033
40038
  moveCellsOnAddition(sheet, addedElement, quantity, dimension) {
40034
- const commands = [];
40039
+ const updates = [];
40035
40040
  for (let rowIndex = 0; rowIndex < sheet.rows.length; rowIndex++) {
40036
40041
  const row = sheet.rows[rowIndex];
40037
40042
  if (dimension !== "rows" || rowIndex >= addedElement) {
@@ -40040,20 +40045,20 @@ class SheetPlugin extends CorePlugin {
40040
40045
  const cellId = row.cells[i];
40041
40046
  if (cellId) {
40042
40047
  if (dimension === "rows" || colIndex >= addedElement) {
40043
- commands.push({
40044
- type: "UPDATE_CELL_POSITION",
40048
+ updates.push({
40045
40049
  sheetId: sheet.id,
40046
40050
  cellId: cellId,
40047
40051
  col: colIndex + (dimension === "columns" ? quantity : 0),
40048
40052
  row: rowIndex + (dimension === "rows" ? quantity : 0),
40053
+ type: "UPDATE_CELL_POSITION",
40049
40054
  });
40050
40055
  }
40051
40056
  }
40052
40057
  }
40053
40058
  }
40054
40059
  }
40055
- for (let cmd of commands.reverse()) {
40056
- this.dispatch(cmd.type, cmd);
40060
+ for (let update of updates.reverse()) {
40061
+ this.updateCellPosition(update);
40057
40062
  }
40058
40063
  }
40059
40064
  /**
@@ -40086,12 +40091,7 @@ class SheetPlugin extends CorePlugin {
40086
40091
  const colIndex = Number(i);
40087
40092
  const cellId = row.cells[i];
40088
40093
  if (cellId) {
40089
- this.dispatch("UPDATE_CELL_POSITION", {
40090
- sheetId: sheet.id,
40091
- cellId: cellId,
40092
- col: colIndex,
40093
- row: rowIndex - numberRows,
40094
- });
40094
+ this.setNewPosition(cellId, sheet.id, colIndex, rowIndex - numberRows);
40095
40095
  }
40096
40096
  }
40097
40097
  }
@@ -42700,17 +42700,17 @@ function isBadExpression(tokens) {
42700
42700
  */
42701
42701
  function sortWithClusters(colorsToSort) {
42702
42702
  const clusters = [
42703
- { leadColor: rgba(255, 0, 0), colors: [] },
42704
- { leadColor: rgba(255, 128, 0), colors: [] },
42705
- { leadColor: rgba(128, 128, 0), colors: [] },
42706
- { leadColor: rgba(128, 255, 0), colors: [] },
42707
- { leadColor: rgba(0, 255, 0), colors: [] },
42708
- { leadColor: rgba(0, 255, 128), colors: [] },
42709
- { leadColor: rgba(0, 255, 255), colors: [] },
42710
- { leadColor: rgba(0, 127, 255), colors: [] },
42711
- { leadColor: rgba(0, 0, 255), colors: [] },
42712
- { leadColor: rgba(127, 0, 255), colors: [] },
42713
- { leadColor: rgba(128, 0, 128), colors: [] },
42703
+ { leadColor: rgba(255, 0, 0), colors: [] }, // red
42704
+ { leadColor: rgba(255, 128, 0), colors: [] }, // orange
42705
+ { leadColor: rgba(128, 128, 0), colors: [] }, // yellow
42706
+ { leadColor: rgba(128, 255, 0), colors: [] }, // chartreuse
42707
+ { leadColor: rgba(0, 255, 0), colors: [] }, // green
42708
+ { leadColor: rgba(0, 255, 128), colors: [] }, // spring green
42709
+ { leadColor: rgba(0, 255, 255), colors: [] }, // cyan
42710
+ { leadColor: rgba(0, 127, 255), colors: [] }, // azure
42711
+ { leadColor: rgba(0, 0, 255), colors: [] }, // blue
42712
+ { leadColor: rgba(127, 0, 255), colors: [] }, // violet
42713
+ { leadColor: rgba(128, 0, 128), colors: [] }, // magenta
42714
42714
  { leadColor: rgba(255, 0, 128), colors: [] }, // rose
42715
42715
  ];
42716
42716
  for (const color of colorsToSort.map(colorToRGBA)) {
@@ -52497,7 +52497,7 @@ class BottomBar extends owl.Component {
52497
52497
  .map((sheetEl) => sheetEl.getBoundingClientRect())
52498
52498
  .map((rect) => ({
52499
52499
  x: rect.x,
52500
- width: rect.width - 1,
52500
+ width: rect.width - 1, // -1 to compensate negative margin
52501
52501
  y: rect.y,
52502
52502
  height: rect.height,
52503
52503
  }));
@@ -52719,7 +52719,7 @@ class RowGroup extends AbstractHeaderGroup {
52719
52719
  }
52720
52720
  return cssPropertiesToCss({
52721
52721
  top: `${groupBox.headerRect.height / 2}px`,
52722
- left: `calc(50% - 1px)`,
52722
+ left: `calc(50% - 1px)`, // -1px: we want the border to be on the center
52723
52723
  width: `30%`,
52724
52724
  height: `calc(100% - ${groupBox.headerRect.height / 2}px)`,
52725
52725
  "border-left": `1px solid ${HEADER_GROUPING_BORDER_COLOR}`,
@@ -52771,7 +52771,7 @@ class ColGroup extends AbstractHeaderGroup {
52771
52771
  return "";
52772
52772
  }
52773
52773
  return cssPropertiesToCss({
52774
- top: `calc(50% - 1px)`,
52774
+ top: `calc(50% - 1px)`, // -1px: we want the border to be on the center
52775
52775
  left: `${groupBox.headerRect.width / 2}px`,
52776
52776
  width: `calc(100% - ${groupBox.headerRect.width / 2}px)`,
52777
52777
  height: `30%`,
@@ -54182,7 +54182,7 @@ class Spreadsheet extends owl.Component {
54182
54182
  const gridColSize = GROUP_LAYER_WIDTH * this.rowLayers.length;
54183
54183
  const gridRowSize = GROUP_LAYER_WIDTH * this.colLayers.length;
54184
54184
  return cssPropertiesToCss({
54185
- "grid-template-columns": `${gridColSize ? gridColSize + 2 : 0}px auto`,
54185
+ "grid-template-columns": `${gridColSize ? gridColSize + 2 : 0}px auto`, // +2: margins
54186
54186
  "grid-template-rows": `${gridRowSize ? gridRowSize + 2 : 0}px auto`,
54187
54187
  });
54188
54188
  }
@@ -55627,7 +55627,7 @@ class SelectionStreamProcessorImpl {
55627
55627
  }
55628
55628
 
55629
55629
  class StateObserver {
55630
- changes = [];
55630
+ changes;
55631
55631
  commands = [];
55632
55632
  /**
55633
55633
  * Record the changes which could happen in the given callback, save them in a
@@ -55659,7 +55659,7 @@ class StateObserver {
55659
55659
  if (value[key] === val) {
55660
55660
  return;
55661
55661
  }
55662
- this.changes.push({
55662
+ this.changes?.push({
55663
55663
  path: args,
55664
55664
  before: value[key],
55665
55665
  after: val,
@@ -56790,7 +56790,7 @@ function addTableColumns(table, sheetData) {
56790
56790
  const colHeaderXc = toXC(tableZone.left + i, tableZone.top);
56791
56791
  const colName = sheetData.cells[colHeaderXc]?.content || `col${i}`;
56792
56792
  const colAttributes = [
56793
- ["id", i + 1],
56793
+ ["id", i + 1], // id cannot be 0
56794
56794
  ["name", colName],
56795
56795
  ];
56796
56796
  columns.push(escapeXml /*xml*/ `<tableColumn ${formatAttributes(colAttributes)}/>`);
@@ -57882,6 +57882,6 @@ exports.setTranslationMethod = setTranslationMethod;
57882
57882
  exports.tokenize = tokenize;
57883
57883
 
57884
57884
 
57885
- __info__.version = "17.1.25";
57886
- __info__.date = "2024-07-24T10:26:01.576Z";
57887
- __info__.hash = "0edff47";
57885
+ __info__.version = "17.1.26";
57886
+ __info__.date = "2024-08-02T08:23:08.499Z";
57887
+ __info__.hash = "4ba7e55";
@@ -7912,6 +7912,7 @@ declare class Composer extends Component<ComposerProps, SpreadsheetChildEnv> {
7912
7912
  autoCompleteState: AutoCompleteState;
7913
7913
  functionDescriptionState: FunctionDescriptionState;
7914
7914
  private compositionActive;
7915
+ private spreadsheetRect;
7915
7916
  get assistantStyle(): string;
7916
7917
  shouldProcessInputEvents: boolean;
7917
7918
  tokens: EnrichedToken[];
@@ -8130,7 +8131,7 @@ declare class Spreadsheet extends Component<SpreadsheetProps, SpreadsheetChildEn
8130
8131
  private keyDownMapping;
8131
8132
  private isViewportTooSmall;
8132
8133
  get model(): Model;
8133
- getStyle(): string;
8134
+ getStyle(): "grid-template-rows: auto;" | "grid-template-rows: 63px auto 37px";
8134
8135
  setup(): void;
8135
8136
  get focusTopBarComposer(): Omit<ComposerFocusType, "cellFocus">;
8136
8137
  get focusGridComposer(): ComposerFocusType;